bbgo: use backoff for graceful cancel

This commit is contained in:
c9s 2023-07-20 12:44:57 +08:00
parent f1a105cc06
commit a3c16a4117
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -15,6 +15,7 @@ import (
"github.com/c9s/bbgo/pkg/fixedpoint"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/util"
"github.com/c9s/bbgo/pkg/util/backoff"
)
var ErrExceededSubmitOrderRetryLimit = errors.New("exceeded submit order retry limit")
@ -429,15 +430,10 @@ func (e *GeneralOrderExecutor) GracefulCancelActiveOrderBook(ctx context.Context
return nil
}
if err := activeOrders.GracefulCancel(ctx, e.session.Exchange); err != nil {
// Retry once
if err = activeOrders.GracefulCancel(ctx, e.session.Exchange); err != nil {
return errors.Wrap(err, "graceful cancel error")
}
}
defer e.tradeCollector.Process()
e.tradeCollector.Process()
return nil
op := func() error { return activeOrders.GracefulCancel(ctx, e.session.Exchange) }
return backoff.RetryGeneral(ctx, op)
}
// GracefulCancel cancels all active maker orders if orders are not given, otherwise cancel all the given orders