MAINT: Re-enable algorithms which omit initialize method.

Though defining the `initialize` method may end up being explicitly
required, in the meantime prevent existing algorithms from crashing
by providing a noop function when `initialize` is not defined.
This commit is contained in:
Eddie Hebert
2014-02-20 13:50:03 -05:00
parent 170fe97631
commit 57c56351e9
+5
View File
@@ -160,6 +160,8 @@ class TradingAlgorithm(object):
# functions.
self.algoscript = kwargs.pop('script', None)
self._initialize = None
if self.algoscript is not None:
self.ns = {}
exec_(self.algoscript, self.ns)
@@ -179,6 +181,9 @@ class TradingAlgorithm(object):
self._initialize = kwargs.pop('initialize')
self._handle_data = kwargs.pop('handle_data')
if self._initialize is None:
self._initialize = lambda x: None
# an algorithm subclass needs to set initialized to True when
# it is fully initialized.
self.initialized = False