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:
jackyu66git
2026-05-04 17:48:14 +08:00
parent 156ce22474
commit 49da6fd35b
7 changed files with 143 additions and 171 deletions
+25
View File
@@ -248,9 +248,34 @@ func NewTrader(cfg *Config, database *db.DB) *Trader {
}
}
// Fetch real balances from exchanges
t.fetchBalances()
return t
}
func (t *Trader) fetchBalances() {
// Bitget
if t.bitget != nil {
if bal, err := t.bitget.GetBalance(); err == nil {
t.exchangeFunds[ExBitget] = &ExchangeFund{Balance: bal}
log.Printf("[Funds] Bitget balance: $%.2f", bal)
} else {
log.Printf("[Funds] Bitget balance fetch failed: %v (using default)", err)
}
}
// HyperLiquid
if t.hyperliquid != nil && t.hyperliquid.IsConfigured() {
if bal, err := t.hyperliquid.GetBalance(); err == nil {
t.exchangeFunds[ExHyperLiquid] = &ExchangeFund{Balance: bal}
log.Printf("[Funds] HyperLiquid balance: $%.2f", bal)
} else {
log.Printf("[Funds] HyperLiquid balance fetch failed: %v (using default)", err)
}
}
}
func (t *Trader) IsConfigured() bool {
switch {
case t.cfg.TestMode: