quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.58k stars 4.71k forks source link

Attempting to run an Algo but can't progress past error message #2686

Closed Matma724427 closed 4 years ago

Matma724427 commented 4 years ago

Dear Zipline Maintainers,

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

Environment

* Operating System: (Mac OS`) * Python Version: `$ python -3.5` * Python Bitness: `$ python -c 'import math, sys;print(int(math.log(sys.maxsize + 1, 2) + 1))'` * How did you install Zipline: (conda`) * Python packages: `$ pip freeze` or `$ conda list`

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

Attempting to run an Algo but can't progress past error message below. Not very explicit and cant for the life of me work out how to get past it.

Any help would be much appreciated!

Thanks, Mark


JSONDecodeError Traceback (most recent call last)

in () 71 handle_data=handle_data, 72 capital_base=10000, ---> 73 data_frequency = 'daily', bundle='quandl' 74 ) /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/utils/run_algo.py in run_algorithm(start, end, initialize, capital_base, handle_data, before_trading_start, analyze, data_frequency, data, bundle, bundle_timestamp, trading_calendar, metrics_set, default_extension, extensions, strict_extensions, environ, blotter) 428 local_namespace=False, 429 environ=environ, --> 430 blotter=blotter, 431 ) /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/utils/run_algo.py in _run(handle_data, initialize, before_trading_start, analyze, algofile, algotext, defines, data_frequency, capital_base, data, bundle, bundle_timestamp, start, end, output, trading_calendar, print_algo, metrics_set, local_namespace, environ, blotter) 157 trading_calendar=trading_calendar, 158 trading_day=trading_calendar.day, --> 159 trading_days=trading_calendar.schedule[start:end].index, 160 ) 161 first_trading_day =\ /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/finance/trading.py in __init__(self, load, bm_symbol, exchange_tz, trading_calendar, trading_day, trading_days, asset_db_path, future_chain_predicates, environ) 101 trading_day, 102 trading_days, --> 103 self.bm_symbol, 104 ) 105 /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/data/loader.py in load_market_data(trading_day, trading_days, bm_symbol, environ) 147 # date so that we can compute returns for the first date. 148 trading_day, --> 149 environ, 150 ) 151 tc = ensure_treasury_data( /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/data/loader.py in ensure_benchmark_data(symbol, first_date, last_date, now, trading_day, environ) 214 215 try: --> 216 data = get_benchmark_returns(symbol) 217 data.to_csv(get_data_filepath(filename, environ)) 218 except (OSError, IOError, HTTPError): /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/zipline/data/benchmarks.py in get_benchmark_returns(symbol) 44 r = requests.get( 45 'https://api.iextrading.com/1.0/stock/{}/chart/5y'.format(symbol) ---> 46 ) 47 data = r.json() 48 /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/site-packages/requests/models.py in json(self, **kwargs) 895 # used. 896 pass --> 897 return complexjson.loads(self.text, **kwargs) 898 899 @property /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/json/__init__.py in loads(s, encoding, cls, object_hook, parse_float, parse_int, parse_constant, object_pairs_hook, **kw) 317 parse_int is None and parse_float is None and 318 parse_constant is None and object_pairs_hook is None and not kw): --> 319 return _default_decoder.decode(s) 320 if cls is None: 321 cls = JSONDecoder /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/json/decoder.py in decode(self, s, _w) 337 338 """ --> 339 obj, end = self.raw_decode(s, idx=_w(s, 0).end()) 340 end = _w(s, end).end() 341 if end != len(s): /Users/markmatheson/anaconda3/envs/zip35/lib/python3.5/json/decoder.py in raw_decode(self, s, idx) 355 obj, end = self.scan_once(s, idx) 356 except StopIteration as err: --> 357 raise JSONDecodeError("Expecting value", s, err.value) from None 358 return obj, end JSONDecodeError: Expecting value: line 1 column 1 (char 0) * What did you expect to happen? * What happened instead? Here is how you can reproduce this issue on your machine: ## Reproduction Steps 1. 2. 3. ... ## What steps have you taken to resolve this already? ... # Anything else? ... Sincerely, `$ whoami`
dirk-fr commented 4 years ago

See fix here: https://github.com/quantopian/zipline/issues/2488#issuecomment-520276705

This happens because the benchmark provider (IEX) changed their API.

richafrank commented 4 years ago

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.