fix: restore workspace nav and correct overview spot fallback

This commit is contained in:
Bu5hm4nn
2026-03-24 20:54:45 +01:00
parent 75f8e0a282
commit 2cbe4f274d
4 changed files with 74 additions and 7 deletions

View File

@@ -0,0 +1,26 @@
from __future__ import annotations
from app.models.portfolio import PortfolioConfig
from app.pages.overview import _resolve_overview_spot
from app.services.alerts import build_portfolio_alert_context
def test_overview_falls_back_to_configured_entry_price_when_live_quote_units_do_not_match() -> None:
config = PortfolioConfig(entry_price=4400.0, gold_ounces=220.0, entry_basis_mode="weight", loan_amount=145000.0)
spot_price, source, updated_at = _resolve_overview_spot(
config,
{"price": 404.19, "source": "yfinance", "updated_at": "2026-03-24T00:00:00+00:00"},
)
portfolio = build_portfolio_alert_context(
config,
spot_price=spot_price,
source=source,
updated_at=updated_at,
)
assert spot_price == 4400.0
assert source == "configured_entry_price"
assert portfolio["gold_value"] == 968000.0
assert portfolio["net_equity"] == 823000.0
assert round(float(portfolio["margin_call_price"]), 2) == 878.79