From ba091dccf6334fbd45a4f8c577828300747d2eb4 Mon Sep 17 00:00:00 2001 From: zenix Date: Tue, 11 May 2021 06:57:09 +0000 Subject: [PATCH] Fix: binance's cancel update is sent through New status with 0 quantity --- pkg/bbgo/active_book.go | 10 +++++++++- 1 file changed, 9 insertions(+), 1 deletion(-) diff --git a/pkg/bbgo/active_book.go b/pkg/bbgo/active_book.go index 28095046e..53c7bc702 100644 --- a/pkg/bbgo/active_book.go +++ b/pkg/bbgo/active_book.go @@ -47,9 +47,17 @@ func (b *LocalActiveOrderBook) orderUpdateHandler(order types.Order) { b.EmitFilled(order) } - case types.OrderStatusPartiallyFilled, types.OrderStatusNew: + case types.OrderStatusPartiallyFilled: b.Update(order) + case types.OrderStatusNew: + if order.Quantity == 0 { + log.Debugf("[LocalActiveOrderBook] order status %s, removing %d...", order.Status, order.OrderID) + b.Remove(order) + } else { + b.Update(order) + } + case types.OrderStatusCanceled, types.OrderStatusRejected: log.Debugf("[LocalActiveOrderBook] order status %s, removing %d...", order.Status, order.OrderID) b.Remove(order)