Repository: liampauling/flumine
Pull request #170 (2020-05-22 14:09:49)

Release/1.5.3 2


Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index ef5121f..3f99136 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,6 +3,18 @@
 Release History
 ---------------
 
+1.5.3 (2020-05-22)
++++++++++++++++++++
+
+**Improvements**
+
+- Market properties added
+
+**Bug Fixes**
+
+- Memory leak in historical stream fixed (queue)
+- process_closed_market bug fix in process logic
+
 1.5.2 (2020-05-21)
 +++++++++++++++++++
 
diff --git a/flumine/__version__.py b/flumine/__version__.py
index 9c755cb..c0859c5 100644
--- a/flumine/__version__.py
+++ b/flumine/__version__.py
@@ -1,6 +1,6 @@
 __title__ = "flumine"
 __description__ = "Betfair trading framework"
 __url__ = "https://github.com/liampauling/flumine"
-__version__ = "1.5.2"
+__version__ = "1.5.3"
 __author__ = "Liam Pauling"
 __license__ = "MIT"
diff --git a/flumine/baseflumine.py b/flumine/baseflumine.py
index 55800c2..18ac464 100644
--- a/flumine/baseflumine.py
+++ b/flumine/baseflumine.py
@@ -197,7 +197,7 @@ class BaseFlumine:
         market.blotter.process_closed_market(event.event)
 
         for strategy in self.strategies:
-            if strategy.check_market(market, event.event):
+            if market.market_book.streaming_unique_id in strategy.stream_ids:
                 strategy.process_closed_market(market, event.event)
 
         self.cleared_market_queue.put(market.market_id)
diff --git a/flumine/markets/market.py b/flumine/markets/market.py
index ef3a419..c9d2d88 100644
--- a/flumine/markets/market.py
+++ b/flumine/markets/market.py
@@ -57,6 +57,11 @@ class Market:
         order.replace(new_price)
         self.blotter.pending_replace.append(order)
 
+    @property
+    def event_type_id(self) -> str:
+        if self.market_book:
+            return self.market_book.market_definition.event_type_id
+
     @property
     def event_id(self) -> str:
         if self.market_book:
diff --git a/flumine/streams/historicalstream.py b/flumine/streams/historicalstream.py
index 367f30f..fbeeb7d 100644
--- a/flumine/streams/historicalstream.py
+++ b/flumine/streams/historicalstream.py
@@ -17,7 +17,6 @@ class HistoricalStream(BaseStream):
         pass
 
     def create_generator(self):
-        self._listener.output_queue = None
         self._listener.register_stream(0, "marketSubscription")
         stream = HistoricalGeneratorStream(
             directory=self.market_filter, listener=self._listener


Test patch:
diff --git a/tests/test_baseflumine.py b/tests/test_baseflumine.py
index 7322daa..7a20eb6 100644
--- a/tests/test_baseflumine.py
+++ b/tests/test_baseflumine.py
@@ -173,8 +173,10 @@ class BaseFlumineTest(unittest.TestCase):
     @mock.patch("flumine.baseflumine.BaseFlumine.log_control")
     def test__process_close_market(self, mock_log_control):
         mock_strategy = mock.Mock()
+        mock_strategy.stream_ids = [1, 2, 3]
         self.base_flumine.strategies = [mock_strategy]
         mock_market = mock.Mock()
+        mock_market.market_book.streaming_unique_id = 2
         mock_markets = mock.Mock()
         mock_markets.markets = {"1.23": mock_market}
         self.base_flumine.markets = mock_markets
@@ -184,7 +186,6 @@ class BaseFlumineTest(unittest.TestCase):
         self.base_flumine._process_close_market(mock_event)
         mock_market.close_market.assert_called_with()
         mock_market.blotter.process_closed_market.assert_called_with(mock_market_book)
-        mock_strategy.check_market.assert_called_with(mock_market, mock_market_book)
         mock_strategy.process_closed_market.assert_called_with(
             mock_market, mock_market_book
         )
diff --git a/tests/test_markets.py b/tests/test_markets.py
index 4e15c0e..2dd7c17 100644
--- a/tests/test_markets.py
+++ b/tests/test_markets.py
@@ -169,6 +169,13 @@ class MarketTest(unittest.TestCase):
         mock_order.replace.assert_called_with(1.01)
         self.assertEqual(mock_blotter.pending_replace, [mock_order])
 
+    def test_event_type_id(self):
+        mock_market_book = mock.Mock()
+        self.market.market_book = mock_market_book
+        self.assertEqual(
+            self.market.event_type_id, mock_market_book.market_definition.event_type_id
+        )
+
     def test_event_id(self):
         mock_market_book = mock.Mock()
         self.market.market_book = mock_market_book