bbgo: pass the actual context object instead of background context

This commit is contained in:
c9s 2024-09-25 13:36:49 +08:00
parent 329b8a40d9
commit 768428a7eb
No known key found for this signature in database
GPG Key ID: 7385E7E464CB0A54

View File

@ -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)
}