ranaroussi / yfinance

Download market data from Yahoo! Finance's API
https://aroussi.com/post/python-yahoo-finance
Apache License 2.0
14.58k stars 2.43k forks source link

How do you get data for NYSE and NASDAQ indexes? (NYA and .IXIC) #1269

Closed so87 closed 1 year ago

so87 commented 1 year ago

What are you trying to do?

  1. Get data for this index: https://www.google.com/finance/quote/.IXIC:INDEXNASDAQ
  2. Get data for this index: https://www.google.com/finance/quote/NYA:INDEXNYSEGIS

what did you already try:

What did I expect to happen?

I don't want data on the symbols inside those exchanges. I want the index data. I expected this to work like any other ticker(see google links above). I searched through questions and documentation but i couldn't find anything on trying to get just the big composite indexes.

galashour commented 1 year ago

nq = yf.Ticker('^IXIC') nq_data = nq.history(period='3mo')

so87 commented 1 year ago

@galashour thank you! Is the NYSE index the same? I thought it was odd this wasn't documented because i would assume people would want to get the nasdaq/sp500/dow/etc

galashour commented 1 year ago

didn't check the below with yahoo finance, but should work similar to the one above for nasdaq:

NYSE yahoo ticker seems to be '^NYA' or maybe '^XAX' SP500 yahoo ticker seems to be '^SPX' DOW index yahoo ticker seems to be '^DJI'

by the way, if you just want to track the trends, you can use the ETFs (e.g, SPY, DIA, etc.).

so87 commented 1 year ago

that works thank you!