How to get a complete list of ticker symbols from Yahoo Finance? [closed]
Asked Answered
R

9

114

I've googled endlessly for a method of getting a complete (and daily updated) list of all Yahoo ticker symbols available through http://finance.yahoo.com

Yahoo has information for stocks, futures etc for a lot of exchanges worldwide, and I'd like a combined list of all the ticker symbols available through them. I've tried YQL but they have a "where symbol = (or in)" clause restriction so I cannot select * from symbols.

So basically, getting detailed information for a single symbol or several symbols at one time is easy but I just can't seem to find out how to get a list of all available tickers.

Can anyone help, please?

Ricoriki answered 9/3, 2011 at 14:0 Comment(7)
Did you get any joy? I did find this: eoddata.com/symbols.aspxQuillet
Thanks Codek :-) No, I didn't find it and the task was to find Yahoos symbol list, not anyone elses, so unfortunately cannot use Eoddatas. Thanks again and have a great weekend :-)Ricoriki
ok no probs. I only wanted the LSE symbols so the above helped for me - I believe the symbols within the exchange are consistent across e.g. yahoo/lse/google finance etc - except for yahoo it has .L on the end and in google it has LON. It is ridiculous how all the price data is willingly available, but not the list of symbols I just dont get it!Quillet
Now you can use the metadata from quandl holding 98k symbols. Note that you have to decode the quandl symbol back to the original yahoo symbol. INDEX_ gets ^ and _ gets . quandl.com/data/YAHOO/metadataTransposal
A python program that can do that for you: github.com/Benny-/Yahoo-ticker-symbol-downloaderRomito
This script scrapes ticker symbols from Wikipedia: github.com/kevin91nl/scrape-ticker-symbolsDnieper
The following package offers a good collection: github.com/portfolioplus/pytickersymbolsCommissure
S
14

There is a nice C# wrapper for the Yahoo.Finance API at http://code.google.com/p/yahoo-finance-managed/ that will get you there. Unfortunately there is no direct way to download the ticker list but the following creates the list by iterating through the alphabetical groups:

        AlphabeticIDIndexDownload dl1 = new AlphabeticIDIndexDownload();
        dl1.Settings.TopIndex = null;
        Response<AlphabeticIDIndexResult> resp1 = dl1.Download();

        writeStream.WriteLine("Id|Isin|Name|Exchange|Type|Industry");

        foreach (var alphabeticalIndex in resp1.Result.Items)
        {
            AlphabeticalTopIndex topIndex = (AlphabeticalTopIndex) alphabeticalIndex;
            dl1.Settings.TopIndex = topIndex;
            Response<AlphabeticIDIndexResult> resp2 = dl1.Download();

            foreach (var index in resp2.Result.Items)
            {
                IDSearchDownload dl2 = new IDSearchDownload();
                Response<IDSearchResult> resp3 = dl2.Download(index);


                int i = 0;
                foreach (var item in resp3.Result.Items)
                {
                    writeStream.WriteLine(item.ID + "|" + item.ISIN + "|" + item.Name + "|" + item.Exchange + "|" + item.Type + "|" + item.Industry);
                }

            }
        }

It gave me a list of about 75,000 securities in about 4 mins.

Sail answered 3/11, 2012 at 1:31 Comment(4)
Could you run this code and put a copy of the output on pastebin, for those of us that don't use C# ?Brandabrandais
It does seem the alphabetical result is not complete. Many symbols missed out.Monastic
I tried running this code but unfortunately it returned no results. Any ideas?Rolon
I don't think this works anymore. The wrapper API mentioned makes a request to biz.yahoo.com/i which appears to have changed (redirects to finance.yahoo.com/q) and no longer contains the table the XPath suggests.Calciferous
G
50

i had a similar problem. yahoo doesn't offer it, but you can get one by looking through the document.write statements on nyse.com's list and finding the .js file where they just happen to store the list of companies starting with the given letter as a js array literal. you can also get nice tidy csv files from nasdaq.com here: http://www.nasdaq.com/screening/companies-by-name.aspx?letter=0&exchange=nasdaq&render=download (replace exchange=nasdaq with exchange=nyse for nyse symbols).

Guffey answered 17/6, 2011 at 21:1 Comment(4)
Thanks Ian. I need the list for Yahoo though as they also have tickers outside of the US, so Nasdaq unfortunately isn't enough.Ricoriki
This is excellent, thanks. You can also replace the exchange with "all" to get the tickers for all three indexes.Extravagant
the link leads to a website with such list but I don't see the option to download a csvHydrant
I managed to get all available tickers from plextock.com/us-symbols?utm_source=soYancy
Y
44

I managed to do something similar by using this URL:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.industry%20where%20id%20in%20(select%20industry.id%20from%20yahoo.finance.sectors)&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys

It downloads a complete list of stock symbols using the Yahoo YQL API, including the stock name, stock symbol, and industry ID. What it doesn't seem to have is any sort of stock symbol modifiers. E.g. for Rogers Communications Inc, it only downloads RCI, not RCI-A.TO, RCI-B.TO, etc. I haven't found a source for that information yet - if anyone knows of a way to automate downloading that, I'd like to hear it. Also, it'd be nice to find a way to download some sort of relation between the stock symbol and the exchange it's traded on, since some are traded on multiple exchanges, or maybe I only want to look at stuff on the TSX or something.

Ygerne answered 3/5, 2013 at 13:29 Comment(7)
OR if json is more your thing:jsonProdigy
Nice one. The raw YQL: select * from yahoo.finance.industry where id in (select industry.id from yahoo.finance.sectors)Stasiastasis
I believe the data returned by the above query ultimately comes from links reachable from this URL biz.yahoo.com/ic/ind_index.html (these additional URLs may also be useful: biz.yahoo.com/p/s_conameu.html, biz.yahoo.com/p/sum_conameu.html)Calciferous
How did you come to this query, e.g. where do you read about industry.id and yahoo.finance.sectors?Suffrage
Also, can you also get the sector, in addition to the industry for each ticker? What about the exchange it is traded on?Suffrage
This doesn't seem to be working anymore :(Romito
I think the table "yahoo.finance.sectors" has been removed. But there is still a source for the data - a webpage only. (Indeed, if you do 'select * from yahoo.finance.sectors' at the YQL Console at developer.yahoo.com/yql/console , embedded in the return is the link to the web page - biz.yahoo.com/ic/ind_index.html.) So what you have to do is write some code to get that page and then parse the data out of it. It will give you the list of sectors, the industries in those sectors, and the industry ID (and you can make a sector ID out of the first digit of the industry ID).Paramaribo
L
26

NASDAQ Stock lists ftp://ftp.nasdaqtrader.com/symboldirectory

The 2 files nasdaqlisted.txt and otherlisted.txt are | pipe separated. That should give you a good list of all stocks.

Ladd answered 5/11, 2012 at 3:35 Comment(2)
for the lazy like me: ftp.nasdaqtrader.com/SymbolDirectory ftp.nasdaqtrader.com/SymbolDirectory/nasdaqlisted.txt ftp.nasdaqtrader.com/SymbolDirectory/otherlisted.txtUnclose
nasdaqtraded.txt is what you need, it's both those lists combined.Baronet
C
14

I may be able to help with a list of ticker symbols for (U.S. and non-U.S.) stocks and for ETFs.

Yahoo provides an Earnings Calendar that lists all the stocks that announce earnings for a given day. This includes non-US stocks.

For example, here is today's: http://biz.yahoo.com/research/earncal/20120710.html

the last part of the URL is the date (in YYYYMMDD format) for which you want the Earnings Calendar. You can loop through several days and scrape the Symbols of all stocks that reported earnings on those days.

There is no guarantee that yahoo has data for all stocks that report earnings, especially since some stocks no longer exist (bankruptcy, acquisition, etc.), but this is probably a decent starting point.

If you are familiar with R, you can use the qmao package to do this. (See this post) if you have trouble installing it.

ec <- getEarningsCalendar(from="2011-01-01", to="2012-07-01") #this may take a while
s <- unique(ec$Symbol)
length(s)
#[1] 12223
head(s, 20) #look at the first 20 Symbols
# [1] "CVGW"    "ANGO"    "CAMP"    "LNDC"    "MOS"     "NEOG"    "SONC"   
# [8] "TISI"    "SHLM"    "FDO"     "FC"      "JPST.PK" "RECN"    "RELL"   
#[15] "RT"      "UNF"     "WOR"     "WSCI"    "ZEP"     "AEHR"   

This will not include any ETFs, futures, options, bonds, forex or mutual funds.

You can get a list of ETFs from yahoo here: http://finance.yahoo.com/etf/browser/mkt That only shows the first 20. You need the URL of the "Show All" link at the bottom of that page. You can scrape the page to find out how many ETFs there are, then construct a URL.

L <- readLines("http://finance.yahoo.com/etf/browser/mkt")
# Sorry for the ugly regex
n <- gsub("^(\\w+)\\s?(.*)$", "\\1", 
          gsub("(.*)(Showing 1 - 20 of )(.*)", "\\3",  
               L[grep("Showing 1 - 20", L)]))
URL <- paste0("http://finance.yahoo.com/etf/browser/mkt?c=0&k=5&f=0&o=d&cs=1&ce=", n)
#http://finance.yahoo.com/etf/browser/mkt?c=0&k=5&f=0&o=d&cs=1&ce=1442

Now, you can extract the Tickers from the table on that page

library(XML)
tbl <- readHTMLTable(URL, stringsAsFactors=FALSE)
dat <- tbl[[tail(grep("Ticker", tbl), 1)]][-1, ]
colnames(dat) <- dat[1, ]
dat <- dat[-1, ]
etfs <- dat$Ticker # All ETF tickers from yahoo
length(etfs)
#[1] 1442
head(etfs)
#[1] "DGAZ" "TAGS" "GASX" "KOLD" "DWTI" "RTSA"

That's about all the help I can offer, but you could do something similar to get some of the futures they offer by scraping these pages (These are only U.S. futures)

http://finance.yahoo.com/indices?e=futures, http://finance.yahoo.com/futures?t=energy, http://finance.yahoo.com/futures?t=metals, http://finance.yahoo.com/futures?t=grains, http://finance.yahoo.com/futures?t=livestock, http://finance.yahoo.com/futures?t=softs, http://finance.yahoo.com/futures?t=indices,

And, for U.S. and non-U.S. indices, you could scrape these pages

http://finance.yahoo.com/intlindices?e=americas, http://finance.yahoo.com/intlindices?e=asia, http://finance.yahoo.com/intlindices?e=europe, http://finance.yahoo.com/intlindices?e=africa, http://finance.yahoo.com/indices?e=dow_jones, http://finance.yahoo.com/indices?e=new_york, http://finance.yahoo.com/indices?e=nasdaq, http://finance.yahoo.com/indices?e=sp, http://finance.yahoo.com/indices?e=other, http://finance.yahoo.com/indices?e=treasury, http://finance.yahoo.com/indices?e=commodities

Chanty answered 10/7, 2012 at 20:26 Comment(1)
As you wrote, I might not get all tickers this way and for my project it's either all (complete liste) or it doesn't matter. But thank you very much for the thorough answer, GSee. Appreciate it! Have a great day :-)Ricoriki
S
14

There is a nice C# wrapper for the Yahoo.Finance API at http://code.google.com/p/yahoo-finance-managed/ that will get you there. Unfortunately there is no direct way to download the ticker list but the following creates the list by iterating through the alphabetical groups:

        AlphabeticIDIndexDownload dl1 = new AlphabeticIDIndexDownload();
        dl1.Settings.TopIndex = null;
        Response<AlphabeticIDIndexResult> resp1 = dl1.Download();

        writeStream.WriteLine("Id|Isin|Name|Exchange|Type|Industry");

        foreach (var alphabeticalIndex in resp1.Result.Items)
        {
            AlphabeticalTopIndex topIndex = (AlphabeticalTopIndex) alphabeticalIndex;
            dl1.Settings.TopIndex = topIndex;
            Response<AlphabeticIDIndexResult> resp2 = dl1.Download();

            foreach (var index in resp2.Result.Items)
            {
                IDSearchDownload dl2 = new IDSearchDownload();
                Response<IDSearchResult> resp3 = dl2.Download(index);


                int i = 0;
                foreach (var item in resp3.Result.Items)
                {
                    writeStream.WriteLine(item.ID + "|" + item.ISIN + "|" + item.Name + "|" + item.Exchange + "|" + item.Type + "|" + item.Industry);
                }

            }
        }

It gave me a list of about 75,000 securities in about 4 mins.

Sail answered 3/11, 2012 at 1:31 Comment(4)
Could you run this code and put a copy of the output on pastebin, for those of us that don't use C# ?Brandabrandais
It does seem the alphabetical result is not complete. Many symbols missed out.Monastic
I tried running this code but unfortunately it returned no results. Any ideas?Rolon
I don't think this works anymore. The wrapper API mentioned makes a request to biz.yahoo.com/i which appears to have changed (redirects to finance.yahoo.com/q) and no longer contains the table the XPath suggests.Calciferous
C
9

Complete list of yahoo symbols/tickers/stocks is available for download(excel format) at below website. http://www.myinvestorshub.com/yahoo_stock_list.php

List updated to january 2016: http://investexcel.net/all-yahoo-finance-stock-tickers/

Crowson answered 27/12, 2012 at 17:59 Comment(5)
How up to date is this list?Brandabrandais
This list seems to be incomplete, e.g. GOOG isn't on it.Privation
This list cuts off at 3000 symbols. It's in alphabetical order so for the US that ends up being at FDEF. Other markets with less than 3000 symbols seem to fare better, such as Hong Kong. That said I have no idea how complete / up to date it is.Brigandage
Seems incomplete and unmaintained.Treat
The link does not working anymoreRosaleerosaleen
O
8

I have been researching this for a few days, following endless leads that got close, but not quite, to what I was after.

My need is for a simple list of 'symbol, sector, industry'. I'm working in Java and don't want to use any platform native code.

It seems that most other data, like quotes, etc., is readily available.

Finally, followed a suggestion to look at 'finviz.com'. Looks like just the ticket. Try using the following:

http://finviz.com/export.ashx?v=111&t=aapl,cat&o=ticker This comes back as lines, csv style, with a header row, ordered by ticker symbol. You can keep adding tickers. In code, you can read the stream. Or you can let the browser ask you whether to open or save the file.

http://finviz.com/export.ashx?v=111&&o=ticker Same csv style, but pulls all available symbols (a lot, across global exchanges)

Replace 'export' with 'screener' and the data will show up in the browser.

There are many more options you can use, one for every screener element on the site.

So far, this is the most powerful and convenient programmatic way to get the few pieces of data I couldn't otherwise seem to easily get. And, it looks like this site could well be a single source for most of what you might need other than real- or near-real-time quotes.

Ormsby answered 3/7, 2013 at 3:29 Comment(3)
Every url I load is redirected to finviz.com/elite.ashxChristyna
I had to subscribe to the Elite trader service, but it's worth it. Thanks.Quest
Seems like this is just shilling some product and doesn't answer the question. anyone could buy this infoPricefixing
D
1

One workaround I had for this was to iterate over the sectors(which at the time you could do...I haven't tested that recently).

You wind up getting blocked eventually when you do it that way though, since YQL gets throttled per day.

Use the CSV API whenever possible to avoid this.

Donne answered 20/5, 2012 at 22:54 Comment(0)
T
1

I had same problem, but I think I have simple solution(code is from my RoR app): Extract industry ids from yahoo.finance.sectors and add it to db:

    select = "select * from yahoo.finance.sectors"
    generate_query select
    @data.each do |data|
      data["industry"].each do |ind|
        unless ind.kind_of?(Array)
          unless ind["id"].nil?
            id = ind["id"].to_i
            if id > 0
              Industry.where(id: id).first_or_create(name: ind["name"]).update_attribute(:name, ind["name"])
            end
          end
        end
      end
    end

Extract all comanies with their symbols with industry ids:

    ids = Industry.all.map{|ind| "'#{ind.id.to_s}'" }.join(",")
    select = "select * from yahoo.finance.industry where id in"
    generate_query select, ids
    @data.each do |ts|
      unless ts.kind_of?(Array) || ts["company"].nil?
        if ts["company"].count == 2 && ts["company"].first[0] == "name"
          t = ts["company"]
          Ticket.find_or_create_by_symbol(symbol: t["symbol"], name: t["name"] ).update_attribute(:name, t["name"])
        else
          ts["company"].each do |t|
            Ticket.find_or_create_by_symbol(symbol: t["symbol"], name: t["name"] ).update_attribute(:name, t["name"])
          end
        end
      end
    end
  end

Connection hellper:

def generate_query(select, ids = nil)
    if params[:form] || params[:action] == "sectors" || params[:controller] == "tickets"
      if params[:action] == "sectors" || params[:controller] == "tickets"
        if ids.nil?
          query= select
        else
          query= "#{select} (#{ids})"
        end
      else
        if params[:form][:ids]
          @conditions = params_parse params[:form][:ids]
          query = "#{select} (#{@conditions})"
        end
      end
      yql_execut(query)
    end
  end

  def yql_execut(query)
    # TODO: OAuth ACCESS (http://developer.yahoo.com/yql/guide/authorization.html)
    base_url = "http://query.yahooapis.com/v1/public/yql?&format=json&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&q="
    dirty_data = JSON.parse(HTTParty.get(base_url +  URI.encode(query)).body)
    if dirty_data["query"]["results"] == nil
      @data, @count, @table_head = nil
    else
      @data = dirty_data["query"]["results"].to_a[0][1].to_a
      @count = dirty_data["query"]["count"]
      if @count == 1
        @table_head = @data.map{|h| h[0].capitalize}
      else
        @table_head = @data.to_a.first.to_a.map{|h| h[0].capitalize}
      end
    end
  end

Sorry for mess, but this is first testing version for my project and I needed it very fast. There are some helpers variabels and other things for my app, sorry for it. But I have question: Have many symbols do you have? I have 5500.

Tysontyumen answered 30/11, 2012 at 13:41 Comment(1)
5500 would probably only be US stock symbols (Yahoo finance covers way more - worldwide - as you can see in the accepted answer, he got around 75,000 symbols! :) ... Haven't converted the accepted answer .NET way to Ruby yet (I am also using RoR), so if you make it work, i.e find more symbols, please let me know. Thanks! :-)Ricoriki

© 2022 - 2024 — McMap. All rights reserved.