diff --git a/exchanges/binance/cfutures_types.go b/exchanges/binance/cfutures_types.go index ad2a9e0b63e..36305835305 100644 --- a/exchanges/binance/cfutures_types.go +++ b/exchanges/binance/cfutures_types.go @@ -359,6 +359,25 @@ type FuturesAccountBalanceData struct { UpdateTime int64 `json:"updateTime"` } +// FuturesAccountInformationPositions holds account position data +type FuturesAccountInformationPositions struct { + Symbol string `json:"symbol"` + Amount float64 `json:"positionAmt,string"` + InitialMargin float64 `json:"initialMargin,string"` + MaintMargin float64 `json:"maintMargin,string"` + UnrealizedProfit float64 `json:"unrealizedProfit,string"` + PositionInitialMargin float64 `json:"positionInitialMargin,string"` + OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"` + Leverage float64 `json:"leverage,string"` + Isolated bool `json:"isolated"` + PositionSide string `json:"positionSide"` + EntryPrice float64 `json:"entryPrice,string"` + MaxQty float64 `json:"maxQty,string"` + UpdateTime time.Time `json:"updateTime"` + NotionalValue float64 `json:"notionalValue,string"` + IsolatedWallet float64 `json:"isolatedWallet,string"` +} + // FuturesAccountInformation stores account information for futures account type FuturesAccountInformation struct { Assets []struct { @@ -370,30 +389,17 @@ type FuturesAccountInformation struct { InitialMargin float64 `json:"initialMargin,string"` PositionInitialMargin float64 `json:"positionInitialMargin,string"` OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"` - Leverage float64 `json:"leverage,string"` - Isolated bool `json:"isolated"` - PositionSide string `json:"positionSide"` - EntryPrice float64 `json:"entryPrice,string"` - MaxQty float64 `json:"maxQty,string"` + MaxWithdrawAmount float64 `json:"maxWithdrawAmount,string"` + CrossWalletBalance float64 `json:"crossWalletBalance,string"` + CrossUnPNL float64 `json:"crossUnPnl,string"` + AvailableBalance float64 `json:"availableBalance,string"` } `json:"assets"` - Positions []struct { - Symbol string `json:"symbol"` - InitialMargin float64 `json:"initialMargin,string"` - MaintMargin float64 `json:"maintMargin,string"` - UnrealizedProfit float64 `json:"unrealizedProfit,string"` - PositionInitialMargin float64 `json:"positionInitialMargin,string"` - OpenOrderInitialMargin float64 `json:"openOrderInitialMargin,string"` - Leverage float64 `json:"leverage,string"` - Isolated bool `json:"isolated"` - PositionSide string `json:"positionSide"` - EntryPrice float64 `json:"entryPrice,string"` - MaxQty float64 `json:"maxQty,string"` - } `json:"positions"` - CanDeposit bool `json:"canDeposit"` - CanTrade bool `json:"canTrade"` - CanWithdraw bool `json:"canWithdraw"` - FeeTier int64 `json:"feeTier"` - UpdateTime int64 `json:"updateTime"` + Positions []FuturesAccountInformationPositions `json:"positions"` + CanDeposit bool `json:"canDeposit"` + CanTrade bool `json:"canTrade"` + CanWithdraw bool `json:"canWithdraw"` + FeeTier int64 `json:"feeTier"` + UpdateTime time.Time `json:"updateTime"` } // GenericAuthResponse is a general data response for a post auth request diff --git a/exchanges/binance/type_convert.go b/exchanges/binance/type_convert.go index 2a8565db526..3d2b04c199e 100644 --- a/exchanges/binance/type_convert.go +++ b/exchanges/binance/type_convert.go @@ -441,3 +441,43 @@ func (u *UFuturesSymbolInfo) UnmarshalJSON(data []byte) error { u.OnboardDate = aux.OnboardDate.Time() return nil } + +// UnmarshalJSON deserialises the JSON info, including the timestamp +func (a *FuturesAccountInformationPositions) UnmarshalJSON(data []byte) error { + type Alias FuturesAccountInformationPositions + + aux := &struct { + UpdateTime binanceTime `json:"updateTime"` + *Alias + }{ + Alias: (*Alias)(a), + } + + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + a.UpdateTime = aux.UpdateTime.Time() + + return nil +} + +// UnmarshalJSON deserialises the JSON info, including the timestamp +func (a *FuturesAccountInformation) UnmarshalJSON(data []byte) error { + type Alias FuturesAccountInformation + + aux := &struct { + UpdateTime binanceTime `json:"updateTime"` + *Alias + }{ + Alias: (*Alias)(a), + } + + if err := json.Unmarshal(data, &aux); err != nil { + return err + } + + a.UpdateTime = aux.UpdateTime.Time() + + return nil +}