feat(CORE-001D): close remaining boundary cleanup slices
This commit is contained in:
@@ -18,6 +18,7 @@ from app.services.backtesting.historical_provider import (
|
||||
SyntheticHistoricalProvider,
|
||||
SyntheticOptionQuote,
|
||||
)
|
||||
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
|
||||
|
||||
@@ -149,12 +150,11 @@ class BacktestPageService:
|
||||
raise ValueError("BT-001A backtests are currently limited to GLD on this page")
|
||||
if start_date > end_date:
|
||||
raise ValueError("Start date must be on or before end date")
|
||||
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,
|
||||
)
|
||||
if not template_slug:
|
||||
raise ValueError("Template selection is required")
|
||||
|
||||
@@ -169,7 +169,11 @@ class BacktestPageService:
|
||||
raise ValueError(
|
||||
f"Supplied entry spot ${entry_spot:,.2f} does not match derived historical entry spot ${derived_entry_spot:,.2f}"
|
||||
)
|
||||
_validate_initial_collateral(underlying_units, derived_entry_spot, loan_amount)
|
||||
_validate_initial_collateral(
|
||||
normalized_inputs.underlying_units,
|
||||
derived_entry_spot,
|
||||
normalized_inputs.loan_amount,
|
||||
)
|
||||
return derived_entry_spot
|
||||
|
||||
def run_read_only_scenario(
|
||||
@@ -193,13 +197,18 @@ class BacktestPageService:
|
||||
loan_amount=loan_amount,
|
||||
margin_call_ltv=margin_call_ltv,
|
||||
)
|
||||
normalized_inputs = normalize_historical_scenario_inputs(
|
||||
underlying_units=underlying_units,
|
||||
loan_amount=loan_amount,
|
||||
margin_call_ltv=margin_call_ltv,
|
||||
)
|
||||
template = self.template_service.get_template(template_slug)
|
||||
initial_portfolio = materialize_backtest_portfolio_state(
|
||||
symbol=normalized_symbol,
|
||||
underlying_units=underlying_units,
|
||||
underlying_units=normalized_inputs.underlying_units,
|
||||
entry_spot=entry_spot,
|
||||
loan_amount=loan_amount,
|
||||
margin_call_ltv=margin_call_ltv,
|
||||
loan_amount=normalized_inputs.loan_amount,
|
||||
margin_call_ltv=normalized_inputs.margin_call_ltv,
|
||||
)
|
||||
scenario = BacktestScenario(
|
||||
scenario_id=(
|
||||
|
||||
Reference in New Issue
Block a user