xgap: call tradingutil.UniversalCancelAllOrders

This commit is contained in:
c9s 2024-11-15 23:48:23 +08:00
parent 050d1ca794
commit abd41c98de
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/strategy/common"
"github.com/c9s/bbgo/pkg/types"
"github.com/c9s/bbgo/pkg/util/timejitter"
"github.com/c9s/bbgo/pkg/util/tradingutil"
)
const ID = "xgap"
@ -154,6 +155,11 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
if err := tradingutil.UniversalCancelAllOrders(ctx, s.tradingSession.Exchange, s.Symbol, nil); err != nil {
s.logger.WithError(err).Errorf("cancel all orders error")
}
close(s.stopC)
bbgo.Sync(ctx, s)
})