mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
xalign: graceful cancel orders when shutting down
This commit is contained in:
parent
a126bc3bb6
commit
1855e52838
|
@ -5,6 +5,7 @@ import (
|
|||
"errors"
|
||||
"fmt"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
@ -234,6 +235,15 @@ func (s *Strategy) CrossRun(ctx context.Context, _ bbgo.OrderExecutionRouter, se
|
|||
s.orderBooks[sessionName] = orderBook
|
||||
}
|
||||
|
||||
bbgo.OnShutdown(ctx, func(ctx context.Context, wg *sync.WaitGroup) {
|
||||
defer wg.Done()
|
||||
for n, session := range s.sessions {
|
||||
if ob, ok := s.orderBooks[n]; ok {
|
||||
_ = ob.GracefulCancel(ctx, session.Exchange)
|
||||
}
|
||||
}
|
||||
})
|
||||
|
||||
go func() {
|
||||
s.align(ctx, s.sessions)
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user