From 768428a7eb403189f8c22be38d2fa8dae255e9a2 Mon Sep 17 00:00:00 2001 From: c9s Date: Wed, 25 Sep 2024 13:36:49 +0800 Subject: [PATCH] bbgo: pass the actual context object instead of background context --- pkg/bbgo/activeorderbook.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/pkg/bbgo/activeorderbook.go b/pkg/bbgo/activeorderbook.go index dee29b579..adfbf1666 100644 --- a/pkg/bbgo/activeorderbook.go +++ b/pkg/bbgo/activeorderbook.go @@ -146,12 +146,11 @@ func (b *ActiveOrderBook) FastCancel(ctx context.Context, ex types.Exchange, ord // optimize order cancel for back-testing if IsBackTesting { - return ex.CancelOrders(context.Background(), orders...) + return ex.CancelOrders(ctx, orders...) } log.Debugf("[ActiveOrderBook] no wait cancelling %s orders...", b.Symbol) - // since ctx might be canceled, we should use background context here - if err := ex.CancelOrders(context.Background(), orders...); err != nil { + if err := ex.CancelOrders(ctx, orders...); err != nil { log.WithError(err).Errorf("[ActiveOrderBook] no wait can not cancel %s orders", b.Symbol) }