mirror of
https://github.com/d0zingcat/gocryptotrader.git
synced 2026-06-07 23:16:53 +00:00
Exchanges: Set AccountInfo ID when available (#882)
* Exchanges: Set AccountInfo ID when avaiable * Rename CollectAccountBalances to CollectBalances and add checks
This commit is contained in:
@@ -426,28 +426,28 @@ func (b *Bitmex) UpdateAccountInfo(ctx context.Context, assetType asset.Item) (a
|
||||
return info, err
|
||||
}
|
||||
|
||||
var accountID string
|
||||
var balances []account.Balance
|
||||
accountBalances := make(map[string][]account.Balance)
|
||||
// Need to update to add Margin/Liquidity availability
|
||||
for i := range userMargins {
|
||||
accountID = strconv.FormatInt(userMargins[i].Account, 10)
|
||||
accountID := strconv.FormatInt(userMargins[i].Account, 10)
|
||||
|
||||
wallet, err := b.GetWalletInfo(ctx, userMargins[i].Currency)
|
||||
var wallet WalletInfo
|
||||
wallet, err = b.GetWalletInfo(ctx, userMargins[i].Currency)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
balances = append(balances, account.Balance{
|
||||
CurrencyName: currency.NewCode(wallet.Currency),
|
||||
TotalValue: wallet.Amount,
|
||||
})
|
||||
accountBalances[accountID] = append(
|
||||
accountBalances[accountID], account.Balance{
|
||||
CurrencyName: currency.NewCode(wallet.Currency),
|
||||
TotalValue: wallet.Amount,
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
info.Accounts = append(info.Accounts,
|
||||
account.SubAccount{
|
||||
ID: accountID,
|
||||
Currencies: balances,
|
||||
})
|
||||
if info.Accounts, err = account.CollectBalances(accountBalances, assetType); err != nil {
|
||||
return account.Holdings{}, err
|
||||
}
|
||||
info.Exchange = b.Name
|
||||
|
||||
if err := account.Process(&info); err != nil {
|
||||
|
||||
Reference in New Issue
Block a user