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:
Discovers vaults via the public GraphQL API (includes per-vault fees)
Fetches per-vault share price history via
vault_summary_historyEnriches with TVL from
vault_detailStores 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 a single vault's share price history and store in the database. |
|
Run the daily GRVT vault metrics scan. |
Classes
DuckDB database for storing GRVT vault daily metrics. |
- 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.
- __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.
- 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_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
- get_all_vault_metadata()
Get metadata for all vaults.
- Returns
DataFrame with one row per vault.
- Return type
- 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
session (requests.sessions.Session) – HTTP session (no authentication needed).
db (eth_defi.grvt.daily_metrics.GRVTDailyMetricsDatabase) – The metrics database to write into.
summary (eth_defi.grvt.vault.GRVTVaultSummary) – Vault summary from the listing.
timeout (float) – HTTP request timeout.
- Returns
True if the vault was successfully processed.
- Return type
- 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.
Discovers vaults via the public GraphQL API (includes per-vault fees)
Fetches TVL from the market data API
Fetches per-vault share price history
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