diff --git a/zipline/MESSAGES.py b/zipline/MESSAGES.py index 2c67395b..6d7bd2da 100644 --- a/zipline/MESSAGES.py +++ b/zipline/MESSAGES.py @@ -37,4 +37,10 @@ Please use PerShare or PerTrade. You attempted to override commission after the simulation has \ started. You may only call override_commission in your initialize \ method. +""".strip() + + CALL_RECORD_VARIABLES_POST_INIT = """ +You attempted to register recorded variables after the simulation has \ +started. You may only call record_variables in your initialize \ +method. """.strip() diff --git a/zipline/algorithm.py b/zipline/algorithm.py index d950e8c2..625459df 100644 --- a/zipline/algorithm.py +++ b/zipline/algorithm.py @@ -286,6 +286,9 @@ class TradingAlgorithm(object): if isinstance(names, basestring): names = [names] + if self.initialized: + raise Exception(MESSAGES.ERRORS.CALL_RECORD_VARIABLES_POST_INIT) + self._registered_vars.update(set(names)) @property