Skip to main content

Stock Recognizer 📈


GitHub Actions Workflow Status License Code style: black

Introduction

A hybrid Python library for extracting stock tickers and company names from messy social media text (Reddit, Twitter, etc.) — fast regex + market-data matching, with a GLiNER2 AI model layered on by default for higher recall. Pass use_ai=False for a lightweight, dependency-light instance when you only need the regex path.

The goal is to answer "what stocks is this post talking about?" — recognize() returns a deduplicated set of tickers per text. A symbol mentioned once or twenty times yields the same result; the focus is coverage of which tickers appear, not counting every occurrence. Accuracy is measured the same way (set-based, deduplicated per document), so a ticker only needs to be caught once to count as found.

Table of Contents 🗂

Key Features 🔑

  • Hybrid Engine: Combines Regex, financedatabase (Market Data), and GLiNER2 (AI).
  • Context Aware: Distinguishes between "DD" (Due Diligence) and "DD" (DuPont).
  • Yelling Protection: Smart filters for posts written in ALL CAPS.
  • Auto-Mapping: Automatically converts "Apple" or "TSMC" to AAPL and TSM.

Installation ⚙️

Installation can be done via pip:

pip install stock-recognizer

Usage ⌨️

from stock_recognizer import StockRecognizer

# Default: use_ai=True, most accurate.
# First run downloads the fine-tuned adapter from the HF Hub (cached after that)
recognizer = StockRecognizer()

text = "$PLAB DD: easy to understand TSMC supplier"
tickers_ai = recognizer.recognize_ai(text)
print(tickers_ai) # ['PLAB', 'TSM']

# Opt out of AI for a lighter, faster, regex + market-data-only path
fast_recognizer = StockRecognizer(use_ai=False)
tickers = fast_recognizer.recognize(text)
print(tickers) # ['PLAB'] (TSMC needs AI mapping)

Model Training 🧠

The GLiNER2 adapter behind recognize_ai() — scraping, labeling policy, training, and benchmarking — lives in the sibling stock-recognizer-model repo. StockRecognizer() (use_ai=True by default) fetches the trained adapter automatically from StephanAkkerman/stock-recognizer-model on the Hugging Face Hub (pass adapter_path= to use a local adapter instead, or adapter_revision= to pin a different published version).


Citation ✍️

If you use this project in your research, please cite as follows:

@misc{project_name,
  author  = {Stephan Akkerman},
  title   = {Stock Recognizer},
  year    = {2026},
  publisher = {GitHub},
  journal = {GitHub repository},
  howpublished = {\url{https://github.com/StephanAkkerman/stock-recognizer}}
}

Contributing 🛠

Contributions are welcome! If you have a feature request, bug report, or proposal for code refactoring, please feel free to open an issue on GitHub. We appreciate your help in improving this project.
https://github.com/StephanAkkerman/stock-recognizer/graphs/contributors

License 📜

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for stock-recognizer 0.2.1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for stock-recognizer 0.2.1
File Size Uploaded
stock_recognizer-0.2.1.tar.gz 25.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for stock-recognizer 0.2.1
File Interpreter ABI Platform
stock_recognizer-0.2.1-py3-none-any.whl Python 3 none any Details

Total release size: 39.8 kB

Release files / stock_recognizer-0.2.1.tar.gz

Download URL stock_recognizer-0.2.1.tar.gz
Size 25.5 kB
Tags Source
SHA-256 checksum
How to use checksums
428509df693db54aa8283b2368020951e78200bdd308ea409b121f98dc723d72
BLAKE2b-256 checksum
How to use checksums
60cda22ca9d7ed71c102eaae710ef6342649975ff0bc3a4f07ed3e850fa2ba1b
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 Sep 27, 2026.

Transparency log

Release files / stock_recognizer-0.2.1-py3-none-any.whl

Download URL stock_recognizer-0.2.1-py3-none-any.whl
Size 14.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4377d65be6ca3686d1860302c2d93b771f089449909b4e5876d013497ed61bed
BLAKE2b-256 checksum
How to use checksums
8bd89c79f9623e4fa986e0507d48d4fc689ad8a9eb1067896f05faf0703ec1e2
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 Sep 27, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.2.1 This release

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page