Skip to content

Commit

Permalink
okx: query account config to verify spot borrow is on
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 23, 2025
1 parent cf154aa commit d21608d
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions pkg/exchange/okex/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,14 +219,28 @@ func (e *Exchange) QueryAccount(ctx context.Context) (*types.Account, error) {
return nil, fmt.Errorf("account balance is empty")
}

accountConfigs, err := e.client.NewGetAccountConfigRequest().Do(ctx)
if err != nil {
return nil, err
}

if len(accountConfigs) == 0 {
return nil, fmt.Errorf("account config is empty")
}

balances := toGlobalBalance(&accounts[0])
account := types.NewAccount()
account.UpdateBalances(balances)

// for margin account
account.MarginRatio = accounts[0].MarginRatio
account.MarginLevel = accounts[0].MarginRatio
account.TotalAccountValue = accounts[0].TotalEquityInUSD

if e.MarginSettings.IsMargin && !accountConfigs[0].EnableSpotBorrow {
log.Warnf("margin is set, but okx enableSpotBorrow field is false, please turn on auto-borrow from the okx UI")
}

return account, nil
}

Expand Down

0 comments on commit d21608d

Please sign in to comment.