mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
fix f.loadDepthSnapshot timing
This commit is contained in:
parent
50fc1fd3ac
commit
cabc082713
|
@ -32,6 +32,10 @@ func (f *DepthFrame) Reset() {
|
|||
}
|
||||
|
||||
func (f *DepthFrame) loadDepthSnapshot() {
|
||||
if debugBinanceDepth {
|
||||
log.Infof("loading %s depth from the restful api", f.Symbol)
|
||||
}
|
||||
|
||||
depth, err := f.fetch(f.context)
|
||||
if err != nil {
|
||||
return
|
||||
|
@ -80,14 +84,14 @@ func (f *DepthFrame) PushEvent(e DepthEvent) {
|
|||
f.BufEvents = append(f.BufEvents, e)
|
||||
f.mu.Unlock()
|
||||
|
||||
f.loadDepthSnapshot()
|
||||
|
||||
// start a worker to update the snapshot periodically.
|
||||
go f.once.Do(func() {
|
||||
if debugBinanceDepth {
|
||||
log.Infof("starting depth snapshot updater for %s market", f.Symbol)
|
||||
}
|
||||
|
||||
f.loadDepthSnapshot()
|
||||
|
||||
ticker := time.NewTicker(1*time.Minute + time.Duration(rand.Intn(10))*time.Millisecond)
|
||||
defer ticker.Stop()
|
||||
for {
|
||||
|
|
Loading…
Reference in New Issue
Block a user