pytickersymbols provides access to google and yahoo ticker symbols
Project description
pytickersymbols
pytickersymbols provides access to google and yahoo ticker symbols for all stocks of the following indices:
- AEX
- BEL 20
- CAC 40
- CAC MID 60
- DAX
- DOW JONES
- EURO STOXX 50
- FTSE 100
- IBEX 35
- MDAX
- NASDAQ 100
- OMX Helsinki 25
- OMX Stockholm 30
- S&P 100
- S&P 500
- S&P 600
- SDAX
- Switzerland 20
- TECDAX
install
pip3 install pytickersymbols
quick start
Get all countries, indices and industries as follows:
from pytickersymbols import PyTickerSymbols
stock_data = PyTickerSymbols()
countries = stock_data.get_all_countries()
indices = stock_data.get_all_indices()
industries = stock_data.get_all_industries()
You can select all stocks of an index as follows:
from pytickersymbols import PyTickerSymbols
stock_data = PyTickerSymbols()
german_stocks = stock_data.get_stocks_by_index('DAX')
uk_stocks = stock_data.get_stocks_by_index('FTSE 100')
print(list(uk_stocks))
If you are only interested in ticker symbols, then you should have a look at the following lines:
from pytickersymbols import PyTickerSymbols
stock_data = PyTickerSymbols()
# the naming conversation is get_{index_name}_{exchange_city}_{yahoo or google}_tickers
dax_google = stock_data.get_dax_frankfurt_google_tickers()
dax_yahoo = stock_data.get_dax_frankfurt_yahoo_tickers()
sp100_yahoo = stock_data.get_sp_100_nyc_yahoo_tickers()
sp500_google = stock_data.get_sp_500_nyc_google_tickers()
dow_yahoo = stock_data.get_dow_jones_nyc_yahoo_tickers()
# there are too many combination. Here is a complete list of all getters
all_ticker_getter_names = list(filter(
lambda x: (
x.endswith('_google_tickers') or x.endswith('_yahoo_tickers')
),
dir(stock_data),
))
print(all_ticker_getter_names)
Iterator Examples
Use iterator-based APIs to stream results without building large lists:
from pytickersymbols import PyTickerSymbols
stock_data = PyTickerSymbols()
# Stream indices
for index in stock_data.iter_all_indices():
print(index)
# Stream all unique stocks
for company in stock_data.iter_all_stocks():
print(company['name'])
# Stream industries and countries
for industry in stock_data.iter_all_industries():
pass # handle industry
for country in stock_data.iter_all_countries():
pass # handle country
# Stream Yahoo tickers for an index (flattened)
for tickers in stock_data.iter_yahoo_ticker_symbols_by_index('DAX'):
for ticker in tickers:
print(ticker)
# Stream tickers using exchange-specific dynamic methods
for ticker in stock_data._iter_tickers_by_index('DAX', ('FRA:',), 'yahoo'):
print(ticker)
Development
Setting up the development environment
This project uses Poetry for dependency management. To set up your development environment:
# Install Poetry if you haven't already
curl -sSL https://install.python-poetry.org | python3 -
# Clone the repository
git clone https://github.com/portfolioplus/pytickersymbols.git
cd pytickersymbols
# Install dependencies (including dev dependencies)
poetry install
# Activate the virtual environment
poetry shell
Development Tools
The tools/ directory contains scripts for managing stock index data:
- build_indices.py: End-to-end pipeline to parse Wikipedia, enrich with
stocks.yaml, canonicalize names, and generate the Python data module. - wiki_table_parser.py: Utilities to parse Wikipedia tables configured via
index_sources.yaml. - enrich_indices.py: Merge raw parsed data with
stocks.yamlhistorical metadata and symbols. - canonicalize_names.py: Normalize company display names across indices using ISIN/Wikipedia.
- sync_canonical_to_stocks.py: Propagate canonical names back to
stocks.yaml. - enrich_with_yfinance.py: Optional enrichment helpers using Yahoo Finance.
See tools/README.md for detailed usage instructions.
Running Tests
poetry run pytest
Adding a New Index
To add a new stock index to the library:
-
Add the index to configuration
Edit tools/index_sources.yaml and add a new entry:- name: NIKKEI 225 source: type: wikipedia url: https://en.wikipedia.org/wiki/Nikkei_225 table_title_regex: "Components" extract_company_info: true language_fallbacks: ["ja", "en"] columns: name: ["Company", "Name"] symbol: ["Ticker", "Symbol"] isin: ["ISIN"] sector: ["Sector", "Industry"] symbol_converter: - pattern: "^(.+)$" format: "{1}.T" # Add .T suffix for Tokyo Stock Exchange match: by: symbol
Configuration options:
name: Display name (must match stocks.yaml if merging with historical data)url: Wikipedia page URL containing the index constituents tabletable_title_regex: (Optional) Regex to match the table titleextract_company_info: Set totrueto fetch additional details from company Wikipedia pageslanguage_fallbacks: List of Wikipedia language codes to try for ISIN lookupsymbol_converter: Rules to convert Wikipedia symbols to Yahoo Finance formatcolumns: Map Wikipedia table headers to data fieldsmatch.by: Field to use for matching with historical data (symbol,isin, orname)
-
Run the build pipeline
This will parse Wikipedia, enrich the data, and generate the Python module:cd tools python build_indices.py
This creates:
indices_raw/<index_name>.json- Raw parsed data from Wikipediaindices/<index_name>.yaml- Enriched data merged with historical records- Updates
src/pytickersymbols/indices_data.py- Generated Python module
-
Test the new index
Verify the index is accessible:from pytickersymbols import PyTickerSymbols stock_data = PyTickerSymbols() nikkei_stocks = stock_data.get_stocks_by_index('NIKKEI 225') print(list(nikkei_stocks))
-
Run tests
Ensure everything works:poetry run pytest
-
Update the index list
Add a checkbox entry to the supported indices list at the top of this README.
Note: The build pipeline automatically runs weekly via GitHub Actions to keep index data up to date.
Performance Tips
- Lookups for stocks by symbol and aggregated lists/sets are internally cached for speed. After calling
load_json()orload_yaml(), caches are automatically rebuilt. - For large results, prefer generator variants to avoid materializing lists:
iter_all_indices(),iter_all_stocks(),iter_all_countries(),iter_all_industries(), anditer_yahoo_ticker_symbols_by_index()/iter_google_ticker_symbols_by_index(). - Dynamic ticker getters follow the naming convention
get_{index_name}_{exchange_city}_{yahoo|google}_tickersand return lists. Use_iter_tickers_by_index()for streaming if needed.
issue tracker
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file pytickersymbols-1.17.9.tar.gz.
File metadata
- Download URL: pytickersymbols-1.17.9.tar.gz
- Upload date:
- Size: 401.4 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d84ad92018bcebe1e419b104b5c7b209ee7faf16973f59ee4a5434a19667e7b9
|
|
| MD5 |
fc02a2fde75238d1181f19e3dbbf46c8
|
|
| BLAKE2b-256 |
7cc38df83a45ca3c1b4dfa72558f4b68b74e37006cbed3642fd4fc24e518dc18
|
Provenance
The following attestation bundles were made for pytickersymbols-1.17.9.tar.gz:
Publisher:
release.yml on portfolioplus/pytickersymbols
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytickersymbols-1.17.9.tar.gz -
Subject digest:
d84ad92018bcebe1e419b104b5c7b209ee7faf16973f59ee4a5434a19667e7b9 - Sigstore transparency entry: 975053949
- Sigstore integration time:
-
Permalink:
portfolioplus/pytickersymbols@6785e627a3ac9e1a5a52f52d7694bc12d3b2517a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/portfolioplus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6785e627a3ac9e1a5a52f52d7694bc12d3b2517a -
Trigger Event:
pull_request
-
Statement type:
File details
Details for the file pytickersymbols-1.17.9-py3-none-any.whl.
File metadata
- Download URL: pytickersymbols-1.17.9-py3-none-any.whl
- Upload date:
- Size: 406.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
9d03b925adcdbc59c24350b2451429daa4365e0c761d7b16ebe039bc272837be
|
|
| MD5 |
ade87f1cc8fd8ed7d7c0cc8ca9d2686c
|
|
| BLAKE2b-256 |
31a54bb8ed5bfbb81c62485cab30ff75e5cceb474edcf7b09471cffa04e18402
|
Provenance
The following attestation bundles were made for pytickersymbols-1.17.9-py3-none-any.whl:
Publisher:
release.yml on portfolioplus/pytickersymbols
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
pytickersymbols-1.17.9-py3-none-any.whl -
Subject digest:
9d03b925adcdbc59c24350b2451429daa4365e0c761d7b16ebe039bc272837be - Sigstore transparency entry: 975053955
- Sigstore integration time:
-
Permalink:
portfolioplus/pytickersymbols@6785e627a3ac9e1a5a52f52d7694bc12d3b2517a -
Branch / Tag:
refs/heads/master - Owner: https://github.com/portfolioplus
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@6785e627a3ac9e1a5a52f52d7694bc12d3b2517a -
Trigger Event:
pull_request
-
Statement type: