ticker-classifier
Introduction
ticker-classifier is a small Python library for classifying ticker-like symbols (for example AAPL, BTC, EUR, GOLD) into a simple market/category representation.
It uses Yahoo Finance for equities, CoinGecko for cryptocurrencies and a few heuristics for currencies/commodities. The output indicates the most likely category, a display name, market cap when available, and a yahoo_lookup value to fetch further data if desired.
Table of Contents 🗂
- Key Features
- Installation
- Usage
- API
- Development
- Release and Versioning
- Citation
- Contributing
- License
Key Features 🔑
- Classify symbols as
Equity,Crypto,Forex,Commodity,IndexorUnknown. - Adds
sectorandindustrymetadata for many equity tickers (for exampleAAPL,NVDA). - Adds a compact
company_profilepayload for equity/ETF symbols (exchange, country, currency, industry group, website, market-cap category). - Adds a
fundamentalspayload for equity/ETF symbols (forward/trailing P/E, forward/trailing EPS, NAV per share for funds/ETFs, 3-month and 10-day average volume, currency) read from the same Yahoo quote used for classification, so it costs no extra requests. Only fields Yahoo actually reported are included -- a missing field means unknown, never zero. - Uses multiple public APIs and simple heuristics to make robust decisions.
- Uses a generic Yahoo search fallback for unknown symbols so index names/aliases (for example
NASDAQ,FTSE,HANGSENG) can be resolved without manual per-ticker shortcuts. - Uses exact CoinGecko coin-name matching to resolve name-style crypto queries (for example
BITCOIN) and returns canonical symbols (BTC) instead of unrelated meme/derivative coins. - When CoinGecko price/market-cap requests are rate-limited or unavailable, crypto candidates can fallback to TradingView quote data to keep category detection resilient.
- Provides both synchronous and asynchronous APIs.
- Lightweight disk cache to avoid repeated lookups (
TickerCache).
Installation ⚙️
Install from pypi using this command:
pip install ticker-classifier
Usage ⌨️
Basic synchronous usage:
from ticker_classifier.classifier import TickerClassifier
classifier = TickerClassifier()
symbols = ["AAPL", "BTC", "EUR", "GOLD", "UNKNOWN123"]
results = classifier.classify(symbols)
for r in results:
print(r)
Example asynchronous usage:
import asyncio
from ticker_classifier.classifier import TickerClassifier
async def main():
classifier = TickerClassifier()
symbols = ["AAPL", "BTC", "ETH", "JPY"]
results = await classifier.classify_async(symbols)
for r in results:
print(r)
asyncio.run(main())
The output for each symbol is a dictionary like:
{'category': 'EQUITY', 'ticker': 'AAPL', 'name': 'Apple Inc.', 'market_cap': 4029017227264, 'sector': 'Information Technology', 'industry': 'Electronic Equipment, Instruments & Components', 'company_profile': {'industry_group': 'Technology Hardware & Equipment', 'country': 'United States', 'exchange': 'NASDAQ Global Select', 'currency': 'USD', 'website': 'http://www.apple.com', 'market_cap_category': 'Mega Cap'}, 'fundamentals': {'market_cap': 4029017227264, 'forward_pe': 30.7, 'trailing_pe': 41.1, 'eps_forward': 6.5, 'eps_trailing': 4.5, 'avg_volume': 54321000, 'avg_volume_10d': 48000000, 'currency': 'USD'}, 'yahoo_lookup': 'AAPL', 'alternatives': ['crypto'], 'source': 'api'}
{'category': 'crypto', 'ticker': 'BTC', 'name': 'Bitcoin', 'market_cap': 1736590593460.9607, 'yahoo_lookup': 'BTC-USD', 'alternatives': ['stock'], 'source': 'api'}
{'category': 'crypto', 'ticker': 'ETH', 'name': 'Ethereum', 'market_cap': 338145915081.1455, 'yahoo_lookup': 'ETH-USD', 'alternatives': ['stock'], 'source': 'cache'}
{'category': 'forex', 'ticker': 'JPY', 'name': 'JPY Currency', 'market_cap': None, 'yahoo_lookup': 'JPYUSD=X', 'alternatives': ['stock'], 'source': 'cache'}
Notes
- The classifier caches positive classifications (non-
Unknown) in an SQLite database (defaultticker_cache.db) for24hours by default. - You can customize the cache filename and expiry by passing
db_nameandhours_to_expiretoTickerClassifier.
API
ticker_classifier.classifier.TickerClassifierclassify(symbols: List[str]) -> List[dict]– synchronous classification.classify_async(symbols: List[str]) -> List[dict]– async classification.ticker_classifier.apis.yahoo.YahooClient– low-level Yahoo quote fetcher (sync + async helpers).ticker_classifier.apis.coingecko.CoinGeckoClient– crypto lookup + market cap helpers (sync + async).ticker_classifier.db.cache.TickerCache– tiny SQLite-backed cache used byTickerClassifier.
Development
Run formatting and linting tools you prefer (project uses black code style).
Run a quick smoke check by running the classifier.py module directly:
& .venv\Scripts\python.exe ticker_classifier\classifier.py
If you add tests, run them with your chosen test runner (e.g. pytest).
Release and Versioning
This package is published to PyPI through GitHub Actions:
- Workflow:
.github/workflows/publish.yml - Trigger: GitHub Release published
- Publisher:
pypa/gh-action-pypi-publishusing trusted publishing (OIDC)
Release flow:
- Update version in
pyproject.toml. - Update
ticker_classifier/__init__.py__version__to match. - Commit and push.
- Create a GitHub release with tag
vX.Y.Z(orX.Y.Z).
The publish workflow validates that the release tag version matches pyproject.toml before uploading to PyPI.
Citation ✍️
If you use this project in your research, please cite as follows (adjust metadata accordingly):
@misc{ticker-classifier,
author = {Stephan Akkerman},
title = {ticker-classifier},
year = {2025},
publisher = {GitHub},
howpublished = {\url{https://github.com/StephanAkkerman/ticker-classifier}}
}
Contributing 🛠
Contributions are welcome. Suggested workflow:
- Fork the repository and create a feature branch.
- Run tests and format your changes with
black. - Open a pull request with a clear description of the change.
Please open issues for feature requests or bugs and include a small reproducible example when possible.
License 📜
This project is licensed under the MIT License. See the LICENSE file for details.
Metadata
Release files for ticker-classifier 0.1.6
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| ticker_classifier-0.1.6.tar.gz | 24.2 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| ticker_classifier-0.1.6-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 47.5 kB
Release files / ticker_classifier-0.1.6.tar.gz
| Download URL | ticker_classifier-0.1.6.tar.gz |
|---|---|
| Size | 24.2 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
3305ddbc9af50a4092b2e677d51f2504822175af5bc57b265416c2f177cb80bf
|
|
BLAKE2b-256 checksum How to use checksums |
8925b829905e1eaa47124bb1d479507fc2295d384213e81309de7d53ec8fa589
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency logRelease files / ticker_classifier-0.1.6-py3-none-any.whl
| Download URL | ticker_classifier-0.1.6-py3-none-any.whl |
|---|---|
| Size | 23.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
e6e097e3aa5d5dba8992aca97f0e2ef0fb68b136ac80b4182b785f5d0a79b2c9
|
|
BLAKE2b-256 checksum How to use checksums |
de8678f24a2326c571033560e15a6eda67003212a8848a1cf9e5f8c6c768b7c0
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/7.0.0 CPython/3.13.14
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on Oct 2, 2026.
Transparency log