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/accountendpoint and produces a DataFrame indexed by date withshare_price,daily_return, andtvlcolumns.Historical TVL is computed as
pool_total_shares * share_pricewhentotal_shares_by_dateis provided (fromfetch_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
detail (eth_defi.lighter.vault.LighterPoolDetail) – Pool detail with share_prices array.
total_shares_by_date (Optional[dict[datetime.date, int]]) – Mapping of
{date: pool_total_shares}from the PnL endpoint. Used to compute historical TVL.
- Returns
DataFrame indexed by date with
share_price,daily_return, andtvlcolumns. Empty if insufficient data.- Return type