fix(live): 监控页三修——①收益率改首快照基线(与列表同口径,治共用QMT账户下cap兜底的假900%)②组合实盘成交落库_sync_trades(轮询broker当日成交→live_trades,此前完全没人写成交表)③updated_at北京时间显示+策略参数JSON改表格 [vps]
CI/CD / test (push) Successful in 15s
CI/CD / nas-deploy (push) Successful in 42s
CI/CD / nas-verify (push) Successful in 14s

This commit is contained in:
2026-08-14 22:07:30 +08:00
parent f73810a6da
commit f49154266d
4 changed files with 97 additions and 24 deletions
+12 -1
View File
@@ -135,11 +135,22 @@ def list_lives():
@router.get("/live/{aid}", dependencies=[Depends(verify_token)])
def get_live(aid: int):
from sanguo_live.persistence import get_account
from sanguo_live.persistence import get_account, get_first_balance, get_last_balance
acc = get_account(_db_path["path"], aid)
if not acc:
raise HTTPException(404, "account not found")
# 收益率与列表页同口径:首快照为基线。监控页此前用 initial_capital 兜底,
# 共用 QMT 账户时 total=1000万 vs cap=100万 → 假 900%(2026-08-14 实况)。
last = get_last_balance(_db_path["path"], aid)
first = get_first_balance(_db_path["path"], aid)
baseline = (first or {}).get("total") if first else None
acc["latest_equity"] = (last or {}).get("total") if last else None
acc["latest_date"] = (last or {}).get("date") if last else None
if last and baseline:
acc["total_return"] = (last.get("total", 0) - baseline) / baseline
else:
acc["total_return"] = None
return acc