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

@@ -693,17 +693,18 @@ func (e *Exchange) CancelBatchOrders(_ context.Context, _ []order.Cancel) (*orde
}
// CancelAllOrders cancels all orders associated with a currency pair
func (e *Exchange) CancelAllOrders(ctx context.Context, orderCancellation *order.Cancel) (order.CancelAllResponse, error) {
if err := orderCancellation.Validate(); err != nil {
return order.CancelAllResponse{}, err
func (e *Exchange) CancelAllOrders(ctx context.Context, cancel *order.Cancel) (order.CancelAllResponse, error) {
var resp order.CancelAllResponse
if err := cancel.Validate(); err != nil {
return resp, err
}
var cancelData *MultipleCancelResponse
pairFmt, err := e.GetPairFormat(orderCancellation.AssetType, true)
fPair, err := e.FormatExchangeCurrency(cancel.Pair, cancel.AssetType)
if err != nil {
return order.CancelAllResponse{}, err
return resp, err
}
var orderTypeStr string
switch orderCancellation.Type {
switch cancel.Type {
case order.Limit:
orderTypeStr = order.Limit.String()
case order.Market:
@@ -711,26 +712,24 @@ func (e *Exchange) CancelAllOrders(ctx context.Context, orderCancellation *order
case order.AnyType, order.UnknownType:
orderTypeStr = "all"
default:
return order.CancelAllResponse{}, fmt.Errorf("%s: orderType %v is not valid", e.Name, orderCancellation.Type)
return resp, fmt.Errorf("%s %w: %v", e.Name, order.ErrTypeIsInvalid, cancel.Type)
}
var cancelData *MultipleCancelResponse
if e.Websocket.IsConnected() && e.Websocket.CanUseAuthenticatedWebsocketForWrapper() {
cancelData, err = e.WSSubmitCancelAllByInstrument(ctx, pairFmt.Format(orderCancellation.Pair), orderTypeStr, true, true)
cancelData, err = e.WSSubmitCancelAllByInstrument(ctx, fPair.String(), orderTypeStr, true, true)
} else {
cancelData, err = e.SubmitCancelAllByInstrument(ctx, pairFmt.Format(orderCancellation.Pair), orderTypeStr, true, true)
cancelData, err = e.SubmitCancelAllByInstrument(ctx, fPair.String(), orderTypeStr, true, true)
}
if err != nil {
return order.CancelAllResponse{}, err
return resp, err
}
response := order.CancelAllResponse{Count: cancelData.CancelCount}
if len(cancelData.CancelDetails) > 0 {
response.Status = make(map[string]string)
for a := range cancelData.CancelDetails {
for b := range cancelData.CancelDetails[a].Result {
response.Status[cancelData.CancelDetails[a].Result[b].OrderID] = cancelData.CancelDetails[a].Result[b].OrderState
}
for a := range cancelData.CancelDetails {
for b := range cancelData.CancelDetails[a].Result {
resp.Add(cancelData.CancelDetails[a].Result[b].OrderID, cancelData.CancelDetails[a].Result[b].OrderState)
}
}
return response, nil
return resp, nil
}
// GetOrderInfo returns order information based on order ID