From 97422f26e7df7d308bdf4c79cfa7dfc2995d8f0a Mon Sep 17 00:00:00 2001 From: c9s Date: Tue, 11 Jan 2022 16:38:02 +0800 Subject: [PATCH] binance: should return error when order does not contain orderID or clientOrderID --- pkg/exchange/binance/exchange.go | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/pkg/exchange/binance/exchange.go b/pkg/exchange/binance/exchange.go index cdb4d8b77..89aa9b45a 100644 --- a/pkg/exchange/binance/exchange.go +++ b/pkg/exchange/binance/exchange.go @@ -544,6 +544,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err if o.OrderID > 0 { req.OrderID(int64(o.OrderID)) + } else { + err = multierr.Append(err, fmt.Errorf( + "can not cancel %s order, order does not contain orderID or clientOrderID. %#v", + o.Symbol, o)) + continue } _, err2 := req.Do(ctx) @@ -565,6 +570,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err req.OrderID(int64(o.OrderID)) } else if len(o.ClientOrderID) > 0 { req.OrigClientOrderID(o.ClientOrderID) + } else { + err = multierr.Append(err, fmt.Errorf( + "can not cancel %s order, order does not contain orderID or clientOrderID. %#v", + o.Symbol, o)) + continue } _, err2 := req.Do(ctx) @@ -584,6 +594,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err req.OrderID(int64(o.OrderID)) } else if len(o.ClientOrderID) > 0 { req.OrigClientOrderID(o.ClientOrderID) + } else { + err = multierr.Append(err, fmt.Errorf( + "can not cancel %s order, order does not contain orderID or clientOrderID. %#v", + o.Symbol, o)) + continue } _, err2 := req.Do(ctx)