Repository: liampauling/flumine (python)

Issue:
backtesting: market_book not updating on market.closed = True
```python
for market in framework.markets:
    results = {r.selection_id: r.status for r in market.market_book.runners}
    print(results)

{38432986: 'ACTIVE', 28095515: 'REMOVED', 38235043: 'ACTIVE', 26817710: 'ACTIVE', 36775362: 'ACTIVE', 37487570: 'ACTIVE', 27207443: 'ACTIVE', 10138440: 'ACTIVE', 38648845: 'ACTIVE', 14037512: 'ACTIVE', 36753881: 'ACTIVE', 12829452: 'ACTIVE', 24075586: 'ACTIVE'}
```
   
https://github.com/liampauling/flumine/blob/ec060b7d98a9f15ec229fab73644d5ad970e05fe/flumine/backtest/backtest.py#L118


Pull request description:
close #499
add missingmarket call on closure

Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index b1f5f8f..bf3b6ab 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -10,6 +10,10 @@ Release History
 
 - Update to use `listener_kwargs` in `_process` rather than `snap`
 
+**Bug Fixes**
+
+- #499 missing market call on closure
+
 **Libraries**
 
 - betfairlightweight upgraded to 2.14.0
diff --git a/flumine/baseflumine.py b/flumine/baseflumine.py
index ab744ee..f8e3f5f 100644
--- a/flumine/baseflumine.py
+++ b/flumine/baseflumine.py
@@ -272,6 +272,8 @@ class BaseFlumine:
                 extra={"market_id": market_id, **self.info},
             )
             return
+        # process market
+        market(market_book)
         if market.closed is False:
             market.close_market()
         if recorder is False:


Test patch:
diff --git a/tests/test_baseflumine.py b/tests/test_baseflumine.py
index a803088..f77b701 100644
--- a/tests/test_baseflumine.py
+++ b/tests/test_baseflumine.py
@@ -234,6 +234,7 @@ class BaseFlumineTest(unittest.TestCase):
             mock_market, mock_market_book
         )
         mock_log_control.assert_called_with(mock_event)
+        mock_market.assert_called_with(mock_market_book)
 
     @mock.patch("flumine.baseflumine.BaseFlumine.info")
     @mock.patch("flumine.baseflumine.BaseFlumine.log_control")