diff --git a/scripts/run_walk_forward_backtest.py b/scripts/run_walk_forward_backtest.py index ff69b60..ed8eddf 100644 --- a/scripts/run_walk_forward_backtest.py +++ b/scripts/run_walk_forward_backtest.py @@ -31,6 +31,8 @@ ) DEFAULT_STORE_ROOT = Path("/tmp/crypto_wf_store") DRIFT_BASELINE_HORIZON_DAYS = 126 +CRYPTO_PERIODS_PER_YEAR = 365.25 +CRYPTO_CALENDAR_ID = "CRYPTO_NATURAL_DAY" PROFILE_DEFAULTS: dict[str, dict[str, Any]] = { PROFILE_NAME: {"min_history_days": DEFAULT_MIN_HISTORY_DAYS, "top_n": 2, "rebalance_every": 7}, @@ -191,7 +193,12 @@ def _write_return_matrix( def _baseline_from_return_tail(full_result: Any, returns: pd.Series) -> Any: tail = returns.tail(DRIFT_BASELINE_HORIZON_DAYS) - metrics = compute_window_metrics(tail, window_days=DRIFT_BASELINE_HORIZON_DAYS) + metrics = compute_window_metrics( + tail, + window_days=DRIFT_BASELINE_HORIZON_DAYS, + periods_per_year=CRYPTO_PERIODS_PER_YEAR, + calendar_id=CRYPTO_CALENDAR_ID, + ) max_drawdown = float(metrics.max_drawdown) cagr = float(metrics.cagr) return replace( @@ -206,6 +213,8 @@ def _baseline_from_return_tail(full_result: Any, returns: pd.Series) -> Any: start_date=metrics.start_date, end_date=metrics.end_date, observation_count=metrics.observation_count, + periods_per_year=metrics.periods_per_year, + calendar_id=metrics.calendar_id, ) diff --git a/src/crypto_strategies/backtest/orchestrator_runner.py b/src/crypto_strategies/backtest/orchestrator_runner.py index dffe697..4db08c3 100644 --- a/src/crypto_strategies/backtest/orchestrator_runner.py +++ b/src/crypto_strategies/backtest/orchestrator_runner.py @@ -24,6 +24,8 @@ COMBO_DEFAULT_MIN_HISTORY_DAYS = 260 SUPPORTED_PROFILES = frozenset({PROFILE_NAME, CRYPTO_EQUITY_COMBO_PROFILE}) SYNTHETIC_PANEL_GENERATOR_VERSION = "crypto_live_pool_panel.v2" +CRYPTO_PERIODS_PER_YEAR = 365.25 +CRYPTO_CALENDAR_ID = "CRYPTO_NATURAL_DAY" def _synthetic_digest_int(*parts: str) -> int: @@ -144,6 +146,8 @@ def _metrics_to_result( source_script="crypto_strategies.backtest.orchestrator_runner", computed_at=datetime.now(timezone.utc).isoformat(), run_duration_seconds=run_duration_seconds, + periods_per_year=CRYPTO_PERIODS_PER_YEAR, + calendar_id=CRYPTO_CALENDAR_ID, )