mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
binance: fix margin balance convert
This commit is contained in:
parent
a93a91546d
commit
897dc55dcf
|
@ -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
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user