HibachiDailyMetricsDatabase
Documentation for eth_defi.hibachi.daily_metrics.HibachiDailyMetricsDatabase Python class.
- class HibachiDailyMetricsDatabase
Bases:
objectDuckDB database for storing Hibachi vault daily metrics.
Stores daily share price time series and vault metadata. The share prices come from the Hibachi data API’s
/vault/performanceendpoint.Example:
from pathlib import Path from eth_defi.hibachi.daily_metrics import HibachiDailyMetricsDatabase db = HibachiDailyMetricsDatabase(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, symbol, ...)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 (int) – Vault 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, symbol, short_description, description, per_share_price, outstanding_shares, tvl, min_unlock_hours, vault_pub_key=None, vault_asset_id=None)
Insert or update a vault’s metadata.
- Parameters
vault_id (int) – Unique vault ID on the Hibachi platform.
symbol (str) – Short ticker symbol (e.g.
GAV).description (Optional[str]) – Long description of the vault strategy.
per_share_price (Optional[float]) – Current share price in USDT.
min_unlock_hours (Optional[int]) – Minimum lockup period in hours.
vault_pub_key (Optional[str]) – Vault’s on-exchange public key.
vault_asset_id (Optional[int]) – Native asset ID of the vault share token.