Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[project]
name = "meatpy"
version = "0.2.7"
version = "0.2.10"
description = "Read and process limit order book data"
authors = [
{ name = "Vincent Grégoire", email = "vincent.gregoire@hec.ca" },
Expand Down
4 changes: 2 additions & 2 deletions src/meatpy/itch50/itch50_exec_trade_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def message_event(
"Queue": "Ask",
"Volume": message.shares,
"OrderID": message.order_ref,
"Price": message.price,
"Price": message.execution_price,
}
(queue, i, j) = lob.find_order(message.order_ref)
record["OrderTimestamp"] = queue[i].queue[j].timestamp
Expand All @@ -110,7 +110,7 @@ def message_event(
"Queue": "Bid",
"Volume": message.shares,
"OrderID": message.order_ref,
"Price": message.price,
"Price": message.execution_price,
}
(queue, i, j) = lob.find_order(message.order_ref)
record["OrderTimestamp"] = queue[i].queue[j].timestamp
Expand Down
3 changes: 2 additions & 1 deletion src/meatpy/itch50/itch50_market_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -157,6 +157,7 @@ def process_message(
):
if message.stock != self.instrument:
return
self._order_refs.add(message.order_ref)
if self.track_lob:
if message.bsindicator == b"B":
order_type = OrderType.BID
Expand Down Expand Up @@ -197,7 +198,7 @@ def process_message(
volume=message.shares,
order_id=message.order_ref,
trade_ref=message.match,
price=message.price,
price=message.execution_price,
)
elif isinstance(message, OrderCancelMessage):
if message.order_ref not in self._order_refs:
Expand Down
2 changes: 1 addition & 1 deletion src/meatpy/itch50/itch50_order_event_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def message_event(self, market_processor, timestamp, message) -> None:
"order_ref": message.order_ref,
"bsindicator": "",
"shares": message.shares,
"price": message.price,
"price": message.execution_price,
"neworder_ref": "",
"MessageType": "OrderExecutedPrice",
}
Expand Down
4 changes: 2 additions & 2 deletions src/meatpy/itch50/itch50_top_of_book_message_recorder.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def message_event(self, market_processor, timestamp, message) -> None:
"Queue": "Ask",
"Volume": message.shares,
"OrderID": message.order_ref,
"Price": message.price,
"Price": message.execution_price,
}
self.records.append((timestamp, record))
elif len(lob.bid_levels) > 0 and lob.bid_levels[0].order_on_book(
Expand All @@ -134,7 +134,7 @@ def message_event(self, market_processor, timestamp, message) -> None:
"Queue": "Bid",
"Volume": message.shares,
"OrderID": message.order_ref,
"Price": message.price,
"Price": message.execution_price,
}
self.records.append((timestamp, record))
elif isinstance(message, OrderCancelMessage):
Expand Down
2 changes: 1 addition & 1 deletion src/meatpy/market_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ def before_lob_update(self, new_timestamp: Timestamp) -> None:
new_timestamp: The new timestamp for the upcoming update
"""
for x in self.handlers:
x.before_lob_update(self.current_lob, new_timestamp)
x.before_lob_update(self, new_timestamp)

def message_event(self, timestamp: Timestamp, message: MarketMessage) -> None:
"""Notify handlers of a raw message event.
Expand Down
16 changes: 12 additions & 4 deletions tests/test_market_processor.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,17 @@ def setup_method(self):
def test_before_lob_update(self):
"""Test before_lob_update method."""
self.processor.before_lob_update(self.timestamp)
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
self.handler.before_lob_update.assert_called_once_with(
self.processor, self.timestamp
)

def test_before_lob_update_with_no_lob(self):
"""Test before_lob_update method with no LOB."""
self.processor.current_lob = None
self.processor.before_lob_update(self.timestamp)
self.handler.before_lob_update.assert_called_once_with(None, self.timestamp)
self.handler.before_lob_update.assert_called_once_with(
self.processor, self.timestamp
)

def test_message_event(self):
"""Test message_event method."""
Expand Down Expand Up @@ -224,12 +228,16 @@ def test_pre_lob_event(self):
"""Test pre_lob_event method."""
self.processor.pre_lob_event(self.timestamp)
# This method should call before_lob_update on handlers
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
self.handler.before_lob_update.assert_called_once_with(
self.processor, self.timestamp
)

def test_pre_lob_event_with_new_snapshot(self):
"""Test pre_lob_event method with new snapshot flag."""
self.processor.pre_lob_event(self.timestamp, new_snapshot=True)
self.handler.before_lob_update.assert_called_once_with(self.lob, self.timestamp)
self.handler.before_lob_update.assert_called_once_with(
self.processor, self.timestamp
)


class TestMarketProcessorCleanup:
Expand Down
4 changes: 2 additions & 2 deletions uv.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading