From b33243da63b663a46ce04feda7333df64e8c7d5b Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Thu, 9 May 2013 03:44:51 -0400 Subject: [PATCH] BUG: Ensure that data_frequency set on algo is set on sim_params. Set the data_frequency member of an algorithm on the sim_params configuration object. Though the extra setting is slightly redundant, it is needed to ensure that the same data_frequency is used throughout. Should fix a bug where an algo that was intended to be run in minute mode was operating as if it were daily in performance. Possible TODO: Remove data_frequency as a param to TradingAlgorithm, in favor of only being a property of sim_params. --- zipline/algorithm.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/zipline/algorithm.py b/zipline/algorithm.py index 6f26cdad..64d552fc 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -117,6 +117,8 @@ class TradingAlgorithm(object): self.capital_base = kwargs.get('capital_base', DEFAULT_CAPITAL_BASE) self.sim_params = kwargs.pop('sim_params', None) + if self.sim_params: + self.sim_params.data_frequency = self.data_frequency self.blotter = kwargs.pop('blotter', Blotter()) @@ -202,6 +204,8 @@ class TradingAlgorithm(object): processed by the zipline, and False for those that should be skipped. """ + sim_params.data_frequency = self.data_frequency + self.data_gen = self._create_data_generator(source_filter, sim_params) self.perf_tracker = PerformanceTracker(sim_params)