exchanges/order, GateIO: Update USDT margined futures pathway for cancel all orders (#2021)

* order/gateio: update USDT margined futures pathway for cancel all orders and drop count field

* gateio: add and expand tests for CancelAllOrders and getExchangeSide

* Add test for load

* linter: fix

* Update exchanges/kraken/kraken_wrapper.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* glorious: nits

* Update exchanges/order/orders.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* gk: nits

* glorious: nits

* reverted change for options

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Scott <gloriousCode@users.noreply.github.com>

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/deribit/deribit_wrapper.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Update exchanges/gateio/gateio_wrapper_test.go

Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>

* Add consts for cancel side references

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/gateio/gateio_wrapper.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* Update exchanges/gateio/gateio_websocket_request_futures.go

Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>

* thrasher-: nits

---------

Co-authored-by: Ryan O'Hara-Reid <ryan.oharareid@thrasher.io>
Co-authored-by: Scott <gloriousCode@users.noreply.github.com>
Co-authored-by: Gareth Kirwan <gbjkirwan@gmail.com>
Co-authored-by: Adrian Gallagher <adrian.gallagher@thrasher.io>
This commit is contained in:
Ryan O'Hara-Reid
2025-10-02 15:50:51 +10:00
committed by GitHub
parent e11765bc36
commit dcf98ec700
13 changed files with 204 additions and 156 deletions

View File

@@ -815,50 +815,48 @@ func (e *Exchange) CancelBatchOrders(ctx context.Context, o []order.Cancel) (*or
// CancelAllOrders cancels all orders associated with a currency pair
func (e *Exchange) CancelAllOrders(ctx context.Context, req *order.Cancel) (order.CancelAllResponse, error) {
var resp order.CancelAllResponse
if err := req.Validate(); err != nil {
return order.CancelAllResponse{}, err
}
cancelAllOrdersResponse := order.CancelAllResponse{
Status: make(map[string]string),
return resp, err
}
switch req.AssetType {
case asset.Spot:
if e.Websocket.CanUseAuthenticatedWebsocketForWrapper() {
resp, err := e.wsCancelAllOrders(ctx)
cancel, err := e.wsCancelAllOrders(ctx)
if err != nil {
return cancelAllOrdersResponse, err
return resp, err
}
cancelAllOrdersResponse.Count = resp.Count
return cancelAllOrdersResponse, err
for i := range cancel.Count {
resp.Add(fmt.Sprintf("Unknown:%d", i+1), "cancelled")
}
return resp, err
}
var emptyOrderOptions OrderInfoOptions
openOrders, err := e.GetOpenOrders(ctx, emptyOrderOptions)
openOrders, err := e.GetOpenOrders(ctx, OrderInfoOptions{})
if err != nil {
return cancelAllOrdersResponse, err
return resp, err
}
for orderID := range openOrders.Open {
var err error
if e.Websocket.CanUseAuthenticatedWebsocketForWrapper() {
err = e.wsCancelOrders(ctx, []string{orderID})
} else {
_, err = e.CancelExistingOrder(ctx, orderID)
}
if err != nil {
cancelAllOrdersResponse.Status[orderID] = err.Error()
resp.Add(orderID, err.Error())
continue
}
resp.Add(orderID, "cancelled")
}
case asset.Futures:
cancelData, err := e.FuturesCancelAllOrders(ctx, req.Pair)
if err != nil {
return cancelAllOrdersResponse, err
return resp, err
}
for x := range cancelData.CancelStatus.CancelledOrders {
cancelAllOrdersResponse.Status[cancelData.CancelStatus.CancelledOrders[x].OrderID] = "cancelled"
resp.Add(cancelData.CancelStatus.CancelledOrders[x].OrderID, "cancelled")
}
}
return cancelAllOrdersResponse, nil
return resp, nil
}
// GetOrderInfo returns information on a current open order