Quantopian's community platform is shutting down. Please read this post for more information and download your code.
Back to Community
JSONDecodeError while loading custom bundle data

I have been using zipline in local development since March this year. I can load my custom data bundle till early June fine.

After I came back from a long trip, I found out the unit test failed with following error:

Traceback (most recent call last):  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/unittest/case.py", line 59, in testPartExecutor  
    yield  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/unittest/case.py", line 605, in run  
    testMethod()  
  File "/Users/mintu/PycharmProjects/myZipline/myzipline/tests/testZigzagTrend_2014.py", line 138, in test_zigzag_trends_2014  
    bundle="ETF")  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/utils/run_algo.py", line 430, in run_algorithm  
    blotter=blotter,  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/utils/run_algo.py", line 159, in _run  
    trading_days=trading_calendar.schedule[start:end].index,  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/finance/trading.py", line 103, in __init__  
    self.bm_symbol,  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/data/loader.py", line 149, in load_market_data  
    environ,  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/data/loader.py", line 216, in ensure_benchmark_data  
    data = get_benchmark_returns(symbol)  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/zipline/data/benchmarks.py", line 35, in get_benchmark_returns  
    data = r.json()  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/site-packages/requests/models.py", line 897, in json  
    return complexjson.loads(self.text, **kwargs)  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/json/__init__.py", line 354, in loads  
    return _default_decoder.decode(s)  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/json/decoder.py", line 339, in decode  
    obj, end = self.raw_decode(s, idx=_w(s, 0).end())  
  File "/Users/mintu/anaconda3/envs/q/lib/python3.6/json/decoder.py", line 357, in raw_decode  
    raise JSONDecodeError("Expecting value", s, err.value) from None  
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

after some debug, seems like the error come from loading 5 years ago data

    start = pd.Timestamp(datetime(2014, 6, 9, tzinfo=pytz.UTC))  
    end = pd.Timestamp(datetime(2014, 6, 10, tzinfo=pytz.UTC))

Any suggestions?

Thanks in advance

6 responses

@Min
SPY IEX data is gone...
Check out:
https://github.com/quantopian/zipline/issues/2480
for some fixes.
alan

tried all of the solutions on this page, didnt work for me.

any updates on this, i get similar problems. When i run an algorithm i get this:

/anaconda3/envs/backtestproject/bin/python3.5 /Users/cemalarican/Desktop/project/test.py Traceback (most recent call last):
File "/Users/cemalarican/Desktop/project/test.py", line 52, in
perf = run_algorithm(start, end, initialize, base_capital, handle_data)
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/utils/run_algo.py", line 430, in run_algorithm
blotter=blotter,
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/utils/run_algo.py", line 159, in run
trading_days=trading_calendar.schedule[start:end].index,
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/finance/trading.py", line 103, in __init
_
self.bm_symbol,
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/data/loader.py", line 149, in load_market_data
environ,
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/data/loader.py", line 216, in ensure_benchmark_data
data = get_benchmark_returns(symbol)
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/data/benchmarks.py", line 35, in get_benchmark_returns
data = r.json()
File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/requests/models.py", line 896, in json
return complexjson.loads(self.text, **kwargs)
File "/anaconda3/envs/backtestproject/lib/python3.5/json/init.py", line 319, in loads
return _default_decoder.decode(s)
File "/anaconda3/envs/backtestproject/lib/python3.5/json/decoder.py", line 339, in decode
obj, end = self.raw_decode(s, idx=_w(s, 0).end())
File "/anaconda3/envs/backtestproject/lib/python3.5/json/decoder.py", line 357, in raw_decode
raise JSONDecodeError("Expecting value", s, err.value) from None
json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

yes

@cemal,
The root cause is lack of working benchmark data...from your error up above:

File "/anaconda3/envs/backtestproject/lib/python3.5/site-packages/zipline/data/benchmarks.py", line 35, in get_benchmark_returns  
data = r.json()  

If you want to bypass the benchmark, do what it says here:
https://github.com/quantopian/zipline/issues/2480#issuecomment-502890521

alan

Hi Alan, it works. I guess I should have also tried that one. Again thank you. I have a couple more questions, what is included in this quantopian-bundle? Also would I have to buy a data set from quandl to get the same data as in the research notebooks? if so which ones? and how to link this dataset with my ide to create a pipeline?

Thank you so much,

Regards,

Cemal