From ee5e34f79e2c107eda7984903943b4e72cde3d6d Mon Sep 17 00:00:00 2001 From: David Blom Date: Fri, 22 Dec 2023 21:30:14 +0100 Subject: [PATCH] Fix Throttler reset (#1423) --- nautilus_trader/common/component.pxd | 1 + nautilus_trader/common/component.pyx | 10 ++++++++++ nautilus_trader/risk/engine.pyx | 2 ++ 3 files changed, 13 insertions(+) diff --git a/nautilus_trader/common/component.pxd b/nautilus_trader/common/component.pxd index 2fe4fcf3cc75..d130902cd5e7 100644 --- a/nautilus_trader/common/component.pxd +++ b/nautilus_trader/common/component.pxd @@ -183,6 +183,7 @@ cdef class Throttler: cdef readonly int sent_count """If count of messages sent from the throttler.\n\n:returns: `int`""" + cpdef void reset(self) cpdef double used(self) cpdef void send(self, msg) cdef int64_t _delta_next(self) diff --git a/nautilus_trader/common/component.pyx b/nautilus_trader/common/component.pyx index a8811120b7f5..c543f2f6d508 100644 --- a/nautilus_trader/common/component.pyx +++ b/nautilus_trader/common/component.pyx @@ -1436,6 +1436,16 @@ cdef class Throttler: """ return len(self._buffer) + cpdef void reset(self): + """ + Reset the state of the throttler. + """ + self._buffer.clear() + self._warm = False + self.recv_count = 0 + self.sent_count = 0 + self.is_limiting = False + cpdef double used(self): """ Return the percentage of maximum rate currently used. diff --git a/nautilus_trader/risk/engine.pyx b/nautilus_trader/risk/engine.pyx index 9dedfe7b7845..19e2f5f802ec 100644 --- a/nautilus_trader/risk/engine.pyx +++ b/nautilus_trader/risk/engine.pyx @@ -386,6 +386,8 @@ cdef class RiskEngine(Component): cpdef void _reset(self): self.command_count = 0 self.event_count = 0 + self._order_submit_throttler.reset() + self._order_modify_throttler.reset() cpdef void _dispose(self): pass