refactor(pre-alpha): fail closed on historical fixture bounds

This commit is contained in:
Bu5hm4nn
2026-03-26 12:04:42 +01:00
parent f38d0a53a9
commit 68275c4d18
5 changed files with 82 additions and 17 deletions

View File

@@ -150,3 +150,38 @@ def test_backtest_page_service_validation_errors_are_user_facing(kwargs: dict[st
with pytest.raises(ValueError, match=message):
service.run_read_only_scenario(**kwargs)
def test_backtest_page_service_fails_closed_outside_seeded_fixture_window() -> None:
service = BacktestPageService()
with pytest.raises(ValueError, match="deterministic fixture data only supports GLD"):
service.derive_entry_spot("GLD", date(2024, 1, 3), 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,
)
def test_backtest_preview_validation_reuses_supplied_entry_spot() -> None:
service = BacktestPageService()
entry_spot = service.validate_preview_inputs(
symbol="GLD",
start_date=date(2024, 1, 2),
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,
entry_spot=100.0,
)
assert entry_spot == 100.0