Forums

Panda Datareader and Yahoo

Hello,

I've just upgraded my panda-datareader package to the last version (0.5.0) but I am still getting trouble fetching quotes from Yahoo Finance API. It seems to be randomly failing getting the data.

Sometime, it is working and sometimes I'm getting an error saying it is unable to read URL... When I launch the last line several times, I get around one error out of 5 attempts (the other attempts ending well...)

Do you have any idea ? Thanks in advance for your help.

from pandas_datareader import data
import time

today = time.strftime("%m/%d/%Y")
valeur={}
valeur = data.DataReader('RCO.PA',data_source='yahoo',start='1/1/2015',end=today)

Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/home/mfk/.local/lib/python3.5/site-packages/pandas_datareader/data.py", line 121, in DataReader session=session).read() File "/home/mfk/.local/lib/python3.5/site-packages/pandas_datareader/yahoo/daily.py", line 115, in read df = super(YahooDailyReader, self).read() File "/home/mfk/.local/lib/python3.5/site-packages/pandas_datareader/base.py", line 181, in read params=self._get_params(self.symbols)) File "/home/mfk/.local/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 "/home/mfk/.local/lib/python3.5/site-packages/pandas_datareader/base.py", line 90, in _read_url_as_StringIO response = self._get_response(url, params=params) File "/home/mfk/.local/lib/python3.5/site-packages/pandas_datareader/base.py", line 139, in _get_response raise RemoteDataError('Unable to read URL: {0}'.format(url)) pandas_datareader._utils.RemoteDataError: Unable to read URL: https://query1.finance.yahoo.com/v7/finance/download/RCO.PA?interval=1d&events=history&crumb=xWh%5Cu002FHEprFWC&period2=1502236799&period1=1420070400

an intermittent error is strange... could it be actual problems with yahoo finance?

I've read that there were some issues with Yahoo Finance that has changed the API in May, but the new version of panda-datareader should work according to the documentation, as they have taken this change into account.

https://github.com/pydata/pandas-datareader/issues/315

https://github.com/pydata/pandas-datareader/commit/ca1a83f725782ccc342460cfc6b0f05446e6ae52

the other possibility could be that yahoo are throttling the service somehow? APIs often use the status code 429 to signify "too many requests", can you check whether that's what you're getting?