Fixed a UI bug calculating equity percentage incorrectly.

This commit is contained in:
2026-08-11 21:22:21 +03:00
parent 1faca2cdda
commit 03a724f7ea
2 changed files with 21 additions and 6 deletions
+19
View File
@@ -139,3 +139,22 @@ def test_render_dashboard_contains_requested_sections() -> None:
assert "FILLED</span>" in html
assert "orderside.sell" not in html
assert "orderstatus.filled" not in html
def test_portfolio_percentage_uses_current_portfolio_total() -> None:
html = render_dashboard(
DashboardSnapshot(
refreshed_at=datetime(2026, 8, 11, 10, 0, tzinfo=UTC),
performance=[
PerformancePoint(date(2026, 8, 11), 10_000.0, 10_000.0),
],
portfolio=[
PortfolioRow("CASH", "cash", None, 100.0, None, None, None),
PortfolioRow("SPY", "us_equity", 10.0, 10_000.0, 900.0, 1_000.0, 1_000.0),
],
trades=[],
)
)
assert "99.01%" in html
assert "100.00%" not in html