improve cancelOrders method

This commit is contained in:
c9s 2023-08-05 02:00:07 +08:00
parent eaaab914e0
commit 951672fc82
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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...)