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:
@@ -323,25 +323,12 @@ class BacktestPageService:
|
|||||||
margin_call_ltv=normalized_inputs.margin_call_ltv,
|
margin_call_ltv=normalized_inputs.margin_call_ltv,
|
||||||
)
|
)
|
||||||
|
|
||||||
# Get the appropriate provider based on data source
|
# CRITICAL: The backtest engine uses a fixture provider (synthetic_v1),
|
||||||
source_info = self.DATA_SOURCE_INFO.get(data_source, self.DATA_SOURCE_INFO["synthetic"])
|
# 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.
|
||||||
# Use the injected provider's identity if available (for custom providers in tests)
|
# The data_source parameter only affects price data fetching, not the backtest engine.
|
||||||
if hasattr(self.backtest_service, "provider"):
|
provider_id = self.backtest_service.provider.provider_id
|
||||||
injected_provider_id = getattr(self.backtest_service.provider, "provider_id", None)
|
pricing_mode = self.backtest_service.provider.pricing_mode
|
||||||
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
|
|
||||||
|
|
||||||
# For now, always use the synthetic engine (which uses fixture data for demo)
|
# 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
|
# In a full implementation, we would create different engines for different providers
|
||||||
|
|||||||
Reference in New Issue
Block a user