Skip to content

Commit

Permalink
Fix Throttler reset (#1423)
Browse files Browse the repository at this point in the history
  • Loading branch information
davidsblom authored Dec 22, 2023
1 parent 061e8f3 commit ee5e34f
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 0 deletions.
1 change: 1 addition & 0 deletions nautilus_trader/common/component.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
10 changes: 10 additions & 0 deletions nautilus_trader/common/component.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
2 changes: 2 additions & 0 deletions nautilus_trader/risk/engine.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ee5e34f

Please sign in to comment.