grid2: delay start process by 5s

This commit is contained in:
c9s 2023-08-31 17:08:00 +08:00
parent f24bd3532c
commit e74da87e51
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -1964,16 +1964,6 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
}
})
session.UserDataStream.OnConnect(func() {
if !bbgo.IsBackTesting {
// callback may block the stream execution, so we spawn the recover function to the background
// add (5 seconds + random <10 seconds jitter) delay
go time.AfterFunc(util.MillisecondsJitter(5*time.Second, 1000*10), func() {
s.recoverActiveOrders(ctx, session)
})
}
})
// if TriggerPrice is zero, that means we need to open the grid when start up
if s.TriggerPrice.IsZero() {
// must call the openGrid method inside the OnStart callback because
@ -1985,13 +1975,25 @@ func (s *Strategy) Run(ctx context.Context, _ bbgo.OrderExecutor, session *bbgo.
s.logger.Infof("user data stream started, initializing grid...")
if !bbgo.IsBackTesting {
go s.startProcess(ctx, session)
go time.AfterFunc(3*time.Second, func() {
s.startProcess(ctx, session)
})
} else {
s.startProcess(ctx, session)
}
})
}
session.UserDataStream.OnConnect(func() {
if !bbgo.IsBackTesting {
// callback may block the stream execution, so we spawn the recover function to the background
// add (5 seconds + random <10 seconds jitter) delay
go time.AfterFunc(util.MillisecondsJitter(5*time.Second, 1000*10), func() {
s.recoverActiveOrders(ctx, session)
})
}
})
return nil
}