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
7 changes: 7 additions & 0 deletions HISTORY.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,13 @@
Release History
---------------

3.2.6 (2026-10-01)
+++++++++++++++++++

**Improvements**

- market_book_closed property added to handle closure per venue

3.2.5 (2026-09-30)
+++++++++++++++++++

Expand Down
2 changes: 1 addition & 1 deletion flumine/__version__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
__title__ = "flumine"
__description__ = "Betting trading framework"
__url__ = "https://github.com/betcode-org/flumine"
__version__ = "3.2.5"
__version__ = "3.2.6"
__author__ = "Liam Pauling"
__license__ = "MIT"
2 changes: 1 addition & 1 deletion flumine/baseflumine.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ def _process_market_books(self, event: events.MarketBookEvent) -> None:
# process market
market(market_book)

if market.status in ["CLOSED", "SETTLED"]:
if market.market_book_closed:
self.handler_queue.put(
events.CloseMarketEvent(market_book, venue=event.venue)
)
Expand Down
12 changes: 12 additions & 0 deletions flumine/markets/market.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,10 @@ def replace_order(
with self.transaction(client=order.client) as t:
return t.replace_order(order, new_price, market_version, force)

@property
def market_book_closed(self):
return self.status == "CLOSED"

@property
def publish_time(self) -> datetime.datetime:
return self.market_book.publish_time
Expand Down Expand Up @@ -299,6 +303,10 @@ class BetdaqMarket(Market):
def __call__(self, market_book: dict):
self.market_book = market_book

@property
def market_book_closed(self):
return self.status == "SETTLED"

@property
def publish_time(self) -> datetime.datetime:
return self.market_book["publish_time"]
Expand Down Expand Up @@ -377,6 +385,10 @@ class ToteMarket(Market):
def __call__(self, market_book: dict):
self.market_book = market_book

@property
def market_book_closed(self):
return self.seconds_to_start < 0 and self.status == "CLOSED"

@property
def publish_time(self) -> datetime.datetime:
return self.market_book["publish_time"]
Expand Down
15 changes: 15 additions & 0 deletions tests/test_markets.py
Original file line number Diff line number Diff line change
Expand Up @@ -267,6 +267,11 @@ def test_replace_order(self, mock_transaction):
mock_transaction.assert_called_with(client=mock_order.client)
mock_transaction.replace_order.assert_called_with(mock_order, 2, False, True)

def test_market_book_closed(self):
self.assertFalse(self.market.market_book_closed)
self.market.market_book.status = "CLOSED"
self.assertTrue(self.market.market_book_closed)

def test_publish_time(self):
self.assertEqual(self.market.publish_time, self.market.market_book.publish_time)

Expand Down Expand Up @@ -596,6 +601,11 @@ def test_call(self):
self.market(mock_market_book)
self.assertEqual(self.market.market_book, mock_market_book)

def test_market_book_closed(self):
self.assertFalse(self.market.market_book_closed)
self.market.market_book["status"] = "SETTLED"
self.assertTrue(self.market.market_book_closed)

def test_publish_time(self):
self.assertEqual(
self.market.publish_time, self.market.market_book["publish_time"]
Expand Down Expand Up @@ -660,6 +670,11 @@ def test_call(self):
self.market(mock_market_book)
self.assertEqual(self.market.market_book, mock_market_book)

def test_market_book_closed(self):
self.assertFalse(self.market.market_book_closed)
self.market.market_book["type"]["selling"]["status"] = "CLOSED"
self.assertTrue(self.market.market_book_closed)

def test_publish_time(self):
self.assertEqual(
self.market.publish_time, self.market.market_book["publish_time"]
Expand Down
Loading