Problems with history function in very simple algorithm

514 views
Skip to first unread message

Tobias Schlottke

unread,
Jul 18, 2015, 3:46:19 AM7/18/15
to zip...@googlegroups.com
Hi there,

I have a problem with zipline and as I am not a python pro, I can't really see the light at the end of the tunnel.
The algo is pretty straight forward (200d vs 36d MAVG) and working with most stocks (for example AAPL).
As soon as I switch to a european stock (EXS1.DE), it's no longer working and produces

EXS1.DE
going long on Equity(0 [EXS1.DE]) 500 for 53.315 each

IndexError: index 0 is out of bounds for axis 0 with size 0

It comes from line 
short_mavg = history(36, '1d', 'price').mean()[sym]

and I nailed it down to
zipline/history/history_container.pyc in ffill_buffer_from_prior_values(freq, field, buffer_frame, digest_frame, pv_frame, raw):

nan_sids = pd.isnull(buffer_values[0])

I printed out all the historic prices and they are all there.

Any ideas?

Thanks for your help!

Best,

Tobias

algo.py

Ken Hersey

unread,
Jul 23, 2015, 7:50:09 PM7/23/15
to Zipline Python Opensource Backtester, tobias.s...@gmail.com
Yes, this is a known challenge. I wouldn't say it's a bug (although it's filed as such), but it is basically caused by a difference in the data input not matching the default (US) trading calendar. There are other trading calendars defined for other countries, so your fix may be as simple as that - switch to one of the other predefined calendars. 

If you mix countries in a portfolio though, you'd need a custom calendar, and I have not been successful at that yet.

for more info. 

If you don't use the history function, you might be able to work around it, but I suspect the benchmark results may be challenged (just a hypothesis).
See issue 447 description link above for workarounds mentioned, while folks are considering guidance.

HTH,
Ken
Reply all
Reply to author
Forward
0 new messages