diff --git a/app/pages/hedge.py b/app/pages/hedge.py index 135a4a4..519a5fc 100644 --- a/app/pages/hedge.py +++ b/app/pages/hedge.py @@ -5,6 +5,7 @@ from nicegui import ui from app.pages.common import ( dashboard_page, demo_spot_price, + portfolio_snapshot, strategy_catalog, strategy_metrics, ) @@ -94,11 +95,16 @@ def hedge_page() -> None: def render_summary() -> None: metrics = strategy_metrics(selected["strategy"], selected["scenario_pct"]) strategy = metrics["strategy"] + portfolio = portfolio_snapshot() + starting_weight = portfolio["gold_value"] / portfolio["spot_price"] summary.clear() with summary: ui.label("Scenario Summary").classes("text-lg font-semibold text-slate-900 dark:text-slate-100") - with ui.grid(columns=2).classes("w-full gap-4 max-sm:grid-cols-1"): + with ui.grid(columns=3).classes("w-full gap-4 max-lg:grid-cols-2 max-sm:grid-cols-1"): cards = [ + ("Start value", f"${portfolio['gold_value']:,.0f}"), + ("Start price", f"${portfolio['spot_price']:,.2f}/oz"), + ("Weight", f"{starting_weight:,.0f} oz"), ("Scenario spot", f"${metrics['scenario_price']:,.2f}"), ("Hedge cost", f"${strategy['estimated_cost']:,.2f}/oz"), ("Unhedged equity", f"${metrics['unhedged_equity']:,.0f}"), diff --git a/tests/test_e2e_playwright.py b/tests/test_e2e_playwright.py index 34d50db..f1b8dbf 100644 --- a/tests/test_e2e_playwright.py +++ b/tests/test_e2e_playwright.py @@ -103,6 +103,12 @@ def test_homepage_and_options_page_render() -> None: page.mouse.click(slider_box["x"] + slider_box["width"] * 0.1, slider_box["y"] + slider_box["height"] / 2) expect(page.locator("text=Scenario move: -20%").first).to_be_visible(timeout=15000) hedge_text = page.locator("body").inner_text(timeout=15000) + assert "Start value" in hedge_text + assert "Start price" in hedge_text + assert "Weight" in hedge_text + assert "$215,000" in hedge_text + assert "$215.00/oz" in hedge_text + assert "1,000 oz" in hedge_text assert "Unhedged equity" in hedge_text assert "Hedged equity" in hedge_text assert "$27,000" in hedge_text