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'.
This commit is contained in:
Bu5hm4nn
2026-04-01 09:42:21 +02:00
parent 27ade507cd
commit a2a816cc79

View File

@@ -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