group_fills_into_trades

Documentation for eth_defi.hyperliquid.trade_history.group_fills_into_trades function.

group_fills_into_trades(events, fills=None)

Group position events into round-trip trades.

Processes position events chronologically and groups them into round-trip trades. Each trade tracks a position from open to close (or to the current state if still open).

When a position was already open before the data window (i.e. the earliest fill has a non-zero start_position), the trade is marked as is_complete=False.

Parameters
Returns

Tuple of (closed_trades, open_trades).

Return type

tuple[list[eth_defi.hyperliquid.trade_history.RoundTripTrade], list[eth_defi.hyperliquid.trade_history.RoundTripTrade]]