3

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
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
Michael
  • 33
  • 1
  • 1
  • 4
  • Possible duplicate of [Where and how to get the equity historical data (at least covers 2008)?](https://stackoverflow.com/questions/46301016/where-and-how-to-get-the-equity-historical-data-at-least-covers-2008) – Brad Solomon Sep 20 '17 at 02:39

3 Answers3

5

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
Brad Solomon
  • 38,521
  • 31
  • 149
  • 235
  • Thanks Brad! I was able to get it to work, following your approach. Only change was to add yf.pdr_override() after import fix_yahoo_finance as yf. – Michael Sep 21 '17 at 01:08
3

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)
lotteryman
  • 389
  • 1
  • 6
  • 21
  • 1
    This now gives: `ImmediateDeprecationError: Yahoo Daily has been immediately deprecated due to large breaks in the API without the introduction of a stable replacement. Pull Requests to re-enable these data connectors are welcome. See https://github.com/pydata/pandas-datareader/issues` – bio Mar 27 '18 at 09:54
1

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())
f0nzie
  • 1,086
  • 14
  • 17