issues downloading stock data from google finance using panda datareader

Michael picture Michael · Sep 19, 2017 · Viewed 12.6k times · Source

Things used to work great until several days ago. Now when I run the following:

from pandas_datareader import data
symbol = 'AMZN'
data_source='google'
start_date = '2010-01-01'
end_date = '2016-01-01'

df = data.DataReader(symbol, data_source, start_date, end_date)

I get only the most recent data of ONE year shown below, as if the start_data and end_data did not seem to matter. Change them to different dates yielded the same results below. Does anyone know why?

Results:

df.head()
              Open    High     Low   Close    Volume
Date                                                
2016-09-21  129.13  130.00  128.39  129.94  14068336
2016-09-22  130.50  130.73  129.56  130.08  15538307
2016-09-23  127.56  128.60  127.30  127.96  28326266
2016-09-26  127.37  128.16  126.80  127.31  15064940
2016-09-27  127.61  129.01  127.43  128.69  15637111

Answer

Brad Solomon picture Brad Solomon · Sep 20, 2017

Use fix-yahoo-finance and then use yahoo rather than Google as your source. It looks like Google has been locking down a lot of its data lately.

First you'll need to install fix-yahoo-finance. Just use pip install fix-yahoo-finance.

Then use get_data_yahoo:

from pandas_datareader import data
import fix_yahoo_finance as yf
yf.pdr_override() 

symbol = 'AMZN'
data_source='google'
start_date = '2010-01-01'
end_date = '2016-01-01'
df = data.get_data_yahoo(symbol, start_date, end_date)

df.head()
                 Open       High        Low      Close  Adj Close    Volume
Date                                                                       
2010-01-04  136.25000  136.61000  133.14000  133.89999  133.89999   7599900
2010-01-05  133.42999  135.48000  131.81000  134.69000  134.69000   8851900
2010-01-06  134.60001  134.73000  131.64999  132.25000  132.25000   7178800
2010-01-07  132.01000  132.32001  128.80000  130.00000  130.00000  11030200
2010-01-08  130.56000  133.67999  129.03000  133.52000  133.52000   9830500