fix(CORE-001D): close boundary review gaps

This commit is contained in:
Bu5hm4nn
2026-03-26 17:34:09 +01:00
parent 94f3c1ef83
commit bdf56ecebe
4 changed files with 70 additions and 12 deletions

View File

@@ -117,13 +117,18 @@ class EventComparisonPageService:
) -> BacktestScenario:
if not template_slugs:
raise ValueError("Select at least one strategy template.")
normalized_inputs = normalize_historical_scenario_inputs(
underlying_units=underlying_units,
loan_amount=loan_amount,
margin_call_ltv=margin_call_ltv,
)
try:
scenario = self.comparison_service.preview_scenario_from_inputs(
preset_slug=preset_slug,
template_slugs=template_slugs,
underlying_units=underlying_units,
loan_amount=loan_amount,
margin_call_ltv=margin_call_ltv,
underlying_units=normalized_inputs.underlying_units,
loan_amount=normalized_inputs.loan_amount,
margin_call_ltv=normalized_inputs.margin_call_ltv,
)
except ValueError as exc:
if str(exc) == "loan_amount must be less than initial collateral value":
@@ -134,9 +139,17 @@ class EventComparisonPageService:
preset.window_end,
)
if preview:
_validate_initial_collateral(underlying_units, preview[0].close, loan_amount)
_validate_initial_collateral(
normalized_inputs.underlying_units,
preview[0].close,
normalized_inputs.loan_amount,
)
raise
_validate_initial_collateral(underlying_units, scenario.initial_portfolio.entry_spot, loan_amount)
_validate_initial_collateral(
normalized_inputs.underlying_units,
scenario.initial_portfolio.entry_spot,
normalized_inputs.loan_amount,
)
return scenario
def run_read_only_comparison(