quantopian / zipline

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

all examples are broken in v0.8.4 #854

Closed FayolChang closed 8 years ago

FayolChang commented 8 years ago

Traceback (most recent call last): File "C:/Users/phil.zhang/dev/zipline/zipline/examples/dual_moving_average.py", line 125, in results = algo.run(data) File "C:\Users\phil.zhang\dev\zipline\zipline\algorithm.py", line 592, in run for perf in self.gen: File "C:\Users\phil.zhang\dev\zipline\zipline\gens\tradesimulation.py", line 121, in transform self.algo.instant_fill, File "C:\Users\phil.zhang\dev\zipline\zipline\gens\tradesimulation.py", line 298, in _process_snapshot new_orders = self._call_handle_data() File "C:\Users\phil.zhang\dev\zipline\zipline\gens\tradesimulation.py", line 327, in _call_handle_data self.simulation_dt, File "C:\Users\phil.zhang\dev\zipline\zipline\utils\events.py", line 209, in handle_data context.trading_environment, File "C:\Users\phil.zhang\dev\zipline\zipline\utils\events.py", line 228, in handle_data self.callback(context, data) File "C:\Users\phil.zhang\dev\zipline\zipline\algorithm.py", line 365, in handle_data self._handle_data(self, data) File "C:/Users/phil.zhang/dev/zipline/zipline/examples/dual_moving_average.py", line 60, in handle_data record(AAPL=data[context.sym].price, File "C:\Users\phil.zhang\dev\zipline\zipline\protocol.py", line 528, in getitem return self._data[name] KeyError: Equity(0, symbol=u'AAPL', asset_name=None, exchange=None, start_date=Timestamp('1970-01-01 00:00:00+0000', tz='UTC'), end_date=Timestamp('2116-02-20 23:53:38.427387903+0000', tz='UTC'), first_traded=None)

FayolChang commented 8 years ago

It is very strange, In the company it is the problem, but when I am at home, It works fine.

However, I am still curious about why Equity instance could be used as a key, because self._data use integer as key.

richafrank commented 8 years ago

Hi @FayolChang! Could you have installed zipline differently between the two environments? We haven't released zipline 0.8.4 yet, so I wonder what version(s) you're running. I just ran that example successfully from source on

Python 2.7.10 (default, Aug 25 2015, 10:31:04) 
[GCC 4.2.1 Compatible Apple LLVM 6.1.0 (clang-602.0.53)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import zipline
>>> zipline.__version__
'v0.8.3+66.g0cdd88a'
richafrank commented 8 years ago

I notice it's the same symptom as https://github.com/quantopian/zipline/issues/650.

FayolChang commented 8 years ago

Hi, @richafrank , thanks for the reply. I am using the source code from github, zipline version is 'v0.8.3+67.g5600b8d.dirty'.

the problem happened on the windows 7. I pulled the latest source code from this repo. (UTC 2:14:58 , 2015-11-19) To test on other machines, I installed ubuntu 12.04 on an virtural machine. It works fine. It also works fine on my mac.

the python environment is anaconda 2.7.10 on these operating systems.

It is easy to understand why it raise KeyError exception because the key passed is an Equity instance, not an Integer. I could not understand why it works on mac and ubuntu.

richafrank commented 8 years ago

The discrepancy is really odd. Since it's windows-only, sounds like it is the same issue as #650 then. Let's close this and continue with the conversation over there, so we're not duplicating effort or discussion.