diff --git a/pkg/exchange/binance/binanceapi/futures_get_position_risks_request.go b/pkg/exchange/binance/binanceapi/futures_get_position_risks_request.go index 18fe8da5b..d2c3a3432 100644 --- a/pkg/exchange/binance/binanceapi/futures_get_position_risks_request.go +++ b/pkg/exchange/binance/binanceapi/futures_get_position_risks_request.go @@ -9,13 +9,9 @@ import ( type FuturesPositionRisk struct { EntryPrice fixedpoint.Value `json:"entryPrice"` - MarginType string `json:"marginType"` - IsAutoAddMargin string `json:"isAutoAddMargin"` IsolatedMargin string `json:"isolatedMargin"` - Leverage fixedpoint.Value `json:"leverage"` LiquidationPrice fixedpoint.Value `json:"liquidationPrice"` MarkPrice fixedpoint.Value `json:"markPrice"` - MaxNotionalValue fixedpoint.Value `json:"maxNotionalValue"` PositionAmount fixedpoint.Value `json:"positionAmt"` Notional fixedpoint.Value `json:"notional"` IsolatedWallet string `json:"isolatedWallet"` @@ -23,9 +19,19 @@ type FuturesPositionRisk struct { UnRealizedProfit fixedpoint.Value `json:"unRealizedProfit"` PositionSide string `json:"positionSide"` UpdateTime types.MillisecondTimestamp `json:"updateTime"` + + BreakEvenPrice fixedpoint.Value `json:"breakEvenPrice"` + MarginAsset fixedpoint.Value `json:"marginAsset"` + InitialMargin fixedpoint.Value `json:"initialMargin"` + MaintMargin fixedpoint.Value `json:"maintMargin"` + PositionInitialMargin fixedpoint.Value `json:"positionInitialMargin"` + OpenOrderInitialMargin fixedpoint.Value `json:"openOrderInitialMargin"` + Adl fixedpoint.Value `json:"adl"` + BidNotional fixedpoint.Value `json:"bidNotional"` + AskNotional fixedpoint.Value `json:"askNotional"` } -//go:generate requestgen -method GET -url "/fapi/v2/positionRisk" -type FuturesGetPositionRisksRequest -responseType []FuturesPositionRisk +//go:generate requestgen -method GET -url "/fapi/v3/positionRisk" -type FuturesGetPositionRisksRequest -responseType []FuturesPositionRisk type FuturesGetPositionRisksRequest struct { client requestgen.AuthenticatedAPIClient diff --git a/pkg/exchange/binance/binanceapi/futures_get_position_risks_request_requestgen.go b/pkg/exchange/binance/binanceapi/futures_get_position_risks_request_requestgen.go index f17d53dd9..c40d9e048 100644 --- a/pkg/exchange/binance/binanceapi/futures_get_position_risks_request_requestgen.go +++ b/pkg/exchange/binance/binanceapi/futures_get_position_risks_request_requestgen.go @@ -1,4 +1,4 @@ -// Code generated by "requestgen -method GET -url /fapi/v2/positionRisk -type FuturesGetPositionRisksRequest -responseType []FuturesPositionRisk"; DO NOT EDIT. +// Code generated by "requestgen -method GET -url /fapi/v3/positionRisk -type FuturesGetPositionRisksRequest -responseType []FuturesPositionRisk"; DO NOT EDIT. package binanceapi @@ -119,6 +119,12 @@ func (f *FuturesGetPositionRisksRequest) GetSlugsMap() (map[string]string, error return slugs, nil } +// GetPath returns the request path of the API +func (f *FuturesGetPositionRisksRequest) GetPath() string { + return "/fapi/v3/positionRisk" +} + +// Do generates the request object and send the request object to the API endpoint func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPositionRisk, error) { // empty params for GET operation @@ -128,7 +134,9 @@ func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPosit return nil, err } - apiURL := "/fapi/v2/positionRisk" + var apiURL string + + apiURL = f.GetPath() req, err := f.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params) if err != nil { @@ -141,8 +149,32 @@ func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPosit } var apiResponse []FuturesPositionRisk - if err := response.DecodeJSON(&apiResponse); err != nil { - return nil, err + + type responseUnmarshaler interface { + Unmarshal(data []byte) error + } + + if unmarshaler, ok := interface{}(&apiResponse).(responseUnmarshaler); ok { + if err := unmarshaler.Unmarshal(response.Body); err != nil { + return nil, err + } + } else { + // The line below checks the content type, however, some API server might not send the correct content type header, + // Hence, this is commented for backward compatibility + // response.IsJSON() + if err := response.DecodeJSON(&apiResponse); err != nil { + return nil, err + } + } + + type responseValidator interface { + Validate() error + } + + if validator, ok := interface{}(&apiResponse).(responseValidator); ok { + if err := validator.Validate(); err != nil { + return nil, err + } } return apiResponse, nil }