From 2a767aba71d83c393824e76f99e28a92dfcfc960 Mon Sep 17 00:00:00 2001 From: Lan Phan Date: Fri, 20 Sep 2024 20:01:24 +0700 Subject: [PATCH] fix OnNew event must be called before OnFilled --- pkg/bbgo/activeorderbook.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/bbgo/activeorderbook.go b/pkg/bbgo/activeorderbook.go index dee29b579..ae695ebed 100644 --- a/pkg/bbgo/activeorderbook.go +++ b/pkg/bbgo/activeorderbook.go @@ -359,7 +359,6 @@ func (b *ActiveOrderBook) Add(orders ...types.Order) { } b.add(order) - b.EmitNew(order) } } @@ -424,6 +423,7 @@ func (b *ActiveOrderBook) add(order types.Order) { b.orders.Add(order) b.pendingOrderUpdates.Remove(pendingOrder.OrderID) + b.EmitNew(order) // 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 @@ -434,6 +434,7 @@ func (b *ActiveOrderBook) add(order types.Order) { } else { b.orders.Add(order) + b.EmitNew(order) } }