fix(types): resolve all mypy type errors (CORE-003)
- Fix return type annotation for get_default_premium_for_product - Add type narrowing for Weight|Money union using _as_money helper - Add isinstance checks before float() calls for object types - Add type guard for Decimal.exponent comparison - Use _unit_typed and _currency_typed properties for type narrowing - Cast option_type to OptionType Literal after validation - Fix provider type hierarchy in backtesting services - Add types-requests to dev dependencies - Remove '|| true' from CI type-check job All 36 mypy errors resolved across 15 files.
This commit is contained in:
@@ -15,8 +15,16 @@ from app.models.backtest import (
|
||||
TemplateRef,
|
||||
)
|
||||
from app.services.backtesting.databento_source import DatabentoHistoricalPriceSource, DatabentoSourceConfig
|
||||
from app.services.backtesting.fixture_source import bind_fixture_source, build_backtest_ui_fixture_source
|
||||
from app.services.backtesting.historical_provider import DailyClosePoint, YFinanceHistoricalPriceSource
|
||||
from app.services.backtesting.fixture_source import (
|
||||
FixtureBoundSyntheticHistoricalProvider,
|
||||
SharedHistoricalFixtureSource,
|
||||
build_backtest_ui_fixture_source,
|
||||
)
|
||||
from app.services.backtesting.historical_provider import (
|
||||
DailyClosePoint,
|
||||
SyntheticHistoricalProvider,
|
||||
YFinanceHistoricalPriceSource,
|
||||
)
|
||||
from app.services.backtesting.input_normalization import normalize_historical_scenario_inputs
|
||||
from app.services.backtesting.service import BacktestService
|
||||
from app.services.strategy_templates import StrategyTemplateService
|
||||
@@ -98,7 +106,10 @@ class BacktestPageService:
|
||||
)
|
||||
self.template_service = template_service or base_service.template_service
|
||||
self.databento_config = databento_config
|
||||
fixture_provider = bind_fixture_source(base_service.provider, build_backtest_ui_fixture_source())
|
||||
fixture_provider = FixtureBoundSyntheticHistoricalProvider(
|
||||
base_provider=SyntheticHistoricalProvider(),
|
||||
source=build_backtest_ui_fixture_source(),
|
||||
)
|
||||
self.backtest_service = copy(base_service)
|
||||
self.backtest_service.provider = fixture_provider
|
||||
self.backtest_service.template_service = self.template_service
|
||||
@@ -135,11 +146,9 @@ class BacktestPageService:
|
||||
List of daily close points sorted by date
|
||||
"""
|
||||
if data_source == "databento":
|
||||
provider = self._get_databento_provider()
|
||||
return provider.load_daily_closes(symbol, start_date, end_date)
|
||||
return self._get_databento_provider().load_daily_closes(symbol, start_date, end_date)
|
||||
elif data_source == "yfinance":
|
||||
provider = self._get_yfinance_provider()
|
||||
return provider.load_daily_closes(symbol, start_date, end_date)
|
||||
return self._get_yfinance_provider().load_daily_closes(symbol, start_date, end_date)
|
||||
else:
|
||||
# Use synthetic fixture data
|
||||
return self.backtest_service.provider.load_history(symbol, start_date, end_date)
|
||||
|
||||
Reference in New Issue
Block a user