109

I have a very basic data question: how to get a list of all common stocks traded on NYSE, NASDAQ and AMEX? I would need to be able to get the approximate list of common stocks as is available in Telechart... I can not get this data at eoddata, for example...

I would like to calculate market breadth indicators and would like to find out how many of common stocks traded were up or down 4% (breakouts/breakdowns) (Cl-Lag(Cl) > 0.04 (4% breakout), Cl-Lag(Cl) < -0.04 (4% breakdown)), how many of common stocks traded are down/up 25% in quarter etc.

My first problem is how to get a list of symbols with only common stocks (no ETFs).

Joshua Ulrich
  • 3,178
  • 3
  • 22
  • 35
Samo
  • 1,091
  • 2
  • 8
  • 3
  • Hi Samo, welcome to quant.SE and thanks for your question. Please consider registering in order to edit and respond to answers and to gain further privileges. – Tal Fishman Aug 10 '11 at 01:36
  • nasdaq site is extremely dated. bloomberg is up to date. – DroBuddy Jan 22 '14 at 02:13
  • 3
    NASDAQ site has been updating this entire time. sure the site design is old, but the data is good. – Adam Feb 05 '19 at 15:01
  • 8
    In 2019, the data is here: ftp://ftp.nasdaqtrader.com/symboldirectory/ – duhaime Mar 14 '19 at 16:34
  • Try this API endpoint to lookup tickers https://rapidapi.com/logicione/api/stock-ticker-security-and-company-search-database?endpoint=apiendpoint_aac710aa-f501-497e-8cc7-8c552d40f955 and this endpoint https://rapidapi.com/logicione/api/stock-ticker-security-and-company-search-database?endpoint=apiendpoint_da310f0a-27d1-43b7-8392-14d09ba83502 to lookup/check S&P500 traded (i.e. actively traded) companies. You can try the API for 50 req/day free. For more calls pay a small amount. – Watt Aug 01 '20 at 07:53
  • https://stackoverflow.com/questions/25338608/download-all-stock-symbol-list-of-a-market – T.Todua Mar 02 '21 at 09:37
  • https://pkgstore.datahub.io/core/nasdaq-listings/nasdaq-listed-symbols_json/data/5c10087ff8d283899b99f1c126361fa7/nasdaq-listed-symbols_json.json

    https://pkgstore.datahub.io/JohnSnowLabs/list-of-companies-in-the-new-york-stock-exchange/list-of-companies-in-the-new-york-stock-exchange-csv_json/data/0026360bbb7be2840f71db501b9bdede/list-of-companies-in-the-new-york-stock-exchange-csv_json.json

    – chovy Apr 20 '21 at 18:12

7 Answers7

120

NASDAQ makes this information available via FTP and they update it every night. Log into ftp.nasdaqtrader.com anonymously. Look in the directory SymbolDirectory. You'll notice two files: nasdaqlisted.txt and otherlisted.txt. These two files will give you the entire list of tradeable symbols, where they are listed, their name/description, and an indicator as to whether they are an ETF.

Given this list, which you can pull each night, you can then query Yahoo to obtain the necessary data to calculate your statistics.

UPDATE: More information about these files and their fields can be found here.

Louis Marascio
  • 5,497
  • 3
  • 31
  • 40
  • 3
    Very nice! I'll have to add a function to TTR to access these files. – Joshua Ulrich Sep 08 '11 at 18:30
  • Does Yahoo allow you to run a script to do thousands of HTML fetches against their servers? I know some web sites will ban your IP if you try that. – pacoverflow Jun 15 '13 at 07:42
  • @pacoverflow They do, at the very least, allow ~7500 sequential individual requests. It is also possible to download data for up to 200 symbols from Yahoo! in one request. – Eliezer P Jan 26 '14 at 03:14
  • 8
    ftp://ftp.nasdaqtrader.com/SymbolDirectory/ ftp://ftp.nasdaqtrader.com/SymbolDirectory/nasdaqlisted.txt ftp://ftp.nasdaqtrader.com/SymbolDirectory/otherlisted.txt – 1mike12 Jul 03 '17 at 15:08
  • 5
    I created an account on this site just to upvote this answer (and the question). I can't believe how hard this type of information is to find, reliably. –  Sep 23 '19 at 16:02
  • Jan-2020 version: https://github.com/pyrytakala/public/blob/master/fina/nasdaqlisted.txt – ppt Jan 20 '20 at 21:46
  • I'm looking at https://www.advfn.com/amex/americanstockexchange.asp?companies=M and I don't see MXM listed on either of those files listed on the ftp – thistleknot Mar 14 '20 at 14:12
  • nevermind. I seee that advfn has outdated listings which MXM is (hasn't traded since 2017) – thistleknot Mar 14 '20 at 22:02
  • otherlisted is fully contained within nasdaqtraded.txt (compared with R's setdiff). So if looking for all 3 markets, just download that. I compared amex and nyse symbols from eoddata to confirm that at least 90% of the symbols were found in nasdaqtraded.txt – thistleknot Mar 14 '20 at 22:58
  • The nasdaqlisted.txt and otherlisted.txt include all the traded securities, which means ETFs are included. I wonder if you have any thoughts about how can I just include common stock, rather than ETFs? – Xiaorui Zhu Nov 20 '20 at 18:42
31

Slightly ugly bash one-liner for a sorted JSON array:

echo "[\"$(echo -n "$(echo -en "$(curl -s --compressed 'ftp://ftp.nasdaqtrader.com/SymbolDirectory/nasdaqlisted.txt' | tail -n+2 | head -n-1 | perl -pe 's/ //g' | tr '|' ' ' | awk '{printf $1" "} {print $4}')\n$(curl -s --compressed 'ftp://ftp.nasdaqtrader.com/SymbolDirectory/otherlisted.txt' | tail -n+2 | head -n-1 | perl -pe 's/ //g' | tr '|' ' ' | awk '{printf $1" "} {print $7}')" | grep -v 'Y$' | awk '{print $1}' | grep -v '[^a-zA-Z]' | sort)" | perl -pe 's/\n/","/g')\"]"


EDIT: Filtered out test stocks

Ryan Lester
  • 411
  • 4
  • 5
20

Bloomberg Open Symbology has this list. Look in the Common Stock precanned file. This will have a bit more data than you probably need as it has a separate entry and unique id for each place an equity is traded. However it is probably the highest quality list available for free anywhere.

As for filtering ETFs are broken out in a separate file (Equity_ETP) so you simply need to filter by exchange.

Update November 2017: BSYM is no more and its replacement does not have prebuilt files as far as I can tell.

Steve Severance
  • 1,805
  • 13
  • 21
18

You can download all stocks on the three exchanges listed in your question from the NASDAQ website: http://www.nasdaq.com/screening/company-list.aspx.

It looks like removing those entries with an industry of "N/A" will eliminate ETFs and other funds from the list.

joshayers
  • 628
  • 3
  • 6
  • 4
    This link doesn't work anymore since NASDAQ decided to push in a new update to their webpage. – troymyname00 Sep 15 '19 at 02:04
  • @troymyname00 The revised url is https://old.nasdaq.com/screening/company-list.aspx that seems to work. – donPablo May 19 '20 at 04:00
  • 1
    The URL has been updated again. It is now at https://www.nasdaq.com/market-activity/stocks/screener Also, the format returned from the web request has changed to JSON. – Winston Kotzan Feb 01 '21 at 19:13
9

The stockSymbols function in the R package TTR pulls the data from nasdaq.com that @bellamyj mentioned. It also attempts to convert the symbols to a format acceptable to Yahoo Finance.

That said, I'm not certain how to filter this list for only common stocks. There are 1275 securities with "n/a" Sector or Industry, leaving ~5000. Perhaps the remaining categories in Sectors and Industries can help you further refine the list.

Joshua Ulrich
  • 3,178
  • 3
  • 22
  • 35
2

I've been using this API called Stock Coverage from unibit. It covers around 70,000 stocks from 49 exchanges. Though I'm not sure if it is the most updated. A few recent IPOs can be found in the list.

The ticker standard seem to complies with Yahoo's and it works with many of the other APIs in their site.

All their listed tickers can be found on this public domain.

Desmond830
  • 86
  • 2
0

Do you have an existing brokerage account or perhaps a data provider you're subscribed to? I was able to previously receive a complete list of stocks for the full Equities universe on all the US exchanges from algoseek.com

  • 1
    SEC maintains a free downloadable list of companies. https://www.sec.gov/file/company-tickers or directly download the json file at https://www.sec.gov/files/company_tickers.json – robert Jan 20 '23 at 13:14