mirror of
https://github.com/wassname/catalyst.git
synced 2026-08-18 11:50:11 +08:00
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:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user