scmaker: graceful cancel orders

This commit is contained in:
c9s 2023-06-19 15:22:43 +08:00
parent 98a78b5224
commit 58a13507bc
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -4,6 +4,7 @@ import (
"context"
"fmt"
"math"
"sync"
log "github.com/sirupsen/logrus"
@ -152,6 +153,16 @@ func (s *Strategy) Run(ctx context.Context, orderExecutor bbgo.OrderExecutor, se
}
})
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
defer wg.Done()
err := s.liquidityOrderBook.GracefulCancel(ctx, s.session.Exchange)
logErr(err, "unable to cancel liquidity orders")
err = s.adjustmentOrderBook.GracefulCancel(ctx, s.session.Exchange)
logErr(err, "unable to cancel adjustment orders")
})
return nil
}