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:
@@ -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:
|
||||
|
||||
Reference in New Issue
Block a user