mirror of
https://github.com/c9s/bbgo.git
synced 2024-11-22 14:55:16 +00:00
bbgo: check order exists
This commit is contained in:
parent
dda3f25c61
commit
2669c3a5db
|
@ -233,17 +233,6 @@ func (b *ActiveOrderBook) GracefulCancel(ctx context.Context, ex types.Exchange,
|
|||
}
|
||||
|
||||
func (b *ActiveOrderBook) orderUpdateHandler(order types.Order) {
|
||||
hasSymbol := len(b.Symbol) > 0
|
||||
|
||||
if hasSymbol && order.Symbol != b.Symbol {
|
||||
return
|
||||
}
|
||||
|
||||
if !b.orders.Exists(order.OrderID) {
|
||||
b.pendingOrderUpdates.Add(order)
|
||||
return
|
||||
}
|
||||
|
||||
b.Update(order)
|
||||
}
|
||||
|
||||
|
@ -279,6 +268,17 @@ func (b *ActiveOrderBook) update(orders ...types.Order) {
|
|||
// When order is New or PartiallyFilled, the internal order will be updated according to the latest order update.
|
||||
// When the order is cancelled, it will be removed from the internal order storage.
|
||||
func (b *ActiveOrderBook) Update(order types.Order) {
|
||||
hasSymbol := len(b.Symbol) > 0
|
||||
|
||||
if hasSymbol && order.Symbol != b.Symbol {
|
||||
return
|
||||
}
|
||||
|
||||
if !b.orders.Exists(order.OrderID) {
|
||||
b.pendingOrderUpdates.Add(order)
|
||||
return
|
||||
}
|
||||
|
||||
switch order.Status {
|
||||
case types.OrderStatusFilled:
|
||||
// make sure we have the order and we remove it
|
||||
|
|
Loading…
Reference in New Issue
Block a user