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

zipline 1.3.0 JSONDecodeError #2481

Closed
SeungYong-Baek opened this issue Jun 17, 2019 · 21 comments
Closed

zipline 1.3.0 JSONDecodeError #2481

SeungYong-Baek opened this issue Jun 17, 2019 · 21 comments

Comments

@SeungYong-Baek
Copy link

SeungYong-Baek commented Jun 17, 2019

Dear Zipline Maintainers,

Environment

  • Operating System: Ubuntu 18.04.2(Linux gcp-vm-001 4.15.0-1033-gcp Allows the capital base of an algorithm to be more easily modified. #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

...

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.
#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

@SeungYong-Baek
Copy link
Author

SeungYong-Baek commented Jun 18, 2019 via email

@MarikoKujo
Copy link

@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.

@rwuebker
Copy link

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.

@bozzlab
Copy link

bozzlab commented Jun 27, 2019

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)

@jonathanmiller2
Copy link

Same issue, trying to run zipline using jupyter notebooks

@SeungYong-Baek
Copy link
Author

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

@SongJiaxin95
Copy link

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

@jecker7
Copy link

jecker7 commented Jul 30, 2019

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.

@steviesteveston
Copy link

I have the same problem, tried Python 2.7 and 3.5

@filippo-ciceri
Copy link

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

@filippo-ciceri
Copy link

@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!

@zoakes
Copy link

zoakes commented Nov 20, 2019

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)

@daraul
Copy link
Contributor

daraul commented Jan 20, 2020

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

@zoakes
Copy link

zoakes commented Jan 20, 2020 via email

@daraul
Copy link
Contributor

daraul commented Jan 20, 2020

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

@301resa
Copy link

301resa commented Apr 10, 2020

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

@301resa
Copy link

301resa commented Apr 10, 2020

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.

@iirekm
Copy link

iirekm commented May 2, 2020

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

zipline is useless

anyone still maintains this library???

@codabulo
Copy link

codabulo commented Jun 4, 2020

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:
    \anaconda3\pkgs\zipline-1.3.0-np114py35_0\Lib\site-packages\zipline\data
  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.

@cemal95
Copy link

cemal95 commented Jun 5, 2020

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).

@richafrank
Copy link
Member

Hi all, I'm going to close this in favor of the consolidated issue for the benchmark downloading problems: #2627.

#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.

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