fix: db migration tab char corrupted, restore historical trades

This commit is contained in:
jackyu66git
2026-05-04 13:50:49 +08:00
parent e74fd084ce
commit f29e78a435
5 changed files with 264 additions and 58 deletions
+17
View File
@@ -373,6 +373,11 @@ func (d *Dashboard) broadcastLoop() {
"duration": time.Since(pos.StartedAt).Round(time.Second).String(),
"started_at": pos.StartedAt.Format("15:04:05"),
"started_ts": pos.StartedAt.UnixMilli(),
"long_exchange": pos.LongLeg.Exchange,
"short_exchange": pos.ShortLeg.Exchange,
"long_entry": pos.LongLeg.EntryPrice,
"short_entry": pos.ShortLeg.EntryPrice,
"db_trade_id": pos.DBTradeID,
}
// Calculate live PnL from current prices — use weighted average for scale-ins
@@ -474,6 +479,18 @@ func (d *Dashboard) broadcastLoop() {
d.connMu.RUnlock()
stats["connections"] = connInfo
// Per-exchange fund tracking
exFunds := d.trader.GetExchangeFunds()
exFundsMap := make(map[string]map[string]float64, len(exFunds))
for ex, ef := range exFunds {
exFundsMap[ex] = map[string]float64{
"balance": math.Round(ef.Balance*100) / 100,
"total_fee": math.Round(ef.TotalFee*100) / 100,
"total_pnl": math.Round(ef.TotalPnl*100) / 100,
}
}
stats["exchange_funds"] = exFundsMap
// Blacklist — stale spread coins
bl := d.trader.GetBlacklist()
blList := make([]map[string]interface{}, 0, len(bl))