fix(backtest): remove BT-001A exact window restriction now that full data access is available
- Change WindowPolicy from EXACT to BOUNDED for backtest fixture - Pass data_source to run_read_only_scenario so real data can be used - Fix injected provider identity preservation in BacktestPageService - Add type: ignore for BacktestHistoricalProvider protocol assignment - Revert TypedDict change to avoid cascading type issues in pages/ - Update tests to reflect new BOUNDED policy behavior
This commit is contained in:
@@ -175,31 +175,32 @@ def test_backtest_page_service_validation_errors_are_user_facing(kwargs: dict[st
|
||||
|
||||
|
||||
def test_backtest_page_service_fails_closed_outside_seeded_fixture_window() -> None:
|
||||
"""Test that fixture data fails for dates outside the seeded window."""
|
||||
service = BacktestPageService()
|
||||
|
||||
# Wrong symbol raises error (fixture only supports GLD)
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports GLD"):
|
||||
service.derive_entry_spot("GLD", date(2024, 1, 3), date(2024, 1, 8))
|
||||
service.derive_entry_spot("AAPL", date(2024, 1, 2), date(2024, 1, 8))
|
||||
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports GLD"):
|
||||
service.run_read_only_scenario(
|
||||
symbol="GLD",
|
||||
start_date=date(2024, 1, 3),
|
||||
end_date=date(2024, 1, 8),
|
||||
template_slug="protective-put-atm-12m",
|
||||
underlying_units=1000.0,
|
||||
loan_amount=68000.0,
|
||||
margin_call_ltv=0.75,
|
||||
)
|
||||
# Dates before window start raises error
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports the seeded"):
|
||||
service.derive_entry_spot("GLD", date(2024, 1, 1), date(2024, 1, 5))
|
||||
|
||||
# Dates after window end raises error
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports the seeded"):
|
||||
service.derive_entry_spot("GLD", date(2024, 1, 5), date(2024, 1, 10))
|
||||
|
||||
|
||||
def test_backtest_preview_validation_requires_supported_fixture_window_even_with_supplied_entry_spot() -> None:
|
||||
"""Test that fixture data fails for dates outside the window even with supplied entry spot."""
|
||||
service = BacktestPageService()
|
||||
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports GLD"):
|
||||
# Dates before window start raises error
|
||||
with pytest.raises(ValueError, match="deterministic fixture data only supports the seeded"):
|
||||
service.validate_preview_inputs(
|
||||
symbol="GLD",
|
||||
start_date=date(2024, 1, 3),
|
||||
end_date=date(2024, 1, 8),
|
||||
start_date=date(2024, 1, 1),
|
||||
end_date=date(2024, 1, 5),
|
||||
template_slug="protective-put-atm-12m",
|
||||
underlying_units=1000.0,
|
||||
loan_amount=68000.0,
|
||||
|
||||
Reference in New Issue
Block a user