analyse_positions_and_deposits

Documentation for eth_defi.hyperliquid.combined_analysis.analyse_positions_and_deposits function.

analyse_positions_and_deposits(position_df, deposit_df, initial_balance=0.0)

Combine position and deposit DataFrames into a unified timeline.

This function merges trading activity (positions/PnL) with capital flows (deposits/withdrawals) to create a comprehensive view of vault performance.

The resulting DataFrame contains:

  • pnl_update: Change in realised PnL at this timestamp (from trading)

  • netflow_update: Change in capital at this timestamp (deposits positive, withdrawals negative)

  • cumulative_pnl: Running total of realised trading PnL

  • cumulative_netflow: Running total of capital flows (deposits - withdrawals)

  • cumulative_account_value: Total account value (initial_balance + netflow + pnl)

  • total_assets: Alias for cumulative_account_value (NAV)

  • total_supply: Number of shares outstanding

  • share_price: Share price calculated as total_assets / total_supply

The share price calculation follows ERC-4626 vault mechanics:

  • Share price starts at 1.00 when the first deposit occurs

  • When deposits occur, new shares are minted at the current share price

  • When withdrawals occur, shares are burned at the current share price

  • PnL changes affect total_assets but not total_supply, thus changing share price

The DataFrame is indexed by timestamp and sorted chronologically, combining events from both position changes and deposit/withdrawal activity.

Example:

from eth_defi.hyperliquid.combined_analysis import analyse_positions_and_deposits

# Assuming position_df and deposit_df are already created
combined = analyse_positions_and_deposits(position_df, deposit_df, initial_balance=1000.0)

# Get final values
final_pnl = combined["cumulative_pnl"].iloc[-1]
final_netflow = combined["cumulative_netflow"].iloc[-1]
final_value = combined["cumulative_account_value"].iloc[-1]
final_share_price = combined["share_price"].iloc[-1]

print(f"Trading PnL: ${final_pnl:,.2f}")
print(f"Net capital flow: ${final_netflow:,.2f}")
print(f"Account value: ${final_value:,.2f}")
print(f"Share price: ${final_share_price:.4f}")
Parameters
Returns

DataFrame with unified timeline containing PnL, capital flow, and share price metrics.

Return type

pandas.DataFrame