mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-14 11:03:53 +00:00
update binance positionRisk api to v3
This commit is contained in:
parent
58133d94ba
commit
5b3f8b52e0
|
@ -9,13 +9,9 @@ import (
|
||||||
|
|
||||||
type FuturesPositionRisk struct {
|
type FuturesPositionRisk struct {
|
||||||
EntryPrice fixedpoint.Value `json:"entryPrice"`
|
EntryPrice fixedpoint.Value `json:"entryPrice"`
|
||||||
MarginType string `json:"marginType"`
|
|
||||||
IsAutoAddMargin string `json:"isAutoAddMargin"`
|
|
||||||
IsolatedMargin string `json:"isolatedMargin"`
|
IsolatedMargin string `json:"isolatedMargin"`
|
||||||
Leverage fixedpoint.Value `json:"leverage"`
|
|
||||||
LiquidationPrice fixedpoint.Value `json:"liquidationPrice"`
|
LiquidationPrice fixedpoint.Value `json:"liquidationPrice"`
|
||||||
MarkPrice fixedpoint.Value `json:"markPrice"`
|
MarkPrice fixedpoint.Value `json:"markPrice"`
|
||||||
MaxNotionalValue fixedpoint.Value `json:"maxNotionalValue"`
|
|
||||||
PositionAmount fixedpoint.Value `json:"positionAmt"`
|
PositionAmount fixedpoint.Value `json:"positionAmt"`
|
||||||
Notional fixedpoint.Value `json:"notional"`
|
Notional fixedpoint.Value `json:"notional"`
|
||||||
IsolatedWallet string `json:"isolatedWallet"`
|
IsolatedWallet string `json:"isolatedWallet"`
|
||||||
|
@ -23,9 +19,19 @@ type FuturesPositionRisk struct {
|
||||||
UnRealizedProfit fixedpoint.Value `json:"unRealizedProfit"`
|
UnRealizedProfit fixedpoint.Value `json:"unRealizedProfit"`
|
||||||
PositionSide string `json:"positionSide"`
|
PositionSide string `json:"positionSide"`
|
||||||
UpdateTime types.MillisecondTimestamp `json:"updateTime"`
|
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 {
|
type FuturesGetPositionRisksRequest struct {
|
||||||
client requestgen.AuthenticatedAPIClient
|
client requestgen.AuthenticatedAPIClient
|
||||||
|
|
||||||
|
|
|
@ -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
|
package binanceapi
|
||||||
|
|
||||||
|
@ -119,6 +119,12 @@ func (f *FuturesGetPositionRisksRequest) GetSlugsMap() (map[string]string, error
|
||||||
return slugs, nil
|
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) {
|
func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPositionRisk, error) {
|
||||||
|
|
||||||
// empty params for GET operation
|
// empty params for GET operation
|
||||||
|
@ -128,7 +134,9 @@ func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPosit
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
apiURL := "/fapi/v2/positionRisk"
|
var apiURL string
|
||||||
|
|
||||||
|
apiURL = f.GetPath()
|
||||||
|
|
||||||
req, err := f.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
req, err := f.client.NewAuthenticatedRequest(ctx, "GET", apiURL, query, params)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
@ -141,8 +149,32 @@ func (f *FuturesGetPositionRisksRequest) Do(ctx context.Context) ([]FuturesPosit
|
||||||
}
|
}
|
||||||
|
|
||||||
var apiResponse []FuturesPositionRisk
|
var apiResponse []FuturesPositionRisk
|
||||||
|
|
||||||
|
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 {
|
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||||
return nil, err
|
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
|
return apiResponse, nil
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user