GRVTDailyMetricsDatabase
Documentation for eth_defi.grvt.daily_metrics.GRVTDailyMetricsDatabase Python class.
- class GRVTDailyMetricsDatabase
Bases:
objectDuckDB database for storing GRVT vault daily metrics.
Stores daily share price time series and vault metadata. The share prices come from the GRVT market data API’s
vault_summary_historyendpoint.Example:
from pathlib import Path from eth_defi.grvt.daily_metrics import GRVTDailyMetricsDatabase db = GRVTDailyMetricsDatabase(Path("/tmp/metrics.duckdb")) df = db.get_all_daily_prices() print(df) db.close()Initialise the database connection.
- Parameters
path – Path to the DuckDB file. Parent directories will be created if needed.
Methods summary
__init__(path)Initialise the database connection.
close()Close the database connection.
Get all daily price data across all vaults.
Get metadata for all vaults.
Get the number of unique vaults with price data.
get_vault_daily_prices(vault_id)Get daily price data for a specific vault.
save()Force a checkpoint to ensure data is written to disk.
upsert_daily_prices(rows)Bulk upsert daily price rows for a vault.
upsert_vault_metadata(vault_id, ...[, ...])Insert or update a vault's metadata.
- __init__(path)
Initialise the database connection.
- Parameters
path (pathlib.Path) – Path to the DuckDB file. Parent directories will be created if needed.
- close()
Close the database connection.
- get_all_daily_prices()
Get all daily price data across all vaults.
- Returns
DataFrame with all daily price records, ordered by vault then date.
- Return type
- get_all_vault_metadata()
Get metadata for all vaults.
- Returns
DataFrame with one row per vault.
- Return type
- get_vault_count()
Get the number of unique vaults with price data.
- Return type
- get_vault_daily_prices(vault_id)
Get daily price data for a specific vault.
- Parameters
vault_id (str) – Vault string ID to query.
- Returns
DataFrame with price records for this vault, ordered by date.
- Return type
- save()
Force a checkpoint to ensure data is written to disk.
- upsert_daily_prices(rows)
Bulk upsert daily price rows for a vault.
- upsert_vault_metadata(vault_id, chain_vault_id, name, description, vault_type, manager_name, tvl, share_price, investor_count, management_fee=None, performance_fee=None, extended_vault_info=None, extended_info_max_age=datetime.timedelta(days=7))
Insert or update a vault’s metadata.
The regular fields (name, TVL, fees, description, …) are updated on every call. The
extended_vault_infoJSON dump is only refreshed when the existingextended_vault_info_metadata_last_updated_atis missing or older thanextended_info_max_age, so the column does not churn on every daily scan. The refresh decision is made atomically inside theON CONFLICTclause.- Parameters
vault_id (str) – Vault string ID (e.g.
VLT:xxx).chain_vault_id (int) – Numeric on-chain vault ID.
management_fee (Optional[float]) – Annual management fee as a decimal fraction (e.g. 0.01 = 1%).
performance_fee (Optional[float]) – Performance fee as a decimal fraction (e.g. 0.20 = 20%).
extended_vault_info (Optional[str]) – Raw extended metadata as a JSON string (the full GraphQL vault node, including
managerInfo).Noneleaves the stored value unchanged.extended_info_max_age (datetime.timedelta) – Maximum age of the stored extended info before it is refreshed on update. New rows always store the supplied value.
name (str) –