Michael
Michael

Reputation: 33

issues downloading stock data from google finance using panda datareader

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

Upvotes: 3

Views: 15943

Answers (3)

f0nzie
f0nzie

Reputation: 1206

Yahoo working as of January 01, 2020:

import pandas_datareader.data as web
import datetime
start = datetime.datetime(2015, 1, 1)
end = datetime.datetime(2018, 2, 8)
df = web.DataReader('TSLA', 'yahoo', start, end)
print(df.head())

Upvotes: 1

Brad Solomon
Brad Solomon

Reputation: 40888

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

Upvotes: 5

lotteryman
lotteryman

Reputation: 399

Just replace google with yahoo. There are problem with google source right now. https://github.com/pydata/pandas-datareader/issues/394

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

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

Upvotes: 3

Related Questions