feat: paper summary add balance + pnl_usdt

This commit is contained in:
root 2026-02-28 12:00:19 +00:00
parent 7b901a2390
commit d0e626a437
2 changed files with 11 additions and 2 deletions

View File

@ -545,6 +545,8 @@ async def paper_summary(user: dict = Depends(get_current_user)):
total = len(closed)
wins = len([r for r in closed if r["pnl_r"] > 0])
total_pnl = sum(r["pnl_r"] for r in closed)
total_pnl_usdt = total_pnl * 200 # 1R = $200
balance = 10000 + total_pnl_usdt
win_rate = (wins / total * 100) if total > 0 else 0
gross_profit = sum(r["pnl_r"] for r in closed if r["pnl_r"] > 0)
gross_loss = abs(sum(r["pnl_r"] for r in closed if r["pnl_r"] <= 0))
@ -554,6 +556,8 @@ async def paper_summary(user: dict = Depends(get_current_user)):
"total_trades": total,
"win_rate": round(win_rate, 1),
"total_pnl": round(total_pnl, 2),
"total_pnl_usdt": round(total_pnl_usdt, 2),
"balance": round(balance, 2),
"active_positions": len(active),
"profit_factor": round(profit_factor, 2),
"start_time": str(first["start"]) if first and first["start"] else None,

View File

@ -74,10 +74,15 @@ function SummaryCards() {
}, []);
if (!data) return <div className="text-center text-slate-400 text-sm py-4">...</div>;
return (
<div className="grid grid-cols-3 lg:grid-cols-6 gap-1.5">
<div className="grid grid-cols-3 lg:grid-cols-7 gap-1.5">
<div className="bg-white rounded-lg border border-slate-200 px-2.5 py-2">
<p className="text-[10px] text-slate-400"></p>
<p className={`font-mono font-bold text-lg ${data.balance >= 10000 ? "text-emerald-600" : "text-red-500"}`}>${data.balance?.toLocaleString()}</p>
</div>
<div className="bg-white rounded-lg border border-slate-200 px-2.5 py-2">
<p className="text-[10px] text-slate-400">(R)</p>
<p className={`font-mono font-bold text-lg ${data.total_pnl >= 0 ? "text-emerald-600" : "text-red-500"}`}>{data.total_pnl >= 0 ? "+" : ""}{data.total_pnl}</p>
<p className={`font-mono font-bold text-lg ${data.total_pnl >= 0 ? "text-emerald-600" : "text-red-500"}`}>{data.total_pnl >= 0 ? "+" : ""}{data.total_pnl}R</p>
<p className={`font-mono text-[10px] ${data.total_pnl_usdt >= 0 ? "text-emerald-500" : "text-red-400"}`}>{data.total_pnl_usdt >= 0 ? "+" : ""}${data.total_pnl_usdt}</p>
</div>
<div className="bg-white rounded-lg border border-slate-200 px-2.5 py-2">
<p className="text-[10px] text-slate-400"></p>