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.
This commit is contained in:
Eddie Hebert
2013-04-29 14:50:52 -04:00
parent 38ae8bbb67
commit 06a01b1469
+8 -2
View File
@@ -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: