From 06a01b146957ea333ca4b6c27b7652dfab069a2a Mon Sep 17 00:00:00 2001 From: Eddie Hebert Date: Mon, 29 Apr 2013 14:50:52 -0400 Subject: [PATCH] BUG: Explicitly add support for refresh period of 0. In the previous implementation of batch transform it happened that a window_length of `0` caused the transform to update on every bar, for the time being that behavior should be retained, though the new rolling implementation more correctly aligns to the term of 'period' so a period of 1 would achieve the same effect. --- zipline/transforms/utils.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/zipline/transforms/utils.py b/zipline/transforms/utils.py index c8a431e1..59f40cb8 100644 --- a/zipline/transforms/utils.py +++ b/zipline/transforms/utils.py @@ -463,11 +463,17 @@ class BatchTransform(object): ################################################# # Determine whether we should call the transform + # 0. Support historical/legacy usage of '0' signaling, + # 'update on every bar' + if self.refresh_period == 0: + period_signals_update = True + else: # 1. Is the refresh period over? - period_over = self.trading_days_total % self.refresh_period == 0 + period_signals_update = ( + self.trading_days_total % self.refresh_period == 0) # 2. Have the args or kwargs been changed since last time? args_updated = args != self.last_args or kwargs != self.last_kwargs - recalculate_needed = args_updated or (period_over and + recalculate_needed = args_updated or (period_signals_update and self.updated) if recalculate_needed: