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

get_banchmark_returns can't handle google finance http response format #2029

Closed
tfwnicholson opened this issue Nov 30, 2017 · 1 comment
Closed

Comments

@tfwnicholson
Copy link

Environment:

alembic 0.9.6
bcolz 0.12.1
Bottleneck 1.2.1
certifi 2016.2.28 py35_0
certifi 2017.11.5
chardet 3.0.4
click 6.7
contextlib2 0.5.5
cyordereddict 1.0.0
Cython 0.27.3
decorator 4.1.2
empyrical 0.3.3
idna 2.6
intervaltree 2.1.0
Logbook 1.1.0
lru-dict 1.1.6
Mako 1.0.7
MarkupSafe 1.0
multipledispatch 0.4.9
networkx 2.0
numexpr 2.6.4
numpy 1.13.3
openssl 1.0.2l 0
pandas 0.18.1
pandas-datareader 0.5.0
patsy 0.4.1
pip 9.0.1 py35_1
python 3.5.4 0
python-dateutil 2.6.1
python-editor 1.0.3
pytz 2017.3
readline 6.2 2
requests 2.18.4
requests-file 1.4.2
requests-ftp 0.3.1
scipy 1.0.0
setuptools 36.4.0 py35_1
six 1.11.0
sortedcontainers 1.5.7
SQLAlchemy 1.1.15
sqlite 3.13.0 0
statsmodels 0.8.0
tables 3.4.2
tk 8.5.18 0
toolz 0.8.2
urllib3 1.22
wheel 0.29.0 py35_0
xz 5.2.3 0
zipline 1.1.1
zlib 1.2.11 0

Description of problem

Trying to create a new, blank trading environment throws the error:

Traceback (most recent call last):
  File "tmp.py", line 3, in <module>
    trading_environment = TradingEnvironment()
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/zipline/finance/trading.py", line 99, in __init__
    self.bm_symbol,
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/zipline/data/loader.py", line 166, in load_market_data
    environ,
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/zipline/data/loader.py", line 230, in ensure_benchmark_data
    last_date,
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/zipline/data/benchmarks.py", line 50, in get_benchmark_returns
    last_date
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/pandas_datareader/data.py", line 137, in DataReader
    session=session).read()
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/pandas_datareader/base.py", line 181, in read 
    params=self._get_params(self.symbols))
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/pandas_datareader/base.py", line 79, in _read_one_data
    out = self._read_url_as_StringIO(url, params=params)
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/pandas_datareader/base.py", line 98, in _read_url_as_StringIO
    out.write(bytes_to_str(text))
  File "~/anaconda3/envs/tmp/lib/python3.5/site-packages/pandas/compat/__init__.py", line 72, in bytes_to_str
    return b.decode(encoding or 'utf-8')
UnicodeDecodeError: 'utf-8' codec can't decode byte 0xe3 in position 33091: invalid continuation byte

Reproduction steps

Setup conda environment:

conda create -n tmp python=3.5
source activate tmp

Install zipline

pip install zipline

Run the code:

from zipline.finance.trading import TradingEnvironment
  
trading_environment = TradingEnvironment()

Abover error is thrown

@freddiev4
Copy link
Contributor

freddiev4 commented Dec 2, 2017

Hi @tfwnicholson I've opened a PR #2031 to handle this. I'm also going to close this in favor of #2036. You can read the discussion there/feel free to post there 🙂

Feel free to re-open if you experience other issues.

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

2 participants