From 6f3a3dab04c00b45114c92a1e8b68e3ed7b20d22 Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Tue, 10 Dec 2013 12:58:19 -0500 Subject: [PATCH] TST: Defend against non-trading days as period start in commission test. A bug in the create_random_simulation_parameters allows the period start to be a non-trading day. That bug was causing the commission tests to randomly fail, e.g. when the period start was on Good Friday, because the commission was created on hour three of Good Friday, instead of the next Monday. When it hit that case, the test commission is never processed. Defend against that bug by using the first open of the simulation parameters which is more guaranteed to be during market hours, when creating the test commission. This is in place of fixing the bug in the random parameters function or making the parameters non-random, which are other potential fixes. --- tests/test_perf_tracking.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/test_perf_tracking.py b/tests/test_perf_tracking.py index ec47132c..738c80fa 100644 --- a/tests/test_perf_tracking.py +++ b/tests/test_perf_tracking.py @@ -171,7 +171,7 @@ class TestCommissionEvents(unittest.TestCase): self.sim_params ) - cash_adj_dt = self.sim_params.period_start \ + cash_adj_dt = self.sim_params.first_open \ + datetime.timedelta(hours=3) cash_adjustment = factory.create_commission(1, 300.0, cash_adj_dt) @@ -201,7 +201,7 @@ class TestCommissionEvents(unittest.TestCase): self.sim_params ) - cash_adj_dt = self.sim_params.period_start \ + cash_adj_dt = self.sim_params.first_open \ + datetime.timedelta(hours=3) cash_adjustment = factory.create_commission(1, 300.0, cash_adj_dt) @@ -231,7 +231,7 @@ class TestCommissionEvents(unittest.TestCase): self.sim_params ) - cash_adj_dt = self.sim_params.period_start \ + cash_adj_dt = self.sim_params.first_open \ + datetime.timedelta(hours=3) cash_adjustment = factory.create_commission(1, 300.0, cash_adj_dt)