-1

I have a python script that downloads stock prices via Yahoo's APIs. I'm trying to add the NASDAQ index, but I can not find a working symbol.

From Yahoo finance webpage NASDAQ is '^IXIC', however the following fail

url = "http://download.finance.yahoo.com/d/quotes.csv?s=^IXIC&f=ac"
url = "http://download.finance.yahoo.com/d/quotes.csv?s=%5EIXIC&f=ac"

For the DOW I needed to use an ETF symbol 'DIA' (then multiple the result by 100)

url = "http://download.finance.yahoo.com/d/quotes.csv?s=DIA&f=ac" 

Anyone know of a symbol for NASDAQ that works with Yahoo's APIs?

Erica
  • 2,399
  • 5
  • 26
  • 34
user192749
  • 247
  • 1
  • 3
  • 11
  • They both work for me from a browser or with `curl` from the CLI. So the symbol seems right. For some reason the price shows as `N/A`, but the change is correct. – Barmar Dec 31 '15 at 22:23

1 Answers1

2

Why not just use the yahoo-finance python project? https://github.com/lukaszbanasiak/yahoo-finance Then the code could look like this:

from yql.api import YQL
ticker = ['^IXIC', '^DJI', '^GSPC']
for t in ticker:
    try:
        yql = YQL(t, '2016-01-01', '2016-01-30')
        print "Ticker: {0}".format(t)
        for item in yql:
            print item.get('date'), item.get('price')
    except:
        print 'Failed to Get Reply from Yahoo API'
  • Thanks Erik, your reply makes perfect sense, but I'm trying to avoid dependencies and alas their is no easy way to include the yahoo-finance module into a install package (for Arch at least). – user192749 Jul 29 '16 at 05:40