Files
vault-dash/tests/test_overview_workspace.py

27 lines
993 B
Python

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