mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
core: add trade to the trade store when order is not matched
This commit is contained in:
parent
7adc786c8a
commit
71d86aa483
|
@ -77,7 +77,7 @@ func (c *TradeCollector) BindStreamForBackground(stream types.Stream) {
|
||||||
|
|
||||||
func (c *TradeCollector) BindStream(stream types.Stream) {
|
func (c *TradeCollector) BindStream(stream types.Stream) {
|
||||||
stream.OnTradeUpdate(func(trade types.Trade) {
|
stream.OnTradeUpdate(func(trade types.Trade) {
|
||||||
c.ProcessTrade(trade)
|
c.processTrade(trade)
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -194,6 +194,9 @@ func (c *TradeCollector) processTrade(trade types.Trade) bool {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !c.orderStore.Exists(trade.OrderID) {
|
if !c.orderStore.Exists(trade.OrderID) {
|
||||||
|
// not done yet
|
||||||
|
// add this trade to the trade store for the later processing
|
||||||
|
c.tradeStore.Add(trade)
|
||||||
c.mu.Unlock()
|
c.mu.Unlock()
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
|
@ -241,7 +244,7 @@ func (c *TradeCollector) Run(ctx context.Context) {
|
||||||
c.Process()
|
c.Process()
|
||||||
|
|
||||||
case trade := <-c.tradeC:
|
case trade := <-c.tradeC:
|
||||||
c.ProcessTrade(trade)
|
c.processTrade(trade)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user