Add detailed PnL and duration stats to dashboard

This commit is contained in:
jackyu66git
2026-05-03 21:03:40 +08:00
parent a89a1f6cd8
commit 1e4a3f3b37
6 changed files with 177 additions and 10 deletions
+14
View File
@@ -360,6 +360,7 @@ func (d *Dashboard) broadcastLoop() {
// 4. Stats + connection status (P3-5)
converged, diverged, flat, total := d.trader.GetClosedStats()
detail := d.trader.GetDetailedStats()
stats := map[string]interface{}{
"total_trades": total,
"converged": converged,
@@ -367,6 +368,19 @@ func (d *Dashboard) broadcastLoop() {
"flat": flat,
"open_positions": len(positions),
"coins": len(prices),
// Detailed PnL & duration stats (session only)
"detail": map[string]interface{}{
"total_pnl": detail.TotalPnlPct,
"avg_pnl": detail.AvgPnlPct,
"max_profit": detail.MaxProfitPct,
"max_loss": detail.MaxLossPct,
"avg_dur": detail.AvgDuration,
"win_rate": detail.WinRate,
"wins": detail.WinningTrades,
"losses": detail.LosingTrades,
"total_dur": detail.TotalDuration,
},
}
// Connection status