calculate_period_metrics

Documentation for eth_defi.research.vault_metrics.calculate_period_metrics function.

calculate_period_metrics(period, gross_fee_data, net_fee_data, share_price_hourly, share_price_daily, daily_returns, tvl, now_, utilisation=None, native_fee_share_price=None, exchange_rate=None)

Calculate metrics for one period.

This pandas entry point converts its inputs with _period_inputs_from_series() and delegates to _calculate_period_metrics_from_arrays(). Batch calculations should convert once per vault and call calculate_period_results() instead.

K-ratio uses the 2013 convention on the supplied daily price curve, with 365 observations per year and no additional fee adjustment. See calculate_k_ratio() and PeriodMetrics.

Parameters
  • period (Literal['1W', '1M', '3M', '6M', '1Y', 'lifetime']) – Period identifier (1W, 1M, 3M, 6M, 1Y, lifetime)

  • gross_fee_data (eth_defi.vault.fee.FeeData) – Fee data before fee mode adjustments

  • net_fee_data (eth_defi.vault.fee.FeeData) – Fee data after fee mode adjustments (for net return calculations)

  • share_price_hourly (pandas.Series) – Sparse source share-price observations with a DatetimeIndex. The historical name is retained for API compatibility; the series is not assumed to contain every hour.

  • share_price_daily (pandas.Series) – Regular, forward-filled daily share-price series prepared once for the vault with prepare_daily_share_price_series(). For sparse sources, this is an explicit approximation rather than a continuous NAV series.

  • daily_returns (pandas.Series) – Regular daily returns derived once from share_price_daily. The same series must be passed to every period calculation for the vault. Unobserved days have zero return and the next observed day receives the accumulated movement.

  • tvl (pandas.Series) – Total value locked series with DatetimeIndex

  • now – The reference timestamp (usually the last timestamp in the data)

  • utilisation (Optional[pandas.Series]) – Optional regular daily utilisation series (lending vaults only, values 0.0–1.0). When provided, avg_utilisation is a calendar-day average for the period rather than an observation-frequency average.

  • native_fee_share_price (Optional[pandas.Series]) – Optional sparse native-denomination prices aligned to share_price_hourly. USD metrics use these values when calculating externalised investor fees, so a vault performance fee is never charged on ETH/BTC/USD market appreciation.

  • exchange_rate (Optional[pandas.Series]) – Optional USD-per-underlying sparse rate series aligned to share_price_hourly. Must be supplied together with native_fee_share_price.

  • now_ (pandas.Timestamp) –

Returns

PeriodMetrics dataclass with calculated metrics

Return type

eth_defi.research.vault_metrics.PeriodMetrics