zipline: Tutorial buyapple.py fails in python 2.7.10
running buyapple.py fails in python 2.7.10 but runs in python 3.4.3 for zipline 8.0rc. The part of code that fails is data[symbol('AAPL')]
found in
record(AAPL=data[symbol('AAPL')].price)
the error is
Traceback (most recent call last):
File "C:\python2710_64\Scripts\run_algo.py", line 4, in <module>
__import__('pkg_resources').run_script('zipline==0.8.0rc1', 'run_algo.py')
File "C:\Python2710_64\lib\site-packages\pkg_resources\__init__.py", line 729, in run_script
self.require(requires)[0].run_script(script_name, ns)
File "C:\Python2710_64\lib\site-packages\pkg_resources\__init__.py", line 1642, in run_script
exec(code, namespace, namespace)
File "c:\python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\EGG-INFO\scripts\run_algo.py", line 23, in <module>
run_pipeline(print_algo=True, **parsed)
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\cli.py", line 246, in run_pipeline
perf = algo.run(source, overwrite_sim_params=overwrite_sim_params)
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.py", line 529, in run
for perf in self.gen:
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 120, in transform
self.algo.instant_fill,
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 314, in _process_snapshot
new_orders = self._call_handle_data()
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\gens\tradesimulation.py", line 343, in _call_handle_data
self.simulation_dt,
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.py", line 194, in handle_data
event.handle_data(context, data, dt)
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\utils\events.py", line 212, in handle_data
self.callback(context, data)
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\algorithm.py", line 306, in handle_data
self._handle_data(self, data)
File "buyapple.py", line 26, in handle_data
record(AAPL=data[symbol('AAPL')].price)
File "C:\Python2710_64\lib\site-packages\zipline-0.8.0rc1-py2.7-win-amd64.egg\zipline\protocol.py", line 518, in __getitem__
return self._data[name]
KeyError: Equity(0, symbol='AAPL', asset_name='', exchange='', start_date=None, end_date=None, first_traded=None)
Environment: Windows 7 64 bit, Python 3.4, Python 2.7, zipline 0.8.0rc Appears to be with zipline.protocol.BarData and zipline.assets._assets.Equity
Kind regards
David Bieber
About this issue
- Original URL
- State: closed
- Created 9 years ago
- Comments: 45 (16 by maintainers)
To add to AnthonyFJGarner’s post on Sep 22:
Thank you Zigguratti, your procedure has worked for me.
Lo and behold, this time all the uninstalled dependencies were installed and any incorrect version was uninstalled and then reinstalled with the correct version. 3. buyapple.py and the code I wrote above now work.
Here is the point for the Quantopian guys:
Your set up instructions are a hopeless, total mess. Not really your fault since you don’t aim to deal with morons such as myself. But my god you could save yourself some problems if you exercised some precision in your instructions and explanations.
I am an ex City securities lawyer so absolute precision was drummed into me many years ago. I hope the above may be of help to someone. The problems are legion for someone new to this game and I reiterate my very strong recommendation that you guys (for your own sake) give a much easier and more explicit set of instructions.
I was initially fooled into downloading Python 2.7 because I thought I had to use Zipline 0.7.0 https://pypi.python.org/pypi/zipline
I then realised Zipline 0.7.0 was an outdated and (for my purposes) hopeless version and so eventually stumbled onto the ability to use the very latest version which I update regularly from github.
I never realised that changing from Python 2.7 to 3.4 would solve my problems…but that’s probably because I’m just dumb.
You never know, I might just be able to get on with developing systems in Zipline now…