mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 23:05:15 +00:00
max: fix max v3 order cancel api
This commit is contained in:
parent
06eff47058
commit
6137905f42
|
@ -293,11 +293,18 @@ func (e *Exchange) CancelAllOrders(ctx context.Context) ([]types.Order, error) {
|
|||
}
|
||||
|
||||
req := e.v3order.NewCancelWalletOrderAllRequest(walletType)
|
||||
var maxOrders, err = req.Do(ctx)
|
||||
var orderResponses, err = req.Do(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var maxOrders []maxapi.Order
|
||||
for _, resp := range orderResponses {
|
||||
if resp.Error == nil {
|
||||
maxOrders = append(maxOrders, resp.Order)
|
||||
}
|
||||
}
|
||||
|
||||
return toGlobalOrders(maxOrders)
|
||||
}
|
||||
|
||||
|
@ -311,11 +318,18 @@ func (e *Exchange) CancelOrdersBySymbol(ctx context.Context, symbol string) ([]t
|
|||
req := e.v3order.NewCancelWalletOrderAllRequest(walletType)
|
||||
req.Market(market)
|
||||
|
||||
maxOrders, err := req.Do(ctx)
|
||||
var orderResponses, err = req.Do(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var maxOrders []maxapi.Order
|
||||
for _, resp := range orderResponses {
|
||||
if resp.Error == nil {
|
||||
maxOrders = append(maxOrders, resp.Order)
|
||||
}
|
||||
}
|
||||
|
||||
return toGlobalOrders(maxOrders)
|
||||
}
|
||||
|
||||
|
@ -328,11 +342,18 @@ func (e *Exchange) CancelOrdersByGroupID(ctx context.Context, groupID uint32) ([
|
|||
req := e.v3order.NewCancelWalletOrderAllRequest(walletType)
|
||||
req.GroupID(groupID)
|
||||
|
||||
maxOrders, err := req.Do(ctx)
|
||||
var orderResponses, err = req.Do(ctx)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
var maxOrders []maxapi.Order
|
||||
for _, resp := range orderResponses {
|
||||
if resp.Error == nil {
|
||||
maxOrders = append(maxOrders, resp.Order)
|
||||
}
|
||||
}
|
||||
|
||||
return toGlobalOrders(maxOrders)
|
||||
}
|
||||
|
||||
|
|
|
@ -6,11 +6,16 @@ import "github.com/c9s/requestgen"
|
|||
//go:generate -command PostRequest requestgen -method POST
|
||||
//go:generate -command DeleteRequest requestgen -method DELETE
|
||||
|
||||
type OrderCancelResponse struct {
|
||||
Order Order
|
||||
Error *string
|
||||
}
|
||||
|
||||
func (s *OrderService) NewCancelWalletOrderAllRequest(walletType WalletType) *CancelWalletOrderAllRequest {
|
||||
return &CancelWalletOrderAllRequest{client: s.Client, walletType: walletType}
|
||||
}
|
||||
|
||||
//go:generate DeleteRequest -url "/api/v3/wallet/:walletType/orders" -type CancelWalletOrderAllRequest -responseType []Order
|
||||
//go:generate DeleteRequest -url "/api/v3/wallet/:walletType/orders" -type CancelWalletOrderAllRequest -responseType []OrderCancelResponse
|
||||
type CancelWalletOrderAllRequest struct {
|
||||
client requestgen.AuthenticatedAPIClient
|
||||
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
// Code generated by "requestgen -method DELETE -url /api/v3/wallet/:walletType/orders -type CancelWalletOrderAllRequest -responseType []Order"; DO NOT EDIT.
|
||||
// Code generated by "requestgen -method DELETE -url /api/v3/wallet/:walletType/orders -type CancelWalletOrderAllRequest -responseType []OrderCancelResponse"; DO NOT EDIT.
|
||||
|
||||
package v3
|
||||
|
||||
|
@ -6,10 +6,11 @@ import (
|
|||
"context"
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
||||
"net/url"
|
||||
"reflect"
|
||||
"regexp"
|
||||
|
||||
max "github.com/c9s/bbgo/pkg/exchange/max/maxapi"
|
||||
)
|
||||
|
||||
func (c *CancelWalletOrderAllRequest) Side(side string) *CancelWalletOrderAllRequest {
|
||||
|
@ -165,7 +166,7 @@ func (c *CancelWalletOrderAllRequest) GetSlugsMap() (map[string]string, error) {
|
|||
return slugs, nil
|
||||
}
|
||||
|
||||
func (c *CancelWalletOrderAllRequest) Do(ctx context.Context) ([]max.Order, error) {
|
||||
func (c *CancelWalletOrderAllRequest) Do(ctx context.Context) ([]OrderCancelResponse, error) {
|
||||
|
||||
params, err := c.GetParameters()
|
||||
if err != nil {
|
||||
|
@ -191,7 +192,7 @@ func (c *CancelWalletOrderAllRequest) Do(ctx context.Context) ([]max.Order, erro
|
|||
return nil, err
|
||||
}
|
||||
|
||||
var apiResponse []max.Order
|
||||
var apiResponse []OrderCancelResponse
|
||||
if err := response.DecodeJSON(&apiResponse); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user