mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: use backoff for graceful cancel
This commit is contained in:
parent
f1a105cc06
commit
a3c16a4117
|
@ -15,6 +15,7 @@ import (
|
||||||
"github.com/c9s/bbgo/pkg/fixedpoint"
|
"github.com/c9s/bbgo/pkg/fixedpoint"
|
||||||
"github.com/c9s/bbgo/pkg/types"
|
"github.com/c9s/bbgo/pkg/types"
|
||||||
"github.com/c9s/bbgo/pkg/util"
|
"github.com/c9s/bbgo/pkg/util"
|
||||||
|
"github.com/c9s/bbgo/pkg/util/backoff"
|
||||||
)
|
)
|
||||||
|
|
||||||
var ErrExceededSubmitOrderRetryLimit = errors.New("exceeded submit order retry limit")
|
var ErrExceededSubmitOrderRetryLimit = errors.New("exceeded submit order retry limit")
|
||||||
|
@ -429,15 +430,10 @@ func (e *GeneralOrderExecutor) GracefulCancelActiveOrderBook(ctx context.Context
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
if err := activeOrders.GracefulCancel(ctx, e.session.Exchange); err != nil {
|
defer e.tradeCollector.Process()
|
||||||
// Retry once
|
|
||||||
if err = activeOrders.GracefulCancel(ctx, e.session.Exchange); err != nil {
|
|
||||||
return errors.Wrap(err, "graceful cancel error")
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
e.tradeCollector.Process()
|
op := func() error { return activeOrders.GracefulCancel(ctx, e.session.Exchange) }
|
||||||
return nil
|
return backoff.RetryGeneral(ctx, op)
|
||||||
}
|
}
|
||||||
|
|
||||||
// GracefulCancel cancels all active maker orders if orders are not given, otherwise cancel all the given orders
|
// GracefulCancel cancels all active maker orders if orders are not given, otherwise cancel all the given orders
|
||||||
|
|
Loading…
Reference in New Issue
Block a user