fix(live): 监控页三修——①收益率改首快照基线(与列表同口径,治共用QMT账户下cap兜底的假900%)②组合实盘成交落库_sync_trades(轮询broker当日成交→live_trades,此前完全没人写成交表)③updated_at北京时间显示+策略参数JSON改表格 [vps]
This commit is contained in:
@@ -216,3 +216,16 @@ def test_snapshot_once_skips_unsynced_cash():
|
||||
rows = list_balance(db, 3)
|
||||
assert len(rows) == 1
|
||||
assert rows[0]["total"] == 10_000_008.51
|
||||
|
||||
|
||||
def test_get_live_return_uses_first_snapshot_baseline(live_db):
|
||||
"""监控页收益率与列表页同口径(首快照基线),不再用 initial_capital 兜底。"""
|
||||
from sanguo_live.persistence import save_balance
|
||||
aid = _create_portfolio(live_db)
|
||||
save_balance(live_db, aid, "2026-08-14 20:00:00", 9_000_000, 1_000_000,
|
||||
total=10_000_000)
|
||||
save_balance(live_db, aid, "2026-08-14 21:00:00", 9_100_000, 1_050_000,
|
||||
total=10_150_000)
|
||||
acc = rl.get_live(aid)
|
||||
assert acc["latest_equity"] == 10_150_000
|
||||
assert acc["total_return"] == (10_150_000 - 10_000_000) / 10_000_000
|
||||
|
||||
Reference in New Issue
Block a user