From 75cb5dd09c9ec8bee67716f19c71ca9069b2aa37 Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 22 Feb 2024 14:25:44 +0800 Subject: [PATCH] check order pointer --- pkg/exchange/retry/order.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/pkg/exchange/retry/order.go b/pkg/exchange/retry/order.go index 19df70dda..2575f51aa 100644 --- a/pkg/exchange/retry/order.go +++ b/pkg/exchange/retry/order.go @@ -2,6 +2,7 @@ package retry import ( "context" + "errors" "fmt" "strconv" @@ -10,6 +11,8 @@ import ( "github.com/c9s/bbgo/pkg/types" ) +var ErrOrderIsNil = errors.New("order object is nil") + type advancedOrderCancelService interface { CancelAllOrders(ctx context.Context) ([]types.Order, error) CancelOrdersBySymbol(ctx context.Context, symbol string) ([]types.Order, error) @@ -57,6 +60,10 @@ func QueryOrderUntilFilled( return err2 } + if o == nil { + return ErrOrderIsNil + } + // for final status return nil error to stop the retry switch o.Status { case types.OrderStatusFilled, types.OrderStatusCanceled: