From 391512c5d34c3f0f06191b73adb81af73f99090b Mon Sep 17 00:00:00 2001 From: todd <3578666+tgibson11@users.noreply.github.com> Date: Tue, 14 Nov 2023 07:31:00 -0700 Subject: [PATCH 1/5] Improve log messages when there is a problem emailing a report (cherry picked from commit ca311ccc0fb32b024f5fd20117d620b9260e10c2) --- syslogdiag/email_via_db_interface.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/syslogdiag/email_via_db_interface.py b/syslogdiag/email_via_db_interface.py index 3deb1886b1..e37cd039f4 100644 --- a/syslogdiag/email_via_db_interface.py +++ b/syslogdiag/email_via_db_interface.py @@ -50,7 +50,7 @@ def send_email_and_record_date_or_store_on_fail( except Exception as e: # problem sending emails will store instead data.log.debug( - "Problem %s sending email subject %s, but message is stored" + "Problem %s sending email subject %s, but message will be stored" % (str(e), subject) ) store_message(data, body, subject, email_is_report=email_is_report) @@ -141,7 +141,7 @@ def record_date_of_email_warning_send(data, subject): def store_message(data, body, subject, email_is_report=False): if email_is_report: - # can't store reports + data.log.debug("Message not stored: can't store reports") return None email_store_file = get_storage_filename(data) From effcd72e408b82c67e16ba8a5fa8941ad9c4a961 Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Tue, 28 Nov 2023 13:22:55 +0000 Subject: [PATCH 2/5] undo monkeypatch work --- systems/tests/test_position_sizing.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/systems/tests/test_position_sizing.py b/systems/tests/test_position_sizing.py index b0676dc816..b81025b357 100644 --- a/systems/tests/test_position_sizing.py +++ b/systems/tests/test_position_sizing.py @@ -29,6 +29,9 @@ def setUp(self): self.data = data self.position_sizing = PositionSizing + def tearDown(self) -> None: + self.monkeypatch.undo() + @unittest.SkipTest def test_get_combined_forecast(self): self.assertAlmostEqual( @@ -60,8 +63,9 @@ def test_get_instrument_sizing_data(self): self.assertEqual(ans[1], 2500) def test_get_daily_cash_vol_target(self): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - self.monkeypatch.setattr(os, "environ", envs) + self.monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) ans_dict = self.system.positionSize.get_vol_target_dict() self.assertEqual(ans_dict["base_currency"], "GBP") From 21fb1ab607d2bb4b54277ca89602e32d04facacf Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Tue, 28 Nov 2023 15:12:40 +0000 Subject: [PATCH 3/5] skip weird 'ufunc' failing test --- sysdata/tests/test_config.py | 17 ++++++++--------- tests/test_examples.py | 1 + 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/sysdata/tests/test_config.py b/sysdata/tests/test_config.py index d7ffbf9afa..2035371392 100644 --- a/sysdata/tests/test_config.py +++ b/sysdata/tests/test_config.py @@ -1,7 +1,6 @@ from sysdata.config.configdata import Config from sysdata.config.control_config import get_control_config from sysdata.config.private_directory import PRIVATE_CONFIG_DIR_ENV_VAR -import os class TestConfig: @@ -11,16 +10,16 @@ def test_default(self): assert config.get_element("ib_idoffset") == 100 def test_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) Config.reset() config = Config.default_config() assert config.get_element("ib_idoffset") == 1000 def test_bad_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv(PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests") Config.reset() config = Config.default_config() @@ -34,8 +33,9 @@ def test_default_control(self): ) def test_control_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests.custom_private_config"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv( + PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests.custom_private_config" + ) config = get_control_config() assert ( @@ -44,8 +44,7 @@ def test_control_custom_dir(self, monkeypatch): ) def test_control_bad_custom_dir(self, monkeypatch): - envs = {PRIVATE_CONFIG_DIR_ENV_VAR: "sysdata.tests"} - monkeypatch.setattr(os, "environ", envs) + monkeypatch.setenv(PRIVATE_CONFIG_DIR_ENV_VAR, "sysdata.tests") config = get_control_config() assert ( diff --git a/tests/test_examples.py b/tests/test_examples.py index cef949fb9b..59ff9b8318 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -253,6 +253,7 @@ def test_simple_system_portfolio_fixed( print(my_system.portfolio.get_notional_position("SOFR").tail(5)) + @pytest.mark.skip # TODO figure out why this fails def test_simple_system_costs( self, data, From 6269c003a1e634cb598c0fa298b4e28bda1cdbe0 Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Thu, 30 Nov 2023 09:46:07 +0000 Subject: [PATCH 4/5] filter out nans with pd.isnull(), and convert to numeric with pd.to_numeric() --- systems/accounts/curves/account_curve.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/systems/accounts/curves/account_curve.py b/systems/accounts/curves/account_curve.py index 9e238958d4..af746eeb4e 100644 --- a/systems/accounts/curves/account_curve.py +++ b/systems/accounts/curves/account_curve.py @@ -277,7 +277,7 @@ def sortino(self): return sortino def vals(self): - vals = self.values[~np.isnan(self.values)] + vals = pd.to_numeric(self.values[~pd.isnull(self.values)], errors="coerce") return vals From 03f85c2a7cd773fb7a9ec85a44e185033478d07d Mon Sep 17 00:00:00 2001 From: Andy Geach Date: Thu, 30 Nov 2023 09:46:21 +0000 Subject: [PATCH 5/5] unskip test --- tests/test_examples.py | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/test_examples.py b/tests/test_examples.py index 59ff9b8318..cef949fb9b 100644 --- a/tests/test_examples.py +++ b/tests/test_examples.py @@ -253,7 +253,6 @@ def test_simple_system_portfolio_fixed( print(my_system.portfolio.get_notional_position("SOFR").tail(5)) - @pytest.mark.skip # TODO figure out why this fails def test_simple_system_costs( self, data,