Skip to content

Commit b9dcf3c

Browse files
authored
Merge pull request #66 from vgreg/fix-before-lob-update-bug
Fixed a bad reference to current_lob in before_lob_update
2 parents b4949f6 + 18052a5 commit b9dcf3c

File tree

2 files changed

+13
-5
lines changed

2 files changed

+13
-5
lines changed

src/meatpy/market_processor.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ def before_lob_update(self, new_timestamp: Timestamp) -> None:
8484
new_timestamp: The new timestamp for the upcoming update
8585
"""
8686
for x in self.handlers:
87-
x.before_lob_update(self.current_lob, new_timestamp)
87+
x.before_lob_update(self, new_timestamp)
8888

8989
def message_event(self, timestamp: Timestamp, message: MarketMessage) -> None:
9090
"""Notify handlers of a raw message event.

tests/test_market_processor.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -74,13 +74,17 @@ def setup_method(self):
7474
def test_before_lob_update(self):
7575
"""Test before_lob_update method."""
7676
self.processor.before_lob_update(self.timestamp)
77-
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
77+
self.handler.before_lob_update.assert_called_once_with(
78+
self.processor, self.timestamp
79+
)
7880

7981
def test_before_lob_update_with_no_lob(self):
8082
"""Test before_lob_update method with no LOB."""
8183
self.processor.current_lob = None
8284
self.processor.before_lob_update(self.timestamp)
83-
self.handler.before_lob_update.assert_called_once_with(None, self.timestamp)
85+
self.handler.before_lob_update.assert_called_once_with(
86+
self.processor, self.timestamp
87+
)
8488

8589
def test_message_event(self):
8690
"""Test message_event method."""
@@ -224,12 +228,16 @@ def test_pre_lob_event(self):
224228
"""Test pre_lob_event method."""
225229
self.processor.pre_lob_event(self.timestamp)
226230
# This method should call before_lob_update on handlers
227-
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
231+
self.handler.before_lob_update.assert_called_once_with(
232+
self.processor, self.timestamp
233+
)
228234

229235
def test_pre_lob_event_with_new_snapshot(self):
230236
"""Test pre_lob_event method with new snapshot flag."""
231237
self.processor.pre_lob_event(self.timestamp, new_snapshot=True)
232-
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
238+
self.handler.before_lob_update.assert_called_once_with(
239+
self.processor, self.timestamp
240+
)
233241

234242

235243
class TestMarketProcessorCleanup:

0 commit comments

Comments
 (0)