BUG: Forward initialize args and kwargs to user-defined function.

The initialize method of TradingAlgorithm no longer accepts and
silently ignores args and kwargs, but instead forwards them
to the user-defined function referenced by self._initialize.

To avoid passing unexpected arguments to self._initialize, the
following additional adjustments are made:

 - pop 'namespace' from the kwargs supplied to TradingAlgorithm
   rather than simply get()ing it

 - do not pass an AssetFinder to the TradingAlgorithm in
   test_modelling_algo.py, as this has been deprecated and will
   cause self._initialize to fail
This commit is contained in:
Thomas Wiecki
2015-08-25 13:25:54 +02:00
committed by Stewart Douglas
parent a6e677a1d7
commit 6f2e1672d7
2 changed files with 2 additions and 5 deletions
-3
View File
@@ -32,7 +32,6 @@ from zipline.api import (
add_factor,
get_datetime,
)
from zipline.assets import AssetFinder
# from zipline.data.equities import USEquityPricing
from zipline.data.ffc.loaders.us_equity_pricing import (
BcolzDailyBarReader,
@@ -87,7 +86,6 @@ class FFCAlgorithmTestCase(TestCase):
)
cls.env = trading.TradingEnvironment()
cls.env.write_data(equities_df=asset_info)
cls.asset_finder = AssetFinder(cls.env.engine)
cls.tempdir = tempdir = TempDirectory()
tempdir.create()
try:
@@ -210,7 +208,6 @@ class FFCAlgorithmTestCase(TestCase):
before_trading_start=before_trading_start,
data_frequency='daily',
ffc_loader=self.ffc_loader,
asset_finder=self.asset_finder,
start=self.dates[max(window_lengths)],
end=self.dates[-1],
)
+2 -2
View File
@@ -177,7 +177,7 @@ class TradingAlgorithm(object):
self.account_controls = []
self._recorded_vars = {}
self.namespace = kwargs.get('namespace', {})
self.namespace = kwargs.pop('namespace', {})
self._platform = kwargs.pop('platform', 'zipline')
@@ -336,7 +336,7 @@ class TradingAlgorithm(object):
functions.
"""
with ZiplineAPI(self):
self._initialize(self)
self._initialize(self, *args, **kwargs)
def before_trading_start(self, data):
if self._before_trading_start is None: