I'm trying to pull data from Google Finance using Pandas and Pandas Datareader. Here is my code:
#Importing libraries needed for pulls from Google
from pandas_datareader import data
import pandas as pd
import datetime
from datetime import date
#Define the instruments to download. In this case: Apple, Microsoft, and
the S&P500 index
tickers = ['APPL', 'MSFT', 'SPY']
start_date = datetime.datetime(2017, 12, 1)
end_date = datetime.datetime(2017, 12, 31)
#Use pandas_reader.data.DataReader to load the desired data
panel_data = data.DataReader('SPY', 'google', start_date, end_date)
#Getting just the adjusted closing prices. This will return a Pandas DataFrame
#The index in this DataFrame is the major index of the panel_data.
close = panel_data.ix['Close']
#Getting all weekdays within date range.
all_weekdays = pd.date_range(start=start_date, end=end_date, freq='B')
#How do we align the existing prices in the adj_close with out new set of dates?
#All we need to do is reindex close using all_weekdays as the new index.
close = close.reindex(all_weekdays)
close.head(10)
And here is the console output:
runfile('C:/Users/kjohn_000/.spyder-py3/temp.py', wdir='C:/Users/kjohn_000/.spyder-py3')
C:\Users\kjohn_000\Anaconda3\lib\site-packages\pandas_datareader\base.py:201: SymbolWarning: Failed to read symbol:
'APPL', replacing with NaN.
warnings.warn(msg.format(sym), SymbolWarning)
C:\Users\kjohn_000\Anaconda3\lib\site-
packages\pandas_datareader\base.py:201: SymbolWarning: Failed to read
symbol: 'MSFT', replacing with NaN.
warnings.warn(msg.format(sym), SymbolWarning)
C:\Users\kjohn_000\Anaconda3\lib\site-packages\pandas_datareader\base.py:201: SymbolWarning: Failed to read symbol:
'SPY', replacing with NaN.
warnings.warn(msg.format(sym), SymbolWarning)
Traceback (most recent call last):
File "<ipython-input-2-0ddd75de0396>", line 1, in <module>
runfile('C:/Users/kjohn_000/.spyder-py3/temp.py',
wdir='C:/Users/kjohn_000/.spyder-py3')
File "C:\Users\kjohn_000\Anaconda3\lib\site-packages\spyder\utils\site\sitecustomize.py", line 705, in runfile
execfile(filename, namespace)
File "C:\Users\kjohn_000\Anaconda3\lib\site-
packages\spyder\utils\site\sitecustomize.py", line 102, in execfile
exec(compile(f.read(), filename, 'exec'), namespace)
File "C:/Users/kjohn_000/.spyder-py3/temp.py", line 14, in <module>
panel_data = data.DataReader(tickers, dataSource, start_date, end_date)
File "C:\Users\kjohn_000\Anaconda3\lib\site-packages\pandas_datareader\data.py", line 137, in DataReader
session=session).read()
File "C:\Users\kjohn_000\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 186, in read
df = self._dl_mult_symbols(self.symbols)
File "C:\Users\kjohn_000\Anaconda3\lib\site-
packages\pandas_datareader\base.py", line 206, in _dl_mult_symbols
raise RemoteDataError(msg.format(self.__class__.__name__))
RemoteDataError: No data fetched using 'GoogleDailyReader'
Why is Pandas Datareader failing to read the stock symbols in the 'tickers' list? I've looked around for answers for a few hours now, but many of the answers were in response questions regarding the Yahoo API, and the remaining answers were either for another language or simply out of my depth as coding goes (I'm relatively new to Python). Thanks in advance for help and feedback.