As you may have heard, Yahoo! finance has decommissioned its historical data API, causing many programs that relied on it to stop working. However...

Today I've releases a small Python library called fix-yahoo-finance that aims to offer a temporary fix to the problem by scraping the data from Yahoo! finance and returning a Pandas DataFrame/Panel in the same format as pandas_datareader's get_data_yahoo() method.

Here's how to use it

from pandas_datareader import data as pdr
import fix_yahoo_finance  # <== that's all it takes :-)

# download dataframe
data = pdr.get_data_yahoo("SPY",
                          start="2017-01-01", end="2017-04-30")

# download Panel
data = pdr.get_data_yahoo(["SPY", "IWM"],
                          start="2017-01-01", end="2017-04-30")

I've also added some options to make life easier, like groupping by ticker instead of OHLC and auto-adjustment of data and option to return a Pandas Panel or a MultiIndex DataFrame.

=> Visit the Github repository for more info and installation instructions.

* Note that this library in intented to be a temporary fix until the good fellas of pandas-datareader find a solution, or while you update your code to work with a different data provider.


Legal note:

Yahoo!, Y!Finance, and Yahoo! finance are registered trademarks of Yahoo, Inc.

yfinance is not affiliated, endorsed, or vetted by Yahoo, Inc. It's an open-source tool that uses Yahoo's publicly available APIs, and is intended for research and educational purposes.

You should refer to Yahoo!'s terms of use (here, here, and here) for details on your rights to use the actual data downloaded. Remember - the Yahoo! finance API is intended for personal use only.