From 958e0a180e7802a123989814243382f964ab9409 Mon Sep 17 00:00:00 2001 From: Chris Sellers Date: Wed, 25 Oct 2023 22:17:37 +1100 Subject: [PATCH] Fix Strategy cancellation of managed GTD on start --- nautilus_trader/trading/strategy.pyx | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/nautilus_trader/trading/strategy.pyx b/nautilus_trader/trading/strategy.pyx index d8c81796e7b4..da61278fdd84 100644 --- a/nautilus_trader/trading/strategy.pyx +++ b/nautilus_trader/trading/strategy.pyx @@ -353,8 +353,14 @@ cdef class Strategy(Actor): if self.manage_gtd_expiry: for order in open_orders: - if order.time_in_force == TimeInForce.GTD and not self._has_gtd_expiry_timer(order.client_order_id): - self._set_gtd_expiry(order) + if order.time_in_force == TimeInForce.GTD: + if self._clock.timestamp_ns() >= order.expire_time_ns: + if self._has_gtd_expiry_timer(order.client_order_id): + self.cancel_gtd_expiry(order) + self.cancel_order(order) + continue + if not self._has_gtd_expiry_timer(order.client_order_id): + self._set_gtd_expiry(order) self.on_start()