run_daily_scan

Documentation for eth_defi.hyperliquid.daily_metrics.run_daily_scan function.

run_daily_scan(session, db_path=PosixPath('/home/runner/.tradingstrategy/vaults/hyperliquid-vaults.duckdb'), min_tvl=5000, max_vaults=20000, max_workers=16, cutoff_date=None, timeout=30.0, vault_addresses=None, flow_backfill_days=7, full_scan=False)

Run the daily Hyperliquid vault metrics scan.

  1. Bulk-fetches all vaults from stats-data API

  2. Filters by TVL and vault limit (or by explicit address list)

  3. Fetches per-vault details and computes share prices

  4. Fetches deposit/withdrawal events for flow metrics

  5. Stores everything in DuckDB

Parameters
  • session (eth_defi.hyperliquid.session.HyperliquidSession) – HTTP session with rate limiting. Use create_hyperliquid_session().

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

  • min_tvl (float) – Minimum TVL in USD to include a vault. Ignored when vault_addresses is provided.

  • max_vaults (int) – Maximum number of vaults to process (sorted by TVL descending). Ignored when vault_addresses is provided.

  • max_workers (int) – Number of parallel workers for fetching vault details.

  • cutoff_date (Optional[datetime.date]) – If provided, only store price data up to this date. Used for incremental scanning / testing.

  • timeout (float) – HTTP request timeout.

  • vault_addresses (Optional[list[str]]) – If provided, only scan these specific vault addresses. Overrides min_tvl and max_vaults filters.

  • flow_backfill_days (int) – Number of complete days to backfill deposit/withdrawal flow data. Only complete days are fetched (up to yesterday). Set to 0 to disable flow fetching. Use a large value (e.g. 365) for initial deep backfill.

  • full_scan (bool) – When True, bypass the min_tvl filter and process all vaults that exist in the database and are still present in the bulk API listing, regardless of their current TVL. This is intended to be run periodically (e.g. once a week) to refresh data for vaults that have dropped below the daily TVL threshold but still have historical data worth keeping current. The max_vaults limit still applies to cap total work. Ignored when vault_addresses is provided.

Returns

The metrics database instance.

Return type

eth_defi.hyperliquid.daily_metrics.HyperliquidDailyMetricsDatabase