bbgo: push to the buffer first

This commit is contained in:
c9s 2021-06-24 20:25:53 +08:00
parent 7d853a9c74
commit 06a1f018c2

View File

@ -66,15 +66,7 @@ func (c *TradeCollector) Run(ctx context.Context) {
c.EmitPositionUpdate(c.position)
case trade := <-c.tradeC:
if c.orderStore.Exists(trade.OrderID) {
c.EmitTrade(trade)
if profit, netProfit, madeProfit := c.position.AddTrade(trade) ; madeProfit {
c.EmitProfit(trade, profit, netProfit)
}
c.EmitPositionUpdate(c.position)
} else {
c.tradeStore.Add(trade)
}
c.tradeStore.Add(trade)
}
}
}