create_account_dataframe

Documentation for eth_defi.hyperliquid.position_analysis.create_account_dataframe function.

create_account_dataframe(events)

Create a DataFrame from position events with exposure and PnL columns per market.

Creates a time-indexed DataFrame where each row represents a point in time when a position event occurred. For each market (coin), the DataFrame contains columns for both long and short directions tracking exposure and cumulative PnL.

Column naming convention: - {coin}_long_exposure: Long position exposure (positive = size * price) - {coin}_long_pnl: Cumulative realized PnL from long positions - {coin}_short_exposure: Short position exposure (positive = abs(size) * price) - {coin}_short_pnl: Cumulative realized PnL from short positions

The total account PnL at any row can be calculated by summing all *_pnl columns.

Parameters

events (Iterable[eth_defi.hyperliquid.position.PositionEvent]) – Iterator of position events from reconstruct_position_history(). Events should be in chronological order.

Returns

DataFrame with timestamp index and columns for each market/direction combination. Exposure represents the notional value (size * price) of open positions. PnL columns contain cumulative realized PnL.

Return type

pandas.core.frame.DataFrame