binance: fix margin balance convert

This commit is contained in:
c9s 2022-04-13 15:38:13 +08:00
parent a93a91546d
commit 897dc55dcf

View File

@ -238,6 +238,15 @@ func (e *Exchange) QueryMarginAccount(ctx context.Context) (*types.Account, erro
MarginInfo: toGlobalMarginAccountInfo(account), // In binance GO api, Account define account info which mantain []*AccountAsset and []*AccountPosition.
}
balances := types.BalanceMap{}
for _, userAsset := range account.UserAssets {
balances[userAsset.Asset] = types.Balance{
Currency: userAsset.Asset,
Available: fixedpoint.MustNewFromString(userAsset.Free),
Locked: fixedpoint.MustNewFromString(userAsset.Locked),
}
}
a.UpdateBalances(balances)
return a, nil
}
@ -257,6 +266,23 @@ func (e *Exchange) QueryIsolatedMarginAccount(ctx context.Context, symbols ...st
IsolatedMarginInfo: toGlobalIsolatedMarginAccountInfo(account), // In binance GO api, Account define account info which mantain []*AccountAsset and []*AccountPosition.
}
balances := types.BalanceMap{}
for _, userAsset := range account.Assets {
balances[userAsset.BaseAsset.Asset] = types.Balance{
Currency: userAsset.BaseAsset.Asset,
Available: fixedpoint.MustNewFromString(userAsset.BaseAsset.Free),
Locked: fixedpoint.MustNewFromString(userAsset.BaseAsset.Locked),
}
balances[userAsset.QuoteAsset.Asset] = types.Balance{
Currency: userAsset.QuoteAsset.Asset,
Available: fixedpoint.MustNewFromString(userAsset.QuoteAsset.Free),
Locked: fixedpoint.MustNewFromString(userAsset.QuoteAsset.Locked),
}
}
a.UpdateBalances(balances)
return a, nil
}