Back to Community
the label [label] is not in the [index]

Hello All,

I am trying to get started with Zipline. I am running it offline. I had some success trying some of the basic algorithms (such as mavg related) to run a backtest. However, whatever I do I cannot go back more than about a year ago. I tried with various data sources ("quantopian-quandl", "quandl", Yahoo, reading from CSV). The result is always the same and for some reason I cannot go back more than about one year ago.

I am also adding the actual code and output to pastebin as this forum messes up the formatting: ###

$ python Traceback (most recent call last):
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1395, in has_valid_type
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1390, in error
(key, self.obj.
KeyError: 'the label [2016-09-16 00:00:00+00:00] is not in the [index]'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "", line 29, in
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/utils/", line 360, in run_algorithm
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/utils/", line 179, in run
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/", line 709, in run
for perf in self.get_generator():
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/gens/", line 230, in transform
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/gens/", line 190, in handle_benchmark
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/zipline/sources/", line 75, in get_value
return self._precalculated_series.loc[dt]
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1296, in _
return self.getitem_axis(key, axis=0)
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1466, in getitem_axis
self._has_valid_type(key, axis)
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1403, in _has
File "/home/username/anaconda3/envs/zipline/lib/python3.4/site-packages/pandas/core/", line 1390, in error
(key, self.obj._get_axis_name(axis)))
KeyError: 'the label [2016-09-16 00:00:00+00:00] is not in the [index]'
(zipline) [email protected]:~/projects/zipline$

(zipline) [email protected]:~/projects/zipline$ cat from zipline.api import symbol
from zipline import run_algorithm

import pandas as pd
import os
from datetime import datetime
import pytz

def initialize(context):

context.asset = symbol('AAPL')


def handle_data(context, data):

tz = pytz.timezone("US/Mountain")
start = datetime(2016, 9, 16, tzinfo=tz)
end = datetime(2017, 9, 2, tzinfo=tz)

perfData = run_algorithm(start=start,

(zipline) [email protected]:~/projects/zipline$

However if I modify the data to the 17th of September 2017 I get:
(zipline) [email protected]:~/projects/zipline$ grep start start = datetime(2016, 9, 17, tzinfo=tz)
perfData = run_algorithm(start=start,
(zipline) [email protected]:~/projects/zipline$ python (zipline) [email protected]:~/projects/zipline$

I am not expecting any output as I changed all the functions to just "pass", while trying to debug this. So basically one day difference makes the script give an error or run successfully. This is also one year ago from today, so that likely has significance.

Please also note I am not even passing in any "symbol" anywhere. I had specific symbols before, but found the error is the same whether I have a symbol /asset or not.

What is going on with this? Anybody?



(zipline) [email protected]:~$ conda list |egrep "python|zipline|pandas"

packages in environment at /home/username/anaconda3/envs/zipline:

pandas 0.18.1 np111py34_0
pandas-datareader 0.2.1 py34_0
python 3.4.5 0
python-dateutil 2.6.1 py34_0
zipline 1.1.1 np111py34_0 Quantopian
(zipline) [email protected]:~$

3 responses

Have the same issue although no dates seems to work for me.

Try posting here hopefully the devs. can assist.

Thanks Rohan, I am glad to have had at least the one response! I am not sure our problems are quite the same, if no dates work for you.

I will try posting to github.