GRVTDailyMetricsDatabase

Documentation for eth_defi.grvt.daily_metrics.GRVTDailyMetricsDatabase Python class.

class GRVTDailyMetricsDatabase

Bases: object

DuckDB 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_history endpoint.

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_prices()

Get all daily price data across all vaults.

get_all_vault_metadata()

Get metadata for all vaults.

get_vault_count()

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.

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)

Insert or update a vault’s metadata.

Parameters
  • vault_id (str) – Vault string ID (e.g. VLT:xxx).

  • chain_vault_id (int) – Numeric on-chain vault ID.

  • management_fee (float | None) – Annual management fee as a decimal fraction (e.g. 0.01 = 1%).

  • performance_fee (float | None) – Performance fee as a decimal fraction (e.g. 0.20 = 20%).

  • name (str) –

  • description (str | None) –

  • vault_type (str | None) –

  • manager_name (str | None) –

  • tvl (float | None) –

  • share_price (float | None) –

  • investor_count (int | None) –

upsert_daily_prices(rows)

Bulk upsert daily price rows for a vault.

Parameters

rows (list[tuple]) – List of tuples: (vault_id, date, share_price, tvl, daily_return).

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

pandas.DataFrame

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

pandas.DataFrame

get_all_vault_metadata()

Get metadata for all vaults.

Returns

DataFrame with one row per vault.

Return type

pandas.DataFrame

get_vault_count()

Get the number of unique vaults with price data.

Return type

int

save()

Force a checkpoint to ensure data is written to disk.

close()

Close the database connection.