quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.52k stars 4.71k forks source link

Algorithm Initialization Logic Error #1167

Open softwaregravy opened 8 years ago

softwaregravy commented 8 years ago

Dear Zipline Maintainers,

Before I tell you about my issue, let me describe my environment:

Environment

Running on Quantopian in a notebook

Now that you know a little about me, let me tell you about the issue I am having:

Description of Issue

TypeError: <lambda>() got an unexpected keyword argument 'initialize'

Here is how you can reproduce this issue on your machine:

Reproduction Steps

  1. call the following: TradingAlgorithm(initialize=initialize, data_frequency='minute')

    What steps have you taken to resolve this already?

    • added an empty handle_data param to the method

      Anything else?

Full stack trace

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-6-9cf8f82b0e75> in <module>()
     60         # compute the performance stats for this backtest run and then append to a dataframe
     61         # that is accumulating all of the backtest performance stats
---> 62         perf_algo = algo_obj.run(data.transpose(2,1,0))
     63         perf_returns = perf_algo.returns
     64         perf_stats_df = perf_stats( perf_returns ).T

/build/src/qexec_repo/zipline_repo/zipline/algorithm.pyc in run(self, source, overwrite_sim_params, benchmark_return_source)
    574 
    575         # create zipline
--> 576         self.gen = self._create_generator(self.sim_params)
    577 
    578         # Create history containers

/build/src/qexec_repo/zipline_repo/zipline/algorithm.pyc in _create_generator(self, sim_params, source_filter)
    463 
    464         if not self.initialized:
--> 465             self.initialize(*self.initialize_args, **self.initialize_kwargs)
    466             self.initialized = True
    467 

/build/src/qexec_repo/zipline_repo/zipline/algorithm.pyc in initialize(self, *args, **kwargs)
    353         """
    354         with ZiplineAPI(self):
--> 355             self._initialize(self, *args, **kwargs)
    356 
    357     def before_trading_start(self, data):

TypeError: <lambda>() got an unexpected keyword argument 'initialize'

Sincerely, $ whoami

llllllllll commented 8 years ago

Sorry about the trouble. This is a known issue with the TrandingAlgorithm constructor. Your workaround of passing handle_data=None is correct. We are reworking some of the public entry points to zipline which should fix this particular issue.