fix(CORE-002C): align historical units with workspace weight
This commit is contained in:
@@ -3,7 +3,7 @@ from __future__ import annotations
|
||||
from fastapi.responses import RedirectResponse
|
||||
from nicegui import ui
|
||||
|
||||
from app.domain.backtesting_math import asset_quantity_from_floats
|
||||
from app.domain.backtesting_math import asset_quantity_from_workspace_config
|
||||
from app.models.workspace import get_workspace_repository
|
||||
from app.pages.common import dashboard_page, render_workspace_recovery
|
||||
from app.services.event_comparison_ui import EventComparisonPageService
|
||||
@@ -54,8 +54,8 @@ def _render_event_comparison_page(workspace_id: str | None = None) -> None:
|
||||
)
|
||||
default_entry_spot = default_preview.initial_portfolio.entry_spot
|
||||
default_units = (
|
||||
asset_quantity_from_floats(float(config.gold_value or 0.0), default_entry_spot, "GLD")
|
||||
if config and config.gold_value is not None and default_entry_spot > 0
|
||||
asset_quantity_from_workspace_config(config, entry_spot=default_entry_spot, symbol="GLD")
|
||||
if config is not None and default_entry_spot > 0
|
||||
else 1000.0
|
||||
)
|
||||
|
||||
@@ -129,7 +129,7 @@ def _render_event_comparison_page(workspace_id: str | None = None) -> None:
|
||||
template_select.value = list(service.default_template_selection(str(option["slug"])))
|
||||
try:
|
||||
preview_units = float(units_input.value or 0.0)
|
||||
if workspace_id and config is not None and config.gold_value is not None:
|
||||
if workspace_id and config is not None:
|
||||
preview_scenario = service.preview_scenario(
|
||||
preset_slug=str(option["slug"]),
|
||||
template_slugs=selected_template_slugs(),
|
||||
@@ -137,10 +137,10 @@ def _render_event_comparison_page(workspace_id: str | None = None) -> None:
|
||||
loan_amount=float(loan_input.value or 0.0),
|
||||
margin_call_ltv=float(ltv_input.value or 0.0),
|
||||
)
|
||||
preview_units = asset_quantity_from_floats(
|
||||
float(config.gold_value),
|
||||
float(preview_scenario.initial_portfolio.entry_spot),
|
||||
"GLD",
|
||||
preview_units = asset_quantity_from_workspace_config(
|
||||
config,
|
||||
entry_spot=float(preview_scenario.initial_portfolio.entry_spot),
|
||||
symbol="GLD",
|
||||
)
|
||||
units_input.value = preview_units
|
||||
scenario = service.preview_scenario(
|
||||
|
||||
Reference in New Issue
Block a user