From eaaf78cd12e7f6268dfb0164cccdce556c84bd07 Mon Sep 17 00:00:00 2001 From: Bu5hm4nn Date: Mon, 30 Mar 2026 09:11:47 +0200 Subject: [PATCH] fix(backtest): improve error message for dates outside fixture window - Add helpful message suggesting Databento/Yahoo Finance for dates outside fixture range - Update test to expect BOUNDED policy for backtest UI --- app/services/backtesting/fixture_source.py | 3 ++- tests/test_backtesting_fixture_source.py | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/app/services/backtesting/fixture_source.py b/app/services/backtesting/fixture_source.py index 2fdeea1..1363978 100644 --- a/app/services/backtesting/fixture_source.py +++ b/app/services/backtesting/fixture_source.py @@ -54,7 +54,8 @@ class SharedHistoricalFixtureSource: if start_date < self.start_date or end_date > self.end_date: raise ValueError( f"{self.feature_label} deterministic fixture data only supports the seeded " - f"{self.start_date.isoformat()} through {self.end_date.isoformat()} window" + f"{self.start_date.isoformat()} through {self.end_date.isoformat()} window. " + f"For dates outside this range, please use Databento or Yahoo Finance data source." ) return [point for point in self.history if start_date <= point.date <= end_date] diff --git a/tests/test_backtesting_fixture_source.py b/tests/test_backtesting_fixture_source.py index 9a4a838..54fb73d 100644 --- a/tests/test_backtesting_fixture_source.py +++ b/tests/test_backtesting_fixture_source.py @@ -54,14 +54,14 @@ def test_shared_fixture_source_bounded_window_allows_subranges_but_fails_closed_ source.load_daily_closes("GLD", date(2024, 1, 5), date(2024, 1, 3)) -def test_backtest_page_service_uses_shared_exact_fixture_source() -> None: +def test_backtest_page_service_uses_shared_bounded_fixture_source() -> None: service = BacktestPageService() source = service.backtest_service.provider.source assert isinstance(source, SharedHistoricalFixtureSource) assert source.feature_label == "BT-001A" - assert source.window_policy is WindowPolicy.EXACT + assert source.window_policy is WindowPolicy.BOUNDED def test_event_comparison_page_service_uses_shared_bounded_fixture_source() -> None: