From a2a816cc793251d6391dcfa4ed356e5653f04532 Mon Sep 17 00:00:00 2001 From: Bu5hm4nn Date: Wed, 1 Apr 2026 09:42:21 +0200 Subject: [PATCH] fix(backtest): use fixture provider ID for backtest scenario The backtest engine uses a fixture provider (synthetic_v1) regardless of the data_source used for price fetching. We must use the fixture provider's ID for the scenario, not the data source's ID. This fixes 'Unsupported provider/pricing combination' error when running backtests with data_source='databento'. --- app/services/backtesting/ui_service.py | 25 ++++++------------------- 1 file changed, 6 insertions(+), 19 deletions(-) diff --git a/app/services/backtesting/ui_service.py b/app/services/backtesting/ui_service.py index 9415c9c..b6db36d 100644 --- a/app/services/backtesting/ui_service.py +++ b/app/services/backtesting/ui_service.py @@ -323,25 +323,12 @@ class BacktestPageService: margin_call_ltv=normalized_inputs.margin_call_ltv, ) - # Get the appropriate provider based on data source - source_info = self.DATA_SOURCE_INFO.get(data_source, self.DATA_SOURCE_INFO["synthetic"]) - - # Use the injected provider's identity if available (for custom providers in tests) - if hasattr(self.backtest_service, "provider"): - injected_provider_id = getattr(self.backtest_service.provider, "provider_id", None) - injected_pricing_mode = getattr(self.backtest_service.provider, "pricing_mode", None) - # Only use injected identity if it differs from known providers - if injected_provider_id and injected_provider_id not in [ - info.provider_id for info in self.DATA_SOURCE_INFO.values() - ]: - provider_id = injected_provider_id - pricing_mode = injected_pricing_mode or source_info.pricing_mode - else: - provider_id = source_info.provider_id - pricing_mode = source_info.pricing_mode - else: - provider_id = source_info.provider_id - pricing_mode = source_info.pricing_mode + # CRITICAL: The backtest engine uses a fixture provider (synthetic_v1), + # regardless of the data_source used for price fetching. + # We must use the fixture provider's ID for the scenario, not the data source's ID. + # The data_source parameter only affects price data fetching, not the backtest engine. + provider_id = self.backtest_service.provider.provider_id + pricing_mode = self.backtest_service.provider.pricing_mode # For now, always use the synthetic engine (which uses fixture data for demo) # In a full implementation, we would create different engines for different providers