From 951672fc82b27c327fe3c1e0fe2dc76674389690 Mon Sep 17 00:00:00 2001 From: c9s Date: Sat, 5 Aug 2023 02:00:07 +0800 Subject: [PATCH] improve cancelOrders method --- pkg/bbgo/order_executor_simple.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/pkg/bbgo/order_executor_simple.go b/pkg/bbgo/order_executor_simple.go index a9e36bbbf..e7c5308d0 100644 --- a/pkg/bbgo/order_executor_simple.go +++ b/pkg/bbgo/order_executor_simple.go @@ -45,6 +45,14 @@ func (e *SimpleOrderExecutor) SubmitOrders(ctx context.Context, submitOrders ... // CancelOrders cancels the given order objects directly func (e *SimpleOrderExecutor) CancelOrders(ctx context.Context, orders ...types.Order) error { + if len(orders) == 0 { + orders = e.activeMakerOrders.Orders() + } + + if len(orders) == 0 { + return nil + } + err := e.session.Exchange.CancelOrders(ctx, orders...) if err != nil { // Retry once err2 := e.session.Exchange.CancelOrders(ctx, orders...)