From 21fa2d758050e34c0c51788781db6e45e827ccbd Mon Sep 17 00:00:00 2001 From: liampauling Date: Thu, 3 Aug 2023 08:34:44 +0100 Subject: [PATCH 1/2] Update marketCatalogue fix when recording data --- HISTORY.rst | 7 +++++++ flumine/__version__.py | 2 +- flumine/baseflumine.py | 13 ++++++------- tests/test_baseflumine.py | 1 + 4 files changed, 15 insertions(+), 8 deletions(-) diff --git a/HISTORY.rst b/HISTORY.rst index 6dea35e0..f7204510 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -3,6 +3,13 @@ Release History --------------- +2.4.2 (2023-08-03) ++++++++++++++++++++ + +**Bug Fixes** + +- Update marketCatalogue fix when recording data + 2.4.1 (2023-07-25) +++++++++++++++++++ diff --git a/flumine/__version__.py b/flumine/__version__.py index fd398e47..9ae0bce4 100644 --- a/flumine/__version__.py +++ b/flumine/__version__.py @@ -1,6 +1,6 @@ __title__ = "flumine" __description__ = "Betting trading framework" __url__ = "https://github.com/betcode-org/flumine" -__version__ = "2.4.1" +__version__ = "2.4.2" __author__ = "Liam Pauling" __license__ = "MIT" diff --git a/flumine/baseflumine.py b/flumine/baseflumine.py index 1c2a319a..df7911b0 100644 --- a/flumine/baseflumine.py +++ b/flumine/baseflumine.py @@ -222,16 +222,15 @@ def _process_raw_data(self, event: events.RawDataEvent) -> None: market_id = datum["id"] market = self.markets.markets.get(market_id) if market is None: - self._add_market(market_id, None) + market = self._add_market(market_id, None) elif market.closed: self.markets.add_market(market_id, market) - if ( - "marketDefinition" in datum - and datum["marketDefinition"]["status"] == "CLOSED" - ): - datum["_stream_id"] = stream_id - self.handler_queue.put(events.CloseMarketEvent(datum)) + if "marketDefinition" in datum: + market.update_market_catalogue = True + if datum["marketDefinition"]["status"] == "CLOSED": + datum["_stream_id"] = stream_id + self.handler_queue.put(events.CloseMarketEvent(datum)) for strategy in self.strategies: if stream_id in strategy.stream_ids: diff --git a/tests/test_baseflumine.py b/tests/test_baseflumine.py index e531d4ef..127d3452 100644 --- a/tests/test_baseflumine.py +++ b/tests/test_baseflumine.py @@ -252,6 +252,7 @@ def test__process_raw_data_closed(self, mock__add_market, mock_events): mock__add_market.assert_called_with("1.23", None) mock_queue.put.assert_called_with(mock_events.CloseMarketEvent()) self.assertEqual(mock_event.event[3][0]["_stream_id"], mock_event.event[0]) + self.assertTrue(mock__add_market.return_value.update_market_catalogue) @mock.patch("flumine.baseflumine.BaseFlumine._add_market") def test__process_raw_data_no_id(self, mock__add_market): From 60016c1af293fe4fdf71d232cb8c9486c89f4eaa Mon Sep 17 00:00:00 2001 From: liampauling Date: Thu, 3 Aug 2023 08:35:10 +0100 Subject: [PATCH 2/2] close #674 --- HISTORY.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/HISTORY.rst b/HISTORY.rst index f7204510..6ca44858 100644 --- a/HISTORY.rst +++ b/HISTORY.rst @@ -8,7 +8,7 @@ Release History **Bug Fixes** -- Update marketCatalogue fix when recording data +- #674 Update marketCatalogue fix when recording data 2.4.1 (2023-07-25) +++++++++++++++++++