mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-25 16:25:16 +00:00
FEAUTRE: [max] update buffer second
This commit is contained in:
parent
e26156d77b
commit
bbfd89b939
|
@ -112,6 +112,12 @@ func (b *Buffer) AddUpdate(o types.SliceOrderBook, firstUpdateID int64, finalArg
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if u.FinalUpdateID <= b.finalUpdateID {
|
||||||
|
log.Infof("the final update id %d of event is less than equal to the final update id %d of the snapshot, skip", u.FinalUpdateID, b.finalUpdateID)
|
||||||
|
b.mu.Unlock()
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
|
||||||
// if there is a missing update, we should reset the snapshot and re-fetch the snapshot
|
// if there is a missing update, we should reset the snapshot and re-fetch the snapshot
|
||||||
if u.FirstUpdateID > b.finalUpdateID+1 {
|
if u.FirstUpdateID > b.finalUpdateID+1 {
|
||||||
// emitReset will reset the once outside the mutex lock section
|
// emitReset will reset the once outside the mutex lock section
|
||||||
|
|
|
@ -236,7 +236,7 @@ func (s *Stream) handleBookEvent(ex *Exchange) func(e max.BookEvent) {
|
||||||
// the depth of websocket orderbook event is 50 by default, so we use 50 as limit here
|
// the depth of websocket orderbook event is 50 by default, so we use 50 as limit here
|
||||||
return ex.QueryDepth(context.Background(), e.Market, bookDepth)
|
return ex.QueryDepth(context.Background(), e.Market, bookDepth)
|
||||||
})
|
})
|
||||||
f.SetBufferingPeriod(time.Second)
|
f.SetBufferingPeriod(3 * time.Second)
|
||||||
f.OnReady(func(snapshot types.SliceOrderBook, updates []depth.Update) {
|
f.OnReady(func(snapshot types.SliceOrderBook, updates []depth.Update) {
|
||||||
s.EmitBookSnapshot(snapshot)
|
s.EmitBookSnapshot(snapshot)
|
||||||
for _, u := range updates {
|
for _, u := range updates {
|
||||||
|
|
Loading…
Reference in New Issue
Block a user