fix: fund overview history starts from 2026-06-09
Add HUB_FUND_HISTORY_START_DAY so curves and drawdown exclude snapshots before the baseline trading day. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
@@ -5,6 +5,7 @@ from hub_fund_history_lib import (
|
||||
account_total_usdt,
|
||||
build_fund_overview,
|
||||
compute_drawdown,
|
||||
get_fund_history,
|
||||
record_fund_snapshot,
|
||||
)
|
||||
|
||||
@@ -77,3 +78,38 @@ def test_build_fund_overview_skips_unmonitored(tmp_path, monkeypatch):
|
||||
assert off["monitored"] is False
|
||||
assert off["total_usdt"] is None
|
||||
assert out["totals"]["drawdown"]["max_drawdown_u"] == 0.0
|
||||
|
||||
|
||||
def test_history_start_day_filters_older(tmp_path, monkeypatch):
|
||||
hist_path = tmp_path / "hub_fund_history.json"
|
||||
monkeypatch.setattr("hub_fund_history_lib.FUND_HISTORY_PATH", hist_path)
|
||||
monkeypatch.setattr("hub_fund_history_lib.FUND_HISTORY_START_DAY", "2026-06-09")
|
||||
record_fund_snapshot(
|
||||
"2026-06-01",
|
||||
[
|
||||
{
|
||||
"key": "binance",
|
||||
"name": "Binance",
|
||||
"funding_usdt": 1,
|
||||
"trading_usdt": 1,
|
||||
"monitored": True,
|
||||
}
|
||||
],
|
||||
keep_days=180,
|
||||
)
|
||||
record_fund_snapshot(
|
||||
"2026-06-09",
|
||||
[
|
||||
{
|
||||
"key": "binance",
|
||||
"name": "Binance",
|
||||
"funding_usdt": 10,
|
||||
"trading_usdt": 20,
|
||||
"monitored": True,
|
||||
}
|
||||
],
|
||||
keep_days=180,
|
||||
)
|
||||
hist = get_fund_history(anchor_day="2026-06-10", keep_days=180)
|
||||
assert "2026-06-01" not in hist
|
||||
assert "2026-06-09" in hist
|
||||
|
||||
Reference in New Issue
Block a user