mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-21 22:43:52 +00:00
FEATURE: [binance] add update when first receive the orderbook event
This commit is contained in:
parent
ce6667268c
commit
f8bd8e4164
|
@ -86,17 +86,7 @@ func NewStream(ex *Exchange, client *binance.Client, futuresClient *futures.Clie
|
|||
|
||||
stream.OnDepthEvent(func(e *DepthEvent) {
|
||||
f, ok := stream.depthBuffers[e.Symbol]
|
||||
if ok {
|
||||
err := f.AddUpdate(types.SliceOrderBook{
|
||||
Symbol: e.Symbol,
|
||||
Time: e.EventBase.Time.Time(),
|
||||
Bids: e.Bids,
|
||||
Asks: e.Asks,
|
||||
}, e.FirstUpdateID, e.FinalUpdateID)
|
||||
if err != nil {
|
||||
log.WithError(err).Errorf("found missing %s update event", e.Symbol)
|
||||
}
|
||||
} else {
|
||||
if !ok {
|
||||
f = depth.NewBuffer(func() (types.SliceOrderBook, int64, error) {
|
||||
log.Infof("fetching %s depth...", e.Symbol)
|
||||
return ex.QueryDepth(context.Background(), e.Symbol)
|
||||
|
@ -113,6 +103,15 @@ func NewStream(ex *Exchange, client *binance.Client, futuresClient *futures.Clie
|
|||
})
|
||||
stream.depthBuffers[e.Symbol] = f
|
||||
}
|
||||
|
||||
if err := f.AddUpdate(types.SliceOrderBook{
|
||||
Symbol: e.Symbol,
|
||||
Time: e.EventBase.Time.Time(),
|
||||
Bids: e.Bids,
|
||||
Asks: e.Asks,
|
||||
}, e.FirstUpdateID, e.FinalUpdateID); err != nil {
|
||||
log.WithError(err).Errorf("found missing %s update event", e.Symbol)
|
||||
}
|
||||
})
|
||||
|
||||
stream.OnOutboundAccountPositionEvent(stream.handleOutboundAccountPositionEvent)
|
||||
|
|
Loading…
Reference in New Issue
Block a user