feat: 监控区 2x2 布局与左上今日统计卡

Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
dekun
2026-07-04 23:10:32 +08:00
parent eb975b0133
commit 9deb58a38a
9 changed files with 362 additions and 24 deletions
+6
View File
@@ -616,6 +616,8 @@ def fetch_trades_for_archive(
def summarize_trades(trades: list[dict]) -> dict[str, Any]:
"""单笔列表 → 笔数 / 盈亏 / 胜败统计。"""
total_pnl = 0.0
win_pnl = 0.0
loss_pnl = 0.0
win = loss = flat = 0
for t in trades or []:
try:
@@ -625,8 +627,10 @@ def summarize_trades(trades: list[dict]) -> dict[str, Any]:
total_pnl += pnl
if pnl > 1e-9:
win += 1
win_pnl += pnl
elif pnl < -1e-9:
loss += 1
loss_pnl += pnl
else:
flat += 1
return {
@@ -635,4 +639,6 @@ def summarize_trades(trades: list[dict]) -> dict[str, Any]:
"loss_count": loss,
"flat_count": flat,
"total_pnl_u": round(total_pnl, 4),
"win_pnl_u": round(win_pnl, 4),
"loss_pnl_u": round(loss_pnl, 4),
}