Getting a list of stock symbols

Lists of stock symbols can be found at either of these links:

You can download a list of symbols from the site for the Nasdaq, NYSE, and AMEX exchanges.

The FTP directory at gets updated every night at 3:00AM (symbols can change). Here is a quick Python script to download the nasdaqlisted.txt and otherlisted.txt files from the ftp site:


# typical use: python > symbols.txt

import urllib

def get_data( url ):
    data = urllib.urlopen( url )
    lines = []
    for line in data:
        lines.append( line.rstrip().split('|') )
    return lines

url = ''
files = ['nasdaqlisted.txt', 'otherlisted.txt']

for f in files:
    print get_data( url + f )