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.
get_all_daily_prices([deployment])Retrieve all daily price data.
get_all_pool_metadata([deployment])Retrieve all pool metadata ordered by TVL.
get_pool_count([deployment])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[, deployment])Get the latest date with price data for a pool.
get_vault_count([deployment])Get number of pools with daily price data.
save()Force checkpoint to disk.
upsert_daily_prices(deployment, rows[, ...])Bulk upsert daily price rows for a pool.
upsert_pool_metadata(deployment, ...[, ...])Insert or update pool metadata.
- __init__(path)
- Parameters
path (pathlib.Path) –
- upsert_pool_metadata(deployment, 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
deployment (str) – Stable deployment slug.
account_index (int) – Pool account index, unique within the deployment.
name (str) – Pool display name.
l1_address (Optional[str]) – Operator address reported in the API’s legacy
l1_addressfield.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 the deployment’s collateral currency.
sharpe_ratio (Optional[float]) – Risk-adjusted return metric.
created_at (Optional[datetime.datetime]) – Pool creation timestamp.
- upsert_daily_prices(deployment, rows, cutoff_date=None)
Bulk upsert daily price rows for a pool.
- Parameters
deployment (str) – Stable deployment slug applied to every row.
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.
- get_all_daily_prices(deployment=None)
Retrieve all daily price data.
- get_pool_daily_prices(account_index, deployment='ethereum')
Get daily prices for a specific pool.
- Parameters
- Returns
DataFrame with daily price data for the pool.
- Return type
- get_all_pool_metadata(deployment=None)
Retrieve all pool metadata ordered by TVL.
- get_pool_count(deployment=None)
Get number of pools with daily price data.
- get_vault_count(deployment=None)
Get number of pools with daily price data.
Alias for
get_pool_count()to unify the interface across Hyperliquid, GRVT, and Lighter scanners.
- get_pool_daily_price_count(account_index, deployment='ethereum')
Get number of daily price records for a specific pool.
- get_pool_last_date(account_index, deployment='ethereum')
Get the latest date with price data for a pool.
- Parameters
- Returns
Latest date or
Noneif no data.- Return type
- save()
Force checkpoint to disk.
- close()
Close database connection.