zipline 1.3.0 JSONDecodeError

Created on 17 Jun 2019  ·  21Comments  ·  Source: quantopian/zipline

Dear Zipline Maintainers,

Environment

  • Operating System: Ubuntu 18.04.2(Linux gcp-vm-001 4.15.0-1033-gcp #35-Ubuntu SMP Fri May 17 13:27:54 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux)
  • Python Version: Python 3.5.7
  • Python Bitness: 64 bit
  • How did you install Zipline: 'pip install zipline'
  • Python packages:
    alembic==1.0.10
    attrs==19.1.0
    backcall==0.1.0
    bcolz==0.12.1
    bleach==3.1.0
    Bottleneck==1.2.1
    certifi==2019.3.9
    chardet==3.0.4
    Click==7.0
    contextlib2==0.5.5
    cycler==0.10.0
    cyordereddict==1.0.0
    Cython==0.29.9
    decorator==4.4.0
    defusedxml==0.6.0
    empyrical==0.5.0
    entrypoints==0.3
    idna==2.8
    intervaltree==3.0.2
    ipykernel==5.1.1
    ipython==7.5.0
    ipython-genutils==0.2.0
    ipywidgets==7.4.2
    jedi==0.13.3
    Jinja2==2.10.1
    jsonschema==3.0.1
    jupyter==1.0.0
    jupyter-client==5.2.4
    jupyter-console==6.0.0
    jupyter-core==4.4.0
    kiwisolver==1.1.0
    Logbook==1.4.3
    lru-dict==1.1.6
    lxml==4.3.3
    Mako==1.0.10
    MarkupSafe==1.1.1
    matplotlib==3.0.3
    mistune==0.8.4
    mock==3.0.5
    multipledispatch==0.6.0
    nbconvert==5.5.0
    nbformat==4.4.0
    networkx==1.11
    notebook==5.7.8
    numexpr==2.6.9
    numpy==1.16.4
    pandas==0.22.0
    pandas-datareader==0.7.0
    pandocfilters==1.4.2
    parso==0.4.0
    patsy==0.5.1
    pexpect==4.7.0
    pickleshare==0.7.5
    prometheus-client==0.6.0
    prompt-toolkit==2.0.9
    ptyprocess==0.6.0
    Pygments==2.4.2
    pyparsing==2.4.0
    pyrsistent==0.15.2
    python-dateutil==2.8.0
    python-editor==1.0.4
    pytz==2019.1
    pyzmq==18.0.1
    qtconsole==4.5.1
    requests==2.22.0
    requests-file==1.4.3
    scipy==1.3.0
    Send2Trash==1.5.0
    six==1.12.0
    sortedcontainers==2.1.0
    SQLAlchemy==1.3.4
    statsmodels==0.9.0
    tables==3.5.2
    terminado==0.8.2
    testpath==0.4.2
    toolz==0.9.0
    tornado==6.0.2
    trading-calendars==1.8.0
    traitlets==4.3.2
    urllib3==1.25.3
    wcwidth==0.1.7
    webencodings==0.5.1
    widgetsnbextension==3.4.2
    wrapt==1.11.1
    zipline==1.3.0

Description of Issue

My zipline back testing script worked well 2 or 3 days ago.
But, last weekend, the script showed "JSONDecodeError".
You can see the detail error and source code in the attached text files.

Reproduction Steps

  1. Just re-run the script
    2.
    3.
    ...

What steps have you taken to resolve this already?

I called the "TradingAlgorithm()" in the ipython console without or with parameters. It showed same error always.
In [4]: algo=TradingAlgorithm() or
In [5]: TradingAlgorithm() or
In [6]: algo = TradingAlgorithm(sim_params=create_simulation_parameters(capital_base=1000000000,trading_calendar=xkrx),initialize=initialize,handle_data=handle_data,trading_calendar=xkrx)

Anything else?

I think that this issue maybe related to the following issue.
https://github.com/quantopian/zipline/issues/2480

Although, I referenced the this issue, I am not using IEX as a data source. Attached "DataDownloader.txt" is the download script and using Yahoo.

Sincerely,
SeungYong
zipline-json-error.txt
zipline-MR.txt
DataDownloader.txt

Benchmark

Most helpful comment

The error is due benchmark.py needing to download benchmark SPY data from IEX, and the API for IEX has changed so that you now need to get a free API key and add this to the zipline benckmark.py file. You can also use pandas Yahoo data - see: https://stackoverflow.com/questions/56957791/getting-jsondecodeerror-expecting-value-line-1-column-1-char-0-with-python

The IEX token solution worked for me:

  1. Signup to the free IEX package at https://iexcloud.io/ and copy the API-token (key).
  2. Locate the benckmark.py file in your python zipline distribution. Mine was found at:
    anaconda3pkgszipline-1.3.0-np114py35_0Libsite-packagesziplinedata
  3. In benchmark.py, replace "r=requests.get..." with:
    IEX_API_KEY = "YOUR-IEX-TOKEN"
    r = requests.get(
    "https://cloud.iexapis.com/stable/stock/{}/chart/5y?chartCloseOnly=True&token={}".format(symbol, IEX_API_KEY)
    )
  4. Curse that this simple fix wasn't mentioned in the tutorial.

All 21 comments

Hello MarikoKujo ,

Thank you for your comment. I really appreciate for your help.
Unfortunately, it doesn't works. I should wait the fix for this and test
with different way.

Thanks again,
SeungYong

2019년 6월 18일 (화) 오전 5:20, MarikoKujo notifications@github.com님이 작성:

Hi SeungYong,

Came from #2480 https://github.com/quantopian/zipline/issues/2480. My
error message is the same as yours.
I think the issue is related to downloading process of benchmark data.
Whatever your custom data source is, as long as you are using default
benchmark data, this error occurs.
If you are using csvdir bundle or a custom data bundle, one workaround is
setting benckmark to your own asset in def initialize(context), by
calling set_benchmark(). For example,

from zipline.api import set_benchmark, symbol

def initialize(context):
set_benchmark(symbol('AAPL'))

It works for me on custom data bundle, minute frequency csv data, but the
drawback is that it slows down my backtests significantly. Still, I am
looking for a way to run backtests without benchmark.


You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
https://github.com/quantopian/zipline/issues/2481?email_source=notifications&email_token=AE4A7PQYFHPEEDHMAGA7MP3P27WXNA5CNFSM4HYTC3LKYY3PNVWWK3TUL52HS4DFVREXG43VMVBW63LNMVXHJKTDN5WW2ZLOORPWSZGODX4KRGA#issuecomment-502835352,
or mute the thread
https://github.com/notifications/unsubscribe-auth/AE4A7PQOMYUC5BNEP4CJUPDP27WXNANCNFSM4HYTC3LA
.

@SeungYong-Baek
Sorry for deleting my earlier reply, because I found that I mistook my cached benchmark file with a newly created one.
If you do not need benchmark in your backtests, you can try this hack.

I'm getting the same issue with python 3.5.6 and zipline 1.3.0. Any ideas? I'm using the quandl data bundle. -Thanks.

I'm getting same issue too, With Python 3.6.8
Now, When i run any command from zipline, It's got this error always.

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Same issue, trying to run zipline using jupyter notebooks

@rwuebker
@bozzlab
@jonathanmiller2
Some fix which is mentioned at the issue #2480 works for my script.
I used the IEXCLOUD API.
Thank you.

I'm getting the same issue with python 3.5.6 and zipline 1.3.0,How to reduce version installation?

Still getting this issue with Python 3.6.8 and zipline 1.3.0, so I downgraded zipline to 1.2.0, but still getting the same error with 1.2.0.

I have the same problem, tried Python 2.7 and 3.5

I have the same problem and I am using zipline 1.30 and python 2.7 (jupyter notebook).

@rwuebker
@bozzlab
@jonathanmiller2
Some fix which is mentioned at the issue #2480 works for my script.
I used the IEXCLOUD API.
Thank you.

this works!

Hey guys, I'm a bit late, but same issue with the code --

Here's my output:
JSONDecodeError: Expecting value: line 1 column 1 (char 0)

Is there ever going to be an official response to this problem?

FWIW the fixes suggested here worked for me: https://stackoverflow.com/a/58661288/3403924 (ignore step 3, though)

I tried many times and it is not working for me as well.

I'm getting same issue too, With Python 3.6.8
Now, When i run any command from zipline, It's got this error always.

simplejson.errors.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

I am having the same issue.

+1, even the sample in readme.md on github or tutorial crashes with this!!!

zipline is useless

anyone still maintains this library???

The error is due benchmark.py needing to download benchmark SPY data from IEX, and the API for IEX has changed so that you now need to get a free API key and add this to the zipline benckmark.py file. You can also use pandas Yahoo data - see: https://stackoverflow.com/questions/56957791/getting-jsondecodeerror-expecting-value-line-1-column-1-char-0-with-python

The IEX token solution worked for me:

  1. Signup to the free IEX package at https://iexcloud.io/ and copy the API-token (key).
  2. Locate the benckmark.py file in your python zipline distribution. Mine was found at:
    anaconda3pkgszipline-1.3.0-np114py35_0Libsite-packagesziplinedata
  3. In benchmark.py, replace "r=requests.get..." with:
    IEX_API_KEY = "YOUR-IEX-TOKEN"
    r = requests.get(
    "https://cloud.iexapis.com/stable/stock/{}/chart/5y?chartCloseOnly=True&token={}".format(symbol, IEX_API_KEY)
    )
  4. Curse that this simple fix wasn't mentioned in the tutorial.

But this is only for 5 year data right? If you want, on my repository I have data from 1993 to 2020, you would have to manually implement the benchmark function, but it works. (In case you want longer time frames).

Hi all, I'm going to close this in favor of the consolidated issue for the benchmark downloading problems: https://github.com/quantopian/zipline/issues/2627.

https://github.com/quantopian/zipline/pull/2642 should help now, if you're using master, but it isn't released on PyPI yet.

Feel free to ping there or to reopen this if you think there's information in this issue that's not captured in the other one.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

Monsieurvishal picture Monsieurvishal  ·  5Comments

mosfiqur-rahman picture mosfiqur-rahman  ·  4Comments

marketneutral picture marketneutral  ·  3Comments

freddiev4 picture freddiev4  ·  3Comments

richdevboston picture richdevboston  ·  4Comments