Whenever I run the below script I receive an error (also below) that says it is unable to read the URL for the quandl site. However, I find this strange because it says the same thing if I use web.DataReader('AAPL', 'google', start, end)
, for example, or even the get_data_yahoo()
method. In fact, sometimes it will work if I am only trying to get the prices of one stock, but I will usually have to run it multiple times before it actually works.
Is this an known problem with pandas_datareader
or is it something I am doing/not doing?
from datetime import datetime as dt
import pandas_datareader as web
import pandas as pd
start = dt(2017, 1, 1)
end = dt.now()
df1 = web.DataReader('AAPL', 'quandl', start, end)
df2 = web.DataReader('JPM', 'quandl', start, end)
df3 = web.DataReader('JNJ', 'quandl', start, end)
df4 = web.DataReader('PG', 'quandl', start, end)
df5 = web.DataReader('XOM', 'quandl', start, end)
df6 = web.DataReader('VZ', 'quandl', start, end)
df7 = web.DataReader('IEF', 'quandl', start, end)
df8 = web.DataReader('SPY', 'quandl', start, end)
Error Output:
Traceback (most recent call last):
File "test.py", line 17, in <module>
df7 = web.DataReader('IEF', 'quandl', start, end)
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/data.py", line 172, in DataReader
session=session).read()
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/quandl.py", line 105, in read
df = super(QuandlReader, self).read()
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 181, in read
params=self._get_params(self.symbols))
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 79, in _read_one_data
out = self._read_url_as_StringIO(url, params=params)
File "/usr/local/lib/python3.6/site-packages/pandas_datareader/base.py", line 90, in _read_url_as_StringIO
response = self._get_response(url, params=params)
File "/usr/local/lib/python3.6/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://www.quandl.com/api/v3/datasets/WIKI/IEF.csv?start_date=2017-01-01&end_date=2017-11-25&order=asc
EDIT: I make requests maybe once every 5 minutes while I'm backtesting the script.
EDIT2: The same script now works if I change the query to google
instead of quandl
, so maybe quandl is having problems currently?