grvt.daily_metrics

Documentation for eth_defi.grvt.daily_metrics Python module.

GRVT daily vault metrics with DuckDB storage.

This module provides a daily pipeline for scanning GRVT vault metrics and storing them in a DuckDB database. It derives daily share prices from the public vault_summary_history endpoint on the GRVT market data API.

The pipeline:

  1. Discovers vaults via the public GraphQL API (includes per-vault fees)

  2. Fetches per-vault share price history via vault_summary_history

  3. Enriches with TVL from vault_detail

  4. Stores daily prices and metadata in DuckDB

Example:

from eth_defi.grvt.daily_metrics import run_daily_scan, GRVTDailyMetricsDatabase

db = run_daily_scan()
print(f"Stored metrics for {db.get_vault_count()} vaults")
db.close()

Functions

fetch_and_store_vault(session, db, summary)

Fetch a single vault's share price history and store in the database.

run_daily_scan([session, db_path, timeout, ...])

Run the daily GRVT vault metrics scan.

Classes

GRVTDailyMetricsDatabase

DuckDB database for storing GRVT vault daily metrics.

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.

__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.

fetch_and_store_vault(session, db, summary, timeout=30.0)

Fetch a single vault’s share price history and store in the database.

Parameters
Returns

True if the vault was successfully processed.

Return type

bool

run_daily_scan(session=None, db_path=PosixPath('/home/runner/.tradingstrategy/vaults/grvt-vaults.duckdb'), timeout=30.0, vault_ids=None, only_discoverable=True)

Run the daily GRVT vault metrics scan.

  1. Discovers vaults via the public GraphQL API (includes per-vault fees)

  2. Fetches TVL from the market data API

  3. Fetches per-vault share price history

  4. Stores everything in DuckDB

No authentication is required — all data comes from public endpoints.

Parameters
  • session (requests.sessions.Session | None) – HTTP session. If None, one is created via create_grvt_session().

  • db_path (pathlib.Path) – Path to the DuckDB database file.

  • timeout (float) – HTTP request timeout.

  • vault_ids (list[str] | None) – If provided, only scan these specific vault string IDs. Overrides the default vault listing.

  • only_discoverable (bool) – If True, only scan vaults marked as discoverable.

Returns

The metrics database instance.

Return type

eth_defi.grvt.daily_metrics.GRVTDailyMetricsDatabase