Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

KeyError: 'the label [2011-01-03 00:00:00+00:00] is not in the [index]' #2041

Closed
HwijaeSon opened this issue Dec 5, 2017 · 5 comments
Closed

Comments

@HwijaeSon
Copy link

Dear Zipline Maintainers,

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

Environment

  • Operating System: Ubuntu 16.04
  • Python Version: python 3.5.4
  • Python Bitness: 64
  • How did you install Zipline: conda install -c Quantopian zipline
  • Python packages:
    _nb_ext_conf 0.4.0 py35_1
    alembic 0.7.7 py35_0 Quantopian
    anaconda-client 1.6.6 py35h6b90917_0
    asn1crypto 0.23.0 py35h4ab26a5_0
    bcolz 0.12.1 np111py35_0 Quantopian
    bleach 2.1.1 py35hd5e75dd_0
    bottleneck 1.2.1 py35he1b16f1_0
    bzip2 1.0.6 h6d464ef_2
    ca-certificates 2017.08.26 h1d4fec5_0
    certifi 2017.11.5 py35h9749603_0
    cffi 1.11.2 py35hc7b2db7_0
    chardet 3.0.4 py35hb6e9ddf_1
    click 6.7 py35h353a69f_0
    clyent 1.2.2 py35h491ffcb_1
    contextlib2 0.5.5 py35h6690dba_0
    cryptography 2.1.4 py35hbeb2da1_0
    cyordereddict 0.2.2 py35_0 Quantopian
    cython 0.27.3 py35h6cdc64b_0
    decorator 4.1.2 py35h3a268aa_0
    empyrical 0.3.3 py35_0 Quantopian
    entrypoints 0.2.3 py35h48174a2_2
    gmp 6.1.2 h6c8ec71_1
    hdf5 1.10.1 h9caa474_1
    html5lib 0.999999999 py35h0543385_0
    idna 2.6 py35h8605a33_1
    intel-openmp 2018.0.0 hc7b2577_8
    intervaltree 2.1.0 py35_0 Quantopian
    ipykernel 4.6.1 py35h29d130c_0
    ipython 6.2.1 py35hd850d2a_1
    ipython_genutils 0.2.0 py35hc9e07d0_0
    ipywidgets 7.0.5 py35h8147dc1_0
    jedi 0.11.0 py35h48b7ba3_0
    jinja2 2.10 py35h480ab6d_0
    jsonschema 2.6.0 py35h4395190_0
    jupyter_client 5.1.0 py35h2bff583_0
    jupyter_core 4.4.0 py35ha89e94b_0
    libedit 3.1 heed3624_0
    libffi 3.2.1 hd88cf55_4
    libgcc-ng 7.2.0 h7cc24e2_2
    libgfortran 3.0.0 1
    libgfortran-ng 7.2.0 h9f7466a_2
    libsodium 1.0.15 hf101ebd_0
    libstdcxx-ng 7.2.0 h7a57d05_2
    logbook 0.12.5 py35_0 Quantopian
    lru-dict 1.1.4 py35_0 Quantopian
    lzo 2.10 h49e0be7_2
    mako 1.0.7 py35h69899ea_0
    markupsafe 1.0 py35h4f4fcf6_1
    mistune 0.8.1 py35h9251d8c_0
    mkl 2017.0.4 h4c4d0af_0
    multipledispatch 0.4.9 py35h2ff591a_0
    nb_anacondacloud 1.4.0 py35_0
    nb_conda 2.2.1 py35hccc8299_0
    nb_conda_kernels 2.1.0 py35_0
    nbconvert 5.3.1 py35hc5194e3_0
    nbformat 4.4.0 py35h12e6e07_0
    nbpresent 3.0.2 py35h9c03491_1
    ncurses 6.0 h9df7e31_2
    networkx 2.0 py35hc690e10_0
    notebook 5.2.2 py35he644770_0
    numexpr 2.6.2 np111py35_0
    numpy 1.11.3 py35_0
    openssl 1.0.2m h26d622b_1
    pandas 0.18.1 np111py35_0
    pandas-datareader 0.5.0 py35_0
    pandoc 1.19.2.1 hea2e7c5_1
    pandocfilters 1.4.2 py35h1565a15_1
    parso 0.1.0 py35ha74fa24_0
    patsy 0.4.1 py35h51b66d5_0
    pexpect 4.3.0 py35hf410859_0
    pickleshare 0.7.4 py35hd57304d_0
    pip 9.0.1 py35h7e7da9d_4
    prompt_toolkit 1.0.15 py35hc09de7a_0
    ptyprocess 0.5.2 py35h38ce0a3_0
    pycparser 2.18 py35h61b3040_1
    pygments 2.2.0 py35h0f41973_0
    pyopenssl 17.5.0 py35h4f8b8c8_0
    pysocks 1.6.7 py35h6aefbb0_1
    pytables 3.4.2 py35hfa98db7_2
    python 3.5.4 h417fded_24
    python-dateutil 2.6.1 py35h90d5b31_1
    pytz 2017.3 py35hb13c558_0
    pyyaml 3.12 py35h46ef4ae_1
    pyzmq 16.0.3 py35ha889422_0
    readline 7.0 ha6073c6_4
    requests 2.18.4 py35hb9e6ad1_1
    requests-file 1.4.1 py35_0
    requests-ftp 0.3.1 py35_0
    scipy 0.19.0 np111py35_0
    setuptools 36.5.0 py35ha8c1747_0
    simplegeneric 0.8.1 py35h2ec4104_0
    six 1.11.0 py35h423b573_1
    sortedcontainers 1.5.7 py35h683703c_0
    sqlalchemy 1.1.13 py35h4911131_0
    sqlite 3.20.1 hb898158_2
    statsmodels 0.8.0 py35haa9d50b_0
    terminado 0.6 py35hce234ed_0
    testpath 0.3.1 py35had42eaf_0
    tk 8.6.7 hc745277_3
    toolz 0.8.2 py35h90f1797_0
    tornado 4.5.2 py35hf879e1d_0
    traitlets 4.3.2 py35ha522a97_0
    urllib3 1.22 py35h2ab6e29_0
    wcwidth 0.1.7 py35hcd08066_0
    webencodings 0.5.1 py35hb6cf162_1
    wheel 0.30.0 py35hd3883cf_1
    widgetsnbextension 3.0.8 py35h84cb72a_0
    xz 5.2.3 h55aa19d_2
    yaml 0.1.7 had09818_2
    zeromq 4.2.2 hbedb6e5_2
    zipline 1.1.1 np111py35_0 Quantopian
    zlib 1.2.11 ha838bed_2

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

zipline run -f example.py --start 2000-1-1 --end 2014-1-1 -o buyapple_out.pickle
on the terminal, it ends up with same error message :

KeyError: 'the label [2000-01-03 00:00:00+00:00] is not in the [index]'

or

KeyError: 'the label [2011-01-03 00:00:00+00:00] is not in the [index]'

for different time period..

Description of Issue

  • What did you expect to happen?
  • What happened instead?

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

Reproduction Steps

...

What steps have you taken to resolve this already?

...

Anything else?

...

Sincerely,
$ whoami
Any help would be appreciated..

@freddiev4
Copy link
Contributor

Hi @HwijaeSon can you try running the latest zipline master branch?

You can install it via:

git clone git@github.com:quantopian/zipline.git
pip install zipline/

@iamjillsanluis
Copy link

iamjillsanluis commented Dec 31, 2017

I too am getting this error when I run

zipline run -f /home/vagrant/trade_algos/experiments/quick_start.py --start 2011-1-1 --end 2012-1-1 -o dma.pickle

My error is KeyError: 'the label [2011-10-10 00:00:00+00:00] is not in the [index]'

And KeyError: 'the label [2012-10-08 00:00:00+00:00] is not in the [index]' for the command below

zipline run -f /home/vagrant/trade_algos/experiments/quick_start.py --start 2012-1-1 --end 2013-1-1 -o dma.pickle

After digging, I noticed that the data is truly missing in the series.

(Pdb++) self._precalculated_series[190:200]
2011-10-04 00:00:00+00:00    0.02563
2011-10-05 00:00:00+00:00    0.02563
2011-10-06 00:00:00+00:00    0.02563
2011-10-07 00:00:00+00:00    0.02563
2011-10-11 00:00:00+00:00    0.02563
2011-10-12 00:00:00+00:00    0.02563
2011-10-13 00:00:00+00:00    0.02563
2011-10-14 00:00:00+00:00    0.02563
2011-10-17 00:00:00+00:00    0.02563
2011-10-18 00:00:00+00:00    0.02563
dtype: float64
...

Pretty new to zipline, but curious if there is some fill strategy for missing data in zipline.

@newzapster
Copy link

Chiming in to raise the same problem.

Tried overriding the benchmark with the same series in the bundle - a new error came up: "KeyError: 'the label [open] is not in the [index]'"

Checked the data and found that the day is missing indeed. (Benchmark has the date) However, it would be much better if the zipline could skip that day simply.

Or, is there any way to turn off the benchmark?

@HwijaeSon
Copy link
Author

HwijaeSon commented Jan 16, 2018

Make a new anaconda environment with python version 3.5

$ conda create -n myenv python=3.5

install zipline

& (myenv) pip install zipline

Change files according to the issue #2031 (181a0f7)

save

  • from zipline.api import order, record, symbol

def initialize(context): pass

def handle_data(context, data): order(symbol('AAPL'), 10) record(AAPL=data.current(symbol('AAPL'), 'price')) *

as buyapple.py

zipline ingest

run the buyapple.py via

$ zipline run -f ../../zipline/examples/buyapple.py --start 2016-1-1 --end 2017-1-1 -o buyapple_out.pickle

( Due to recent change of datareader, we can only use about past 5 years data)

This works for me!

@freddiev4
Copy link
Contributor

Closing this as this should be fixed in the latest release of zipline. You can see the release notes here Feel free to update to 1.2.0 with either:

pip install -U zipline

or

conda update zipline -c quantopian

If you're still experiencing issues, please reopen this or open a new issue 🙂

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants