mirror of
https://github.com/c9s/bbgo.git
synced 2024-09-20 16:21:09 +00:00
all: extend balance field for margin
This commit is contained in:
parent
fbe1906e70
commit
cf2e8c9f0a
|
@ -234,9 +234,10 @@ func (e *Exchange) queryCrossMarginAccount(ctx context.Context) (*types.Account,
|
|||
}
|
||||
|
||||
a := &types.Account{
|
||||
AccountType: types.AccountTypeMargin,
|
||||
MarginInfo: toGlobalMarginAccountInfo(marginAccount), // In binance GO api, Account define marginAccount info which mantain []*AccountAsset and []*AccountPosition.
|
||||
MarginLevel: fixedpoint.MustNewFromString(marginAccount.MarginLevel),
|
||||
AccountType: types.AccountTypeMargin,
|
||||
MarginInfo: toGlobalMarginAccountInfo(marginAccount), // In binance GO api, Account define marginAccount info which mantain []*AccountAsset and []*AccountPosition.
|
||||
MarginLevel: fixedpoint.MustNewFromString(marginAccount.MarginLevel),
|
||||
BorrowEnabled: marginAccount.BorrowEnabled,
|
||||
}
|
||||
|
||||
// convert cross margin user assets into balances
|
||||
|
@ -276,6 +277,8 @@ func (e *Exchange) queryIsolatedMarginAccount(ctx context.Context) (*types.Accou
|
|||
|
||||
userAsset := marginAccount.Assets[0]
|
||||
a.MarginLevel = fixedpoint.MustNewFromString(userAsset.MarginLevel)
|
||||
a.BorrowEnabled = userAsset.BaseAsset.BorrowEnabled || userAsset.QuoteAsset.BorrowEnabled
|
||||
// userAsset.LiquidatePrice
|
||||
|
||||
// Convert user assets into balances
|
||||
balances := types.BalanceMap{}
|
||||
|
|
|
@ -27,12 +27,11 @@ type Balance struct {
|
|||
Locked fixedpoint.Value `json:"locked,omitempty"`
|
||||
|
||||
// margin related fields
|
||||
Borrowed fixedpoint.Value `json:"borrowed,omitempty"`
|
||||
Interest fixedpoint.Value `json:"interest,omitempty"`
|
||||
Borrowed fixedpoint.Value `json:"borrowed,omitempty"`
|
||||
Interest fixedpoint.Value `json:"interest,omitempty"`
|
||||
|
||||
// NetAsset = (Available + Locked) - Borrowed - Interest
|
||||
NetAsset fixedpoint.Value `json:"net,omitempty"`
|
||||
|
||||
NetAsset fixedpoint.Value `json:"net,omitempty"`
|
||||
}
|
||||
|
||||
func (b Balance) Total() fixedpoint.Value {
|
||||
|
@ -245,7 +244,8 @@ type Account struct {
|
|||
IsolatedMarginInfo *IsolatedMarginAccountInfo
|
||||
|
||||
// margin related common field
|
||||
MarginLevel fixedpoint.Value `json:"marginLevel"`
|
||||
MarginLevel fixedpoint.Value `json:"marginLevel"`
|
||||
BorrowEnabled bool `json:"borrowEnabled"`
|
||||
|
||||
MakerFeeRate fixedpoint.Value `json:"makerFeeRate,omitempty"`
|
||||
TakerFeeRate fixedpoint.Value `json:"takerFeeRate,omitempty"`
|
||||
|
|
Loading…
Reference in New Issue
Block a user