mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-15 11:33:50 +00:00
Merge pull request #1813 from c9s/kbearXD/binance/orderbook
This commit is contained in:
commit
230d7e117e
|
@ -86,17 +86,7 @@ func NewStream(ex *Exchange, client *binance.Client, futuresClient *futures.Clie
|
||||||
|
|
||||||
stream.OnDepthEvent(func(e *DepthEvent) {
|
stream.OnDepthEvent(func(e *DepthEvent) {
|
||||||
f, ok := stream.depthBuffers[e.Symbol]
|
f, ok := stream.depthBuffers[e.Symbol]
|
||||||
if ok {
|
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 {
|
|
||||||
f = depth.NewBuffer(func() (types.SliceOrderBook, int64, error) {
|
f = depth.NewBuffer(func() (types.SliceOrderBook, int64, error) {
|
||||||
log.Infof("fetching %s depth...", e.Symbol)
|
log.Infof("fetching %s depth...", e.Symbol)
|
||||||
return ex.QueryDepth(context.Background(), 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
|
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)
|
stream.OnOutboundAccountPositionEvent(stream.handleOutboundAccountPositionEvent)
|
||||||
|
|
Loading…
Reference in New Issue
Block a user