fix: HL balance now reads spot USDC via SpotUserState
HL testnet USDC lives in the spot account, not the perp clearinghouse. GetBalance() was calling UserState() (perp clearinghouseState), which returned /usr/bin/bash. Switched to SpotUserState() and parse USDC.total - USDC.hold. Also cleaned up .gitignore to exclude .env, binary, logs, data/.
This commit is contained in:
+15
-3
@@ -579,10 +579,22 @@ func (d *Dashboard) handleStatus(w http.ResponseWriter, r *http.Request) {
|
||||
positions := d.trader.ReadSnapshot()
|
||||
converged, diverged, flat, total := d.trader.GetClosedStats()
|
||||
|
||||
// Format exchange funds (snake_case, like SSE)
|
||||
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,
|
||||
}
|
||||
}
|
||||
|
||||
resp := map[string]interface{}{
|
||||
"prices": snap,
|
||||
"positions": len(positions),
|
||||
"stats": map[string]int{"total": total, "converged": converged, "diverged": diverged, "flat": flat},
|
||||
"prices": snap,
|
||||
"positions": len(positions),
|
||||
"stats": map[string]int{"total": total, "converged": converged, "diverged": diverged, "flat": flat},
|
||||
"exchange_funds": exFundsMap,
|
||||
}
|
||||
writeJSON(w, resp)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user