├── .gitignore ├── scripts ├── requirements.txt └── process.py ├── .github └── workflows │ └── actions.yml ├── README.md └── datapackage.json /.gitignore: -------------------------------------------------------------------------------- 1 | venv -------------------------------------------------------------------------------- /scripts/requirements.txt: -------------------------------------------------------------------------------- 1 | pandas==2.2.3 2 | requests==2.32.3 -------------------------------------------------------------------------------- /scripts/process.py: -------------------------------------------------------------------------------- 1 | import requests 2 | import pandas as pd 3 | 4 | NASDAQ_URL = 'https://www.nasdaqtrader.com/dynamic/symdir/nasdaqlisted.txt' 5 | 6 | def transform_nasdaq_listed_symbol(): 7 | resp = requests.get(NASDAQ_URL) 8 | 9 | data = resp.text.split('\n') 10 | data = [row.split('|') for row in data] 11 | df = pd.DataFrame(data[1:], columns=data[0]) 12 | 13 | # Transform data 14 | df.columns = df.columns.str.replace('\r', '', regex=False) 15 | df = df.map(lambda x: x.replace('\r', '') if isinstance(x, str) else x) 16 | 17 | # Create nasdaq_listed.csv and nasdaq_listed_symbol.csv 18 | nasdaq_listed = df[['Symbol', 'Security Name']] 19 | nasdaq_listed.to_csv('data/nasdaq-listed.csv', index=False) 20 | nasdaq_listed_symbol = df 21 | nasdaq_listed_symbol['Company Name'] = nasdaq_listed_symbol['Security Name'].str.split(' - ').str[0] 22 | last_col = nasdaq_listed_symbol.pop(nasdaq_listed_symbol.columns[-1]) 23 | nasdaq_listed_symbol.insert(1, last_col.name, last_col) 24 | nasdaq_listed_symbol.to_csv('data/nasdaq-listed-symbols.csv', index=False) 25 | print('nasdaq-listed.csv and nasdaq-listed-symbols.csv saved.') 26 | 27 | if __name__ == '__main__': 28 | transform_nasdaq_listed_symbol() -------------------------------------------------------------------------------- /.github/workflows/actions.yml: -------------------------------------------------------------------------------- 1 | name: Nasdaq listing update 2 | 3 | on: 4 | # Schedule to run on the 1st day of each month 5 | schedule: 6 | - cron: '0 0 1 * *' 7 | 8 | # Run on push to master branch 9 | push: 10 | branches: 11 | - main 12 | 13 | # Run on pull requests targeting the master branch 14 | pull_request: 15 | branches: 16 | - main 17 | 18 | # Allows manual triggering of the workflow 19 | workflow_dispatch: 20 | 21 | jobs: 22 | build: 23 | runs-on: ubuntu-latest 24 | 25 | if: github.ref == 'refs/heads/main' 26 | 27 | steps: 28 | - name: Check out repository 29 | uses: actions/checkout@v3 30 | 31 | - name: Set up Python 3.12 32 | uses: actions/setup-python@v4 33 | with: 34 | python-version: '3.12' 35 | 36 | - name: Install Python dependencies 37 | run: | 38 | python -m venv venv 39 | source venv/bin/activate 40 | pip install --upgrade pip 41 | pip install -r scripts/requirements.txt 42 | python scripts/process.py 43 | 44 | - name: Push and Commit 45 | env: 46 | CI_COMMIT_NAME: "Automated commit" 47 | CI_COMMIT_EMAIL: "actions@users.noreply.github.com" 48 | CI_COMMIT_MESSAGE: "Automated commit" 49 | run: | 50 | git config --global user.email "${{env.CI_COMMIT_EMAIL}}" 51 | git config --global user.name "${{env.CI_COMMIT_NAME}}" 52 | git diff --quiet && echo "No changes to commit" || (git add data/ && git commit -m "${{env.CI_COMMIT_MESSAGE}}" && git push) -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | badge 2 | 3 | List of companies in the NASDAQ exchanges. 4 | 5 | ## Data 6 | 7 | Data and documentation are available on [NASDAQ's official webpage](http://www.nasdaqtrader.com/trader.aspx?id=symboldirdefs). Data is updated regularly on the FTP site. 8 | 9 | The file used in this repository: 10 | * [NASDAQ Listed Securities](ftp://ftp.nasdaqtrader.com/symboldirectory/nasdaqlisted.txt) 11 | 12 | Notes: 13 | 14 | * Company Name is a parsed field using the Security Name field. 15 | * Test Listings are excluded in the final dataset 16 | 17 | ## Preparation 18 | 19 | You need python plus pandas library tool installed to run the 20 | scripts. You also probably need to be on Linux/Unix or Mac for the shell 21 | scripts to work. 22 | 23 | 24 | #### all datasets 25 | 26 | ***Creates all csv files and datapackage.json*** 27 | 28 | Run python script: 29 | 30 | python scripts/process.py 31 | 32 | 33 | ## License 34 | 35 | This Data Package is licensed by its maintainers under the [Public Domain Dedication and License (PDDL)](http://opendatacommons.org/licenses/pddl/1.0/). 36 | 37 | Refer to the [Copyright notice](http://www.nasdaqtrader.com/Trader.aspx?id=CopyDisclaimMain) of the source dataset for any specific restrictions on using these data in a public or commercial product. Copyright © 2010, The NASDAQ OMX Group, Inc. All rights reserved. 38 | -------------------------------------------------------------------------------- /datapackage.json: -------------------------------------------------------------------------------- 1 | { 2 | "license": "", 3 | "name": "nasdaq-listings", 4 | "resources": [ 5 | { 6 | "format": "csv", 7 | "mediatype": "text/csv", 8 | "name": "nasdaq-listed", 9 | "path": "data/nasdaq-listed.csv", 10 | "schema": { 11 | "fields": [ 12 | { 13 | "description": "", 14 | "name": "Symbol", 15 | "type": "string" 16 | }, 17 | { 18 | "description": "", 19 | "name": "Company Name", 20 | "type": "string" 21 | }, 22 | { 23 | "description": "", 24 | "name": "Security Name", 25 | "type": "string" 26 | }, 27 | { 28 | "description": "", 29 | "name": "Market Category", 30 | "type": "string" 31 | }, 32 | { 33 | "description": "", 34 | "name": "Test Issue", 35 | "type": "string" 36 | }, 37 | { 38 | "description": "", 39 | "name": "Financial Status", 40 | "type": "string" 41 | }, 42 | { 43 | "description": "", 44 | "name": "Round Lot Size", 45 | "type": "number" 46 | }, 47 | { 48 | "description": "", 49 | "name": "ETF", 50 | "type": "string" 51 | }, 52 | { 53 | "description": "", 54 | "name": "NextShares", 55 | "type": "string" 56 | } 57 | ] 58 | } 59 | }, 60 | { 61 | "format": "csv", 62 | "mediatype": "text/csv", 63 | "name": "nasdaq-listed-symbols", 64 | "path": "data/nasdaq-listed-symbols.csv", 65 | "schema": { 66 | "fields": [ 67 | { 68 | "description": "", 69 | "name": "Symbol", 70 | "type": "string" 71 | }, 72 | { 73 | "description": "", 74 | "name": "Company Name", 75 | "type": "string" 76 | } 77 | ] 78 | } 79 | } 80 | ], 81 | "title": "Nasdaq Listings", 82 | "collection": "stock-market-data" 83 | } --------------------------------------------------------------------------------