LighterDailyMetricsDatabase
Documentation for eth_defi.lighter.daily_metrics.LighterDailyMetricsDatabase Python class.
- class LighterDailyMetricsDatabase
Bases:
objectDuckDB database for storing Lighter pool daily metrics.
Stores two tables:
pool_metadata: Pool information (name, description, fees, TVL, etc.)pool_daily_prices: Daily share price time series with returns
- Parameters
path – Path to the DuckDB database file.
Methods summary
__init__(path)close()Close database connection.
Retrieve all daily price data.
Retrieve all pool metadata ordered by TVL.
Get number of pools with daily price data.
get_pool_daily_price_count(account_index)Get number of daily price records for a specific pool.
get_pool_daily_prices(account_index)Get daily prices for a specific pool.
get_pool_last_date(account_index)Get the latest date with price data for a pool.
Get number of pools with daily price data.
save()Force checkpoint to disk.
upsert_daily_prices(rows[, cutoff_date])Bulk upsert daily price rows for a pool.
upsert_pool_metadata(account_index, name[, ...])Insert or update pool metadata.
- __init__(path)
- Parameters
path (pathlib.Path) –
- close()
Close database connection.
- get_all_daily_prices()
Retrieve all daily price data.
- Returns
DataFrame with columns: account_index, date, share_price, tvl, daily_return, annual_percentage_yield.
- Return type
- get_all_pool_metadata()
Retrieve all pool metadata ordered by TVL.
- Returns
DataFrame with pool metadata.
- Return type
- get_pool_count()
Get number of pools with daily price data.
- Returns
Count of unique pools.
- Return type
- get_pool_daily_price_count(account_index)
Get number of daily price records for a specific pool.
- get_pool_daily_prices(account_index)
Get daily prices for a specific pool.
- Parameters
account_index (int) – Pool account index.
- Returns
DataFrame with daily price data for the pool.
- Return type
- get_pool_last_date(account_index)
Get the latest date with price data for a pool.
- Parameters
account_index (int) – Pool account index.
- Returns
Latest date or
Noneif no data.- Return type
- get_vault_count()
Get number of pools with daily price data.
Alias for
get_pool_count()to unify the interface across Hyperliquid, GRVT, and Lighter scanners.- Returns
Count of unique pools.
- Return type
- save()
Force checkpoint to disk.
- upsert_daily_prices(rows, cutoff_date=None)
Bulk upsert daily price rows for a pool.
- Parameters
rows (list[tuple]) – List of tuples:
(account_index, date, share_price, tvl, daily_return, annual_percentage_yield, written_at).cutoff_date (Optional[datetime.date]) – If provided, only store rows up to this date (inclusive). Used for incremental scanning / testing.
- upsert_pool_metadata(account_index, name, description=None, l1_address=None, is_llp=False, status=0, operator_fee=None, total_asset_value=None, annual_percentage_yield=None, sharpe_ratio=None, created_at=None)
Insert or update pool metadata.
- Parameters
account_index (int) – Pool account index (primary key).
name (str) – Pool display name.
is_llp (bool) – Whether this is the LLP protocol pool.
status (int) – Pool status code from the API (0 = active).
total_asset_value (Optional[float]) – Total value locked in USDC.
sharpe_ratio (Optional[float]) – Risk-adjusted return metric.
created_at (Optional[datetime.datetime]) – Pool creation timestamp.