feat: paper summary add balance + pnl_usdt
This commit is contained in:
parent
7b901a2390
commit
d0e626a437
@ -545,6 +545,8 @@ async def paper_summary(user: dict = Depends(get_current_user)):
|
|||||||
total = len(closed)
|
total = len(closed)
|
||||||
wins = len([r for r in closed if r["pnl_r"] > 0])
|
wins = len([r for r in closed if r["pnl_r"] > 0])
|
||||||
total_pnl = sum(r["pnl_r"] for r in closed)
|
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
|
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_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))
|
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,
|
"total_trades": total,
|
||||||
"win_rate": round(win_rate, 1),
|
"win_rate": round(win_rate, 1),
|
||||||
"total_pnl": round(total_pnl, 2),
|
"total_pnl": round(total_pnl, 2),
|
||||||
|
"total_pnl_usdt": round(total_pnl_usdt, 2),
|
||||||
|
"balance": round(balance, 2),
|
||||||
"active_positions": len(active),
|
"active_positions": len(active),
|
||||||
"profit_factor": round(profit_factor, 2),
|
"profit_factor": round(profit_factor, 2),
|
||||||
"start_time": str(first["start"]) if first and first["start"] else None,
|
"start_time": str(first["start"]) if first and first["start"] else None,
|
||||||
|
|||||||
@ -74,10 +74,15 @@ function SummaryCards() {
|
|||||||
}, []);
|
}, []);
|
||||||
if (!data) return <div className="text-center text-slate-400 text-sm py-4">加载中...</div>;
|
if (!data) return <div className="text-center text-slate-400 text-sm py-4">加载中...</div>;
|
||||||
return (
|
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">
|
<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="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>
|
||||||
<div className="bg-white rounded-lg border border-slate-200 px-2.5 py-2">
|
<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="text-[10px] text-slate-400">胜率</p>
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user