binance: should return error when order does not contain orderID or clientOrderID

This commit is contained in:
c9s 2022-01-11 16:38:02 +08:00
parent 96ffab9cd8
commit 97422f26e7

View File

@ -544,6 +544,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
if o.OrderID > 0 { if o.OrderID > 0 {
req.OrderID(int64(o.OrderID)) 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) _, err2 := req.Do(ctx)
@ -565,6 +570,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
req.OrderID(int64(o.OrderID)) req.OrderID(int64(o.OrderID))
} else if len(o.ClientOrderID) > 0 { } else if len(o.ClientOrderID) > 0 {
req.OrigClientOrderID(o.ClientOrderID) 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) _, err2 := req.Do(ctx)
@ -584,6 +594,11 @@ func (e *Exchange) CancelOrders(ctx context.Context, orders ...types.Order) (err
req.OrderID(int64(o.OrderID)) req.OrderID(int64(o.OrderID))
} else if len(o.ClientOrderID) > 0 { } else if len(o.ClientOrderID) > 0 {
req.OrigClientOrderID(o.ClientOrderID) 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) _, err2 := req.Do(ctx)