Skip to content

Commit

Permalink
Merge branch 'develop' of https://github.com/robcarver17/pysystemtrade
Browse files Browse the repository at this point in the history
…into develop
  • Loading branch information
Rob Carver committed Dec 4, 2023
2 parents 977e8ba + acd9643 commit b292414
Show file tree
Hide file tree
Showing 4 changed files with 17 additions and 14 deletions.
17 changes: 8 additions & 9 deletions sysdata/tests/test_config.py
Original file line number Diff line number Diff line change
@@ -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:
Expand All @@ -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()
Expand All @@ -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 (
Expand All @@ -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 (
Expand Down
4 changes: 2 additions & 2 deletions syslogdiag/email_via_db_interface.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -140,7 +140,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)
Expand Down
2 changes: 1 addition & 1 deletion systems/accounts/curves/account_curve.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
8 changes: 6 additions & 2 deletions systems/tests/test_position_sizing.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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")
Expand Down

0 comments on commit b292414

Please sign in to comment.