Add cumulative P&L banner to fund overview for at-a-glance profit/loss.
Expose period delta from equity curve start and surface it in the toolbar and summary cards with green/red cues. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from lib.hub.hub_fund_history_lib import (
|
||||
account_total_usdt,
|
||||
build_fund_overview,
|
||||
compute_drawdown,
|
||||
compute_period_delta,
|
||||
get_fund_history,
|
||||
record_fund_snapshot,
|
||||
)
|
||||
@@ -23,6 +24,20 @@ def test_compute_drawdown():
|
||||
assert dd["max_drawdown_pct"] == 25.0
|
||||
|
||||
|
||||
def test_compute_period_delta():
|
||||
out = compute_period_delta(
|
||||
[
|
||||
{"day": "2026-06-09", "total_usdt": 100},
|
||||
{"day": "2026-06-10", "total_usdt": 112.5},
|
||||
]
|
||||
)
|
||||
assert out["start_usdt"] == 100.0
|
||||
assert out["period_delta_usdt"] == 12.5
|
||||
assert out["period_delta_pct"] == 12.5
|
||||
empty = compute_period_delta([])
|
||||
assert empty["period_delta_usdt"] is None
|
||||
|
||||
|
||||
def test_build_fund_overview_skips_unmonitored(tmp_path, monkeypatch):
|
||||
hist_path = tmp_path / "hub_fund_history.json"
|
||||
monkeypatch.setattr("hub_fund_history_lib.FUND_HISTORY_PATH", hist_path)
|
||||
|
||||
Reference in New Issue
Block a user