check order pointer

This commit is contained in:
c9s 2024-02-22 14:25:44 +08:00
parent 3cee573dbd
commit 75cb5dd09c
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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: