mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-10 09:11:55 +00:00
bbgo: triggering pending order update event ot the handler
This commit is contained in:
parent
31c9ebf34b
commit
b666c8bf40
|
@ -307,13 +307,23 @@ func (b *ActiveOrderBook) Add(orders ...types.Order) {
|
|||
// add the order to the active order book and check the pending order
|
||||
func (b *ActiveOrderBook) add(order types.Order) {
|
||||
if pendingOrder, ok := b.pendingOrderUpdates.Get(order.OrderID); ok {
|
||||
// if the pending order update time is newer than the adding order
|
||||
// we should use the pending order rather than the adding order.
|
||||
// if pending order is older, than we should add the new one, and drop the pending order
|
||||
if pendingOrder.UpdateTime.Time().After(order.UpdateTime.Time()) {
|
||||
b.orders.Add(pendingOrder)
|
||||
} else {
|
||||
b.orders.Add(order)
|
||||
order = pendingOrder
|
||||
}
|
||||
|
||||
b.orders.Add(order)
|
||||
b.pendingOrderUpdates.Remove(pendingOrder.OrderID)
|
||||
|
||||
// when using add(order), it's usually a new maker order on the order book.
|
||||
// so, when it's not status=new, we should trigger order update handler
|
||||
if order.Status != types.OrderStatusNew {
|
||||
// emit the order update handle function to trigger callback
|
||||
b.orderUpdateHandler(order)
|
||||
}
|
||||
|
||||
b.pendingOrderUpdates.Remove(order.OrderID)
|
||||
} else {
|
||||
b.orders.Add(order)
|
||||
}
|
||||
|
|
|
@ -1615,6 +1615,7 @@ func (s *Strategy) recoverGrid(ctx context.Context, session *bbgo.ExchangeSessio
|
|||
}
|
||||
|
||||
s.updateOpenOrderPricesMetrics(s.orderExecutor.ActiveMakerOrders().Orders())
|
||||
return nil
|
||||
}
|
||||
|
||||
// openOrdersMismatches verifies if the open orders are on the grid pins
|
||||
|
|
Loading…
Reference in New Issue
Block a user