From c0b161287db06931e97e286e255f21ce8efdc4f3 Mon Sep 17 00:00:00 2001 From: Thomas Wiecki Date: Tue, 23 Oct 2012 15:47:38 -0400 Subject: [PATCH] Fixed odd bug that caused the first day not to get simulated. This triggered some changes to the batchtransform unittests. --- tests/test_transforms.py | 9 +++++---- zipline/gens/tradesimulation.py | 4 +++- 2 files changed, 8 insertions(+), 5 deletions(-) diff --git a/tests/test_transforms.py b/tests/test_transforms.py index 14db877c..e77ad66f 100644 --- a/tests/test_transforms.py +++ b/tests/test_transforms.py @@ -329,17 +329,17 @@ class BatchTransformTestCase(TestCase): for test_history in [algo.history_return_price_class, algo.history_return_price_decorator]: np.testing.assert_array_equal( - range(4, 10), + range(2, 8), test_history[2].values.flatten() ) np.testing.assert_array_equal( - range(4, 10), + range(2, 8), test_history[3].values.flatten() ) np.testing.assert_array_equal( - range(6, 14), + range(4, 12), test_history[4].values.flatten() ) @@ -352,4 +352,5 @@ class BatchTransformTestCase(TestCase): expected_item = ((1, ), {'kwarg': 'str'}) self.assertEqual( algo.history_return_args, - [None, None, expected_item, expected_item, expected_item]) + [None, None, expected_item, expected_item, + expected_item, expected_item]) diff --git a/zipline/gens/tradesimulation.py b/zipline/gens/tradesimulation.py index 8a702fbf..79bc3f02 100644 --- a/zipline/gens/tradesimulation.py +++ b/zipline/gens/tradesimulation.py @@ -132,7 +132,9 @@ class AlgorithmSimulator(object): self.order_book = order_book self.algo = algo - self.algo_start = algo_start + self.algo_start = algo_start.replace(hour=0, minute=0, + second=0, + microsecond=0) # Monkey patch the user algorithm to place orders in the # TransactionSimulator's order book and use our logger.