Yahoo Finance API returning NAN for some tickers

red and white pennants

Im trying to use Yahoo finance to do some very simple analysis just to get used to working with it. Im trying to import data from yahoo finance and then just get it displaying on a graph. In the code you can see that i’ve added a few tickers to get data for but I can never seem to get data for indices such as the Dow Jones, S&P 500 or NASDAQ. its keeps on returning NaN for all of those.

My question is, does yahoo finance’s API not inlcude that data or do I need to do something else to get indices data?

(jbtw having the same issue when im looking for ETF data)

from pandas_datareader import data
import matplotlib.pyplot as plt
import pandas as pd

start_date = '2000-06-30'
end_date = '2020-06-30'

stocks = ['OMC','PUB','WPP','IXIC']

panel_data = data.DataReader(stocks,'yahoo',start_date,end_date)
panel_data = panel_data[['Adj Close']]
print(panel_data)
panel_data.plot(y = 'Adj Close')
plt.show()


Output:

Attributes  Adj Close                           
Symbols           OMC        PUB        WPP IXIC
Date                                            
2000-06-30  29.635815        NaN  39.444866  NaN
2000-07-03  30.093342        NaN  39.275150  NaN
2000-07-05  29.822983        NaN  39.512760  NaN
2000-07-06  29.407042        NaN  39.852219  NaN
2000-07-07  28.284004        NaN  39.241199  NaN
  • Note: In the example above the column ‘PUB’ is getting data just not in the rows I’ve pasted, IXIC is the one thats not returning anything
asked 4 hours ago
Saad ShahidSaad Shahid

153 bronze badges

Latest posts