feat(CORE-001D): close remaining boundary cleanup slices

This commit is contained in:
Bu5hm4nn
2026-03-26 17:27:44 +01:00
parent 99d22302ee
commit 94f3c1ef83
16 changed files with 552 additions and 107 deletions

View File

@@ -6,6 +6,7 @@ from datetime import date
from app.models.backtest import BacktestScenario, EventComparisonReport
from app.services.backtesting.comparison import EventComparisonService
from app.services.backtesting.historical_provider import DailyClosePoint, SyntheticHistoricalProvider
from app.services.backtesting.input_normalization import normalize_historical_scenario_inputs
from app.services.event_presets import EventPresetService
from app.services.strategy_templates import StrategyTemplateService
@@ -151,12 +152,12 @@ class EventComparisonPageService:
raise ValueError("Preset selection is required")
if not template_slugs:
raise ValueError("Select at least one strategy template.")
if underlying_units <= 0:
raise ValueError("Underlying units must be positive")
if loan_amount < 0:
raise ValueError("Loan amount must be non-negative")
if not 0 < margin_call_ltv < 1:
raise ValueError("Margin call LTV must be between 0 and 1")
normalized_inputs = normalize_historical_scenario_inputs(
underlying_units=underlying_units,
loan_amount=loan_amount,
margin_call_ltv=margin_call_ltv,
)
preset = self.event_preset_service.get_preset(preset_slug)
normalized_symbol = preset.symbol.strip().upper()
@@ -179,15 +180,23 @@ class EventComparisonPageService:
preset.window_end,
)
if preview_history:
_validate_initial_collateral(underlying_units, preview_history[0].close, loan_amount)
_validate_initial_collateral(
normalized_inputs.underlying_units,
preview_history[0].close,
normalized_inputs.loan_amount,
)
raise
_validate_initial_collateral(underlying_units, preview.initial_portfolio.entry_spot, loan_amount)
_validate_initial_collateral(
normalized_inputs.underlying_units,
preview.initial_portfolio.entry_spot,
normalized_inputs.loan_amount,
)
return self.comparison_service.compare_event_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,
)
@staticmethod