Repository: liampauling/flumine
Pull request #359 (2020-12-31 14:38:26)

Updates market catalogue middleware to only update when adding market


Patch:
diff --git a/HISTORY.rst b/HISTORY.rst
index 0b1d16c..333a472 100644
--- a/HISTORY.rst
+++ b/HISTORY.rst
@@ -3,23 +3,6 @@
 Release History
 ---------------
 
-1.15.2 (2021-01-11)
-+++++++++++++++++++
-
-**Improvements**
-
-- Order execution args added on place/cancel/update/replace
-- License update
-- Example update (@lunswor)
-
-**Bug Fixes**
-
-- #358 dynamic keep alive (based on trading client)
-
-**Libraries**
-
-- py3.5 removed from setup.py
-
 1.15.1 (2020-12-28)
 +++++++++++++++++++
 
diff --git a/LICENSE b/LICENSE
index f32fff9..75348bf 100644
--- a/LICENSE
+++ b/LICENSE
@@ -1,6 +1,6 @@
 MIT License
 
-Copyright (c) 2021, Liam Pauling
+Copyright (c) 2020, Liam Pauling
 
 Permission is hereby granted, free of charge, to any person obtaining a copy
 of this software and associated documentation files (the "Software"), to deal
diff --git a/examples/controls/jupyterloggingcontrol.py b/examples/controls/jupyterloggingcontrol.py
index c7cd02b..99aaf24 100644
--- a/examples/controls/jupyterloggingcontrol.py
+++ b/examples/controls/jupyterloggingcontrol.py
@@ -23,11 +23,9 @@ use:
 class JupyterLoggingControl(LoggingControl):
     NAME = "JUPYTER_LOGGING_CONTROL"
 
-    def __init__(
-        self, file_name: str = "orders.json", directory: str = "/tmp", *args, **kwargs
-    ):
+    def __init__(self, *args, **kwargs):
         super(JupyterLoggingControl, self).__init__(*args, **kwargs)
-        self.file_name = os.path.join(directory, file_name)
+        self.filename = os.path.join("/tmp", "orders.json")
 
     def _process_end_flumine(self, event):
         framework = event.event
@@ -68,10 +66,9 @@ class JupyterLoggingControl(LoggingControl):
 
     def _create_json(self, data):
         # save json to file
-        with open(self.file_name, "w") as f:
+        with open(self.filename, "w") as f:
             json.dump(data, f)
 
-    @staticmethod
     def launch(self, argv=None, **kwargs):
         from jupyterlab.labapp import LabApp
 
diff --git a/examples/middlewares/marketcatalogue.py b/examples/middlewares/marketcatalogue.py
index 4b3b6f4..4e5d5c3 100644
--- a/examples/middlewares/marketcatalogue.py
+++ b/examples/middlewares/marketcatalogue.py
@@ -11,6 +11,9 @@ MARKET_CATALOGUE_PATH = ""  # update to correct path
 # Usage framework.add_middleware(MarketCatalogueMiddleware())
 class MarketCatalogueMiddleware(Middleware):
     def __call__(self, market) -> None:
+        pass
+
+    def add_market(self, market) -> None:
         catalogue_file_path = os.path.join(MARKET_CATALOGUE_PATH, market.market_id)
         if os.path.exists(catalogue_file_path):
             with open(catalogue_file_path, "r") as r:
diff --git a/flumine/__version__.py b/flumine/__version__.py
index 3a2f232..40ca538 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.15.2"
+__version__ = "1.15.1"
 __author__ = "Liam Pauling"
 __license__ = "MIT"
diff --git a/flumine/flumine.py b/flumine/flumine.py
index 99a2229..d9c6ff5 100644
--- a/flumine/flumine.py
+++ b/flumine/flumine.py
@@ -55,11 +55,8 @@ class Flumine(BaseFlumine):
                 del event
 
     def _add_default_workers(self):
-        ka_interval = min((self.client.betting_client.session_timeout / 2), 1200)
         self.add_worker(
-            worker.BackgroundWorker(
-                self, function=worker.keep_alive, interval=ka_interval
-            )
+            worker.BackgroundWorker(self, function=worker.keep_alive, interval=1200)
         )
         self.add_worker(
             worker.BackgroundWorker(
diff --git a/setup.py b/setup.py
index 7c83895..d066f0d 100644
--- a/setup.py
+++ b/setup.py
@@ -32,10 +32,10 @@ setup(
     classifiers=[
         "License :: OSI Approved :: MIT License",
         "Operating System :: OS Independent",
+        "Programming Language :: Python :: 3.5",
         "Programming Language :: Python :: 3.6",
         "Programming Language :: Python :: 3.7",
         "Programming Language :: Python :: 3.8",
-        "Programming Language :: Python :: 3.9",
     ],
     test_suite="tests",
 )


Test patch:
diff --git a/tests/test_flumine.py b/tests/test_flumine.py
index 7bc2773..05d1571 100644
--- a/tests/test_flumine.py
+++ b/tests/test_flumine.py
@@ -66,7 +66,6 @@ class FlumineTest(unittest.TestCase):
         mock__add_default_workers.assert_called()
 
     def test__add_default_workers(self):
-        self.mock_trading.betting_client.session_timeout = 1200
         self.flumine._add_default_workers()
         self.assertEqual(len(self.flumine._workers), 4)