pool_detail_to_daily_dataframe

Documentation for eth_defi.lighter.vault.pool_detail_to_daily_dataframe function.

pool_detail_to_daily_dataframe(detail, total_shares_by_date=None)

Convert pool detail share prices into a daily DataFrame.

Takes the share price history from the /api/v1/account endpoint and produces a DataFrame indexed by date with share_price, daily_return, and tvl columns.

Historical TVL is computed as pool_total_shares * share_price when total_shares_by_date is provided (from fetch_pool_total_shares_history()). Without it, TVL defaults to 0.

The share price array from the API contains daily entries with unix timestamps. We convert to dates and compute daily returns via pct_change().

Parameters
Returns

DataFrame indexed by date with share_price, daily_return, and tvl columns. Empty if insufficient data.

Return type

pandas.DataFrame