Yahoo Finance API / URL not working: Python fix for Pandas DataReader

Yahoo Finance URL unavailable using the Pandas DataReader "yahoo" method since May 16, 2017. I have yet to check out this fix-yahoo-finance: https://pypi.python.org/pypi/fix-yahoo-finance , which was published only yesterday, with the expression: "Yahoo! Finance has decommissioned its historical data API" .

EDIT August 2, 2017. Since then I followed the steps at https://pypi.python.org/pypi/fix-yahoo-finance : $ pip3 install fix_yahoo_finance --upgrade - no-cache-dir, updated pandas_datareader to work with "fix-yahoo-finance 0.0.6 "and modified codes:

from pandas_datareader import data as pdr import fix_yahoo_finance data = pdr.get_data_yahoo('AAPL', start='2017-04-23', end='2017-05-24') 

Please note that the order of the last two data columns is “Adj Close” and “Volume”, i.e. not the previous format. For my purpose, they just reset in the original format:

 cols = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Close'] data.reindex(columns=cols) 
+2
python yahoo-finance pandas-datareader
May 22 '17 at 12:03
source share
4 answers

I followed the steps at https://pypi.python.org/pypi/fix-yahoo-finance for: $ pip3 install fix_yahoo_finance --upgrade --no-cache-dir and also updated pandas_datareader.

"fix-yahoo-finance 0.0.6" worked well, for example BHP.AX:

 from pandas_datareader import data as pdr import fix_yahoo_finance data = pdr.get_data_yahoo('BHP.AX', start='2017-04-23', end='2017-05-24') 

Please note that the order of the last two data columns is “Adj Close” and “Volume”, i.e. not the previous format. For my purpose, they reset refer to the original format:

 cols = ['Date', 'Open', 'High', 'Low', 'Close', 'Volume', 'Adj Close'] data.reindex(columns=cols) 
0
May 24 '17 at 18:54
source share
— -
 import pandas_datareader.data as pdweb from pandas_datareader import data as pdr import fix_yahoo_finance # must pip install first data = pdr.get_data_yahoo('SPY','2017-05-20','2017-05-23') data = pdr.get_data_yahoo(['SPY','QQQ'],'2017-05-01','2017-05-23', as_panel=False,group_by = 'ticker') 
+2
May 23 '17 at 15:03
source share

I would recommend using Quandl. I'm not sure that Yahoo will become reliable after their acquisition. In Quandl, if you have multiple characters, you should loop around. Read the docs and do something like this:

  import quandl as qdl start_date = '2016-01-01' end_date = '2017-05-22' for symbol in symbols: quandldata = qdl.get_table("WIKI/PRICES",qopts={"columns":["date", "adj_close"]}, ticker=symbol, date = {'gte': start_date,'lte' : end_date}) # specify that the quandldata df has index col = 'date' quandldata = quandldata.set_index(["date"], drop=True) # rename col adj close to the respective symbol to prevent clash w/ same name for all cols quandldata = quandldata.rename(columns={'adj_close': symbol}) df = df.join(quandldata) 
+1
May 23 '17 at 15:02
source share

I like user3443068 to answer as simply.

I would also like to consider using Google as a source, since the yahoo instance will probably go through many legacy versions, data about where the company is going.

 def get_ret(tickers_ls, start_dt, end_dt): #create dataframe df_ret=pd.DataFrame() #get prices for all tickers for tk in tickers: p = wb.DataReader(tk, "google", start_date, end_date).Close df_ret_tmp = p.to_frame()['Close'].reset_index() df_ret_tmp['Ticker']=tk ## append df_ret=df_ret.append(df_ret_tmp) #pivot and get into single dataframe pivoted = df_ret.pivot(index='Date', columns='Ticker') pivoted.columns = pivoted.columns.droplevel(0) return pivoted 
0
Jun 08 '17 at 2:20 on
source share



All Articles