Merge pull request #1539 from c9s/c9s/fix-and-improve-query-order-until-filled

FIX: add check for order pointer
This commit is contained in:
c9s 2024-02-22 14:37:48 +08:00 committed by GitHub
commit 945c442b92
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -2,6 +2,7 @@ package retry
import ( import (
"context" "context"
"errors"
"fmt" "fmt"
"strconv" "strconv"
@ -10,6 +11,8 @@ import (
"github.com/c9s/bbgo/pkg/types" "github.com/c9s/bbgo/pkg/types"
) )
var ErrOrderIsNil = errors.New("order object is nil")
type advancedOrderCancelService interface { type advancedOrderCancelService interface {
CancelAllOrders(ctx context.Context) ([]types.Order, error) CancelAllOrders(ctx context.Context) ([]types.Order, error)
CancelOrdersBySymbol(ctx context.Context, symbol string) ([]types.Order, error) CancelOrdersBySymbol(ctx context.Context, symbol string) ([]types.Order, error)
@ -57,6 +60,10 @@ func QueryOrderUntilFilled(
return err2 return err2
} }
if o == nil {
return ErrOrderIsNil
}
// for final status return nil error to stop the retry // for final status return nil error to stop the retry
switch o.Status { switch o.Status {
case types.OrderStatusFilled, types.OrderStatusCanceled: case types.OrderStatusFilled, types.OrderStatusCanceled: