Skip to main content

brain-sentiment

Analyst revisions, PEAD, and sentiment alpha generation engine for WorldQuant BRAIN.

CI License: MIT PyPI Python 3.9+

brain_sentiment generates quantitative equity alphas on WorldQuant BRAIN sentiment and revision datasets (sentiment1, sentiment2, ValueScore: 8.0). It codifies Post-Earnings Announcement Drift (PEAD), Standardized Unexpected Earnings (SUE), and analyst revision diffusion into turnover-controlled (< 12%) Fast Expressions with sub-industry neutralization. For institutional literature citations and mathematical derivations, see the whitepaper.

Installation

pip install brain-sentiment

Quickstart

from brain_sentiment import SentimentAlphaEngine

engine = SentimentAlphaEngine()

# Generate 5 turnover-controlled sentiment candidates
candidates = engine.generate_candidates(count=5)

for cand in candidates:
    print(f"[{cand.tags}] {cand.expression}\n")

Core Sentiment Archetypes

Archetype Institutional Literature Economic Hypothesis ValueScore
SUE Drift Bernard & Thomas (1989) Standardized quarterly earnings surprises drift predictably for 60-90 days 8.0
Revision Breadth Chan et al. (1996) Net fraction of upward vs downward analyst revisions leads momentum 8.0
Dispersion Arbitrage Diether et al. (2002) Equities with high sell-side forecast disagreement suffer optimistic overpricing 8.0
Revision Divergence Livnat & Mendenhall (2006) Accelerating upward revisions lagging equity price provide reliable forward drift 8.0

Architecture

brain_sentiment/
├── brain_sentiment/
│   ├── __init__.py        # Public re-exports (SentimentAlphaEngine, SentimentCandidate)
│   ├── data/
│   │   └── catalog.json   # Live BRAIN sentiment field catalog
│   ├── catalog.py         # SentimentCatalog field groupings & loader
│   ├── archetypes.py      # Quantitative sentiment strategy descriptors
│   ├── dedup.py           # AST expression deduplicator (delegates to brain_core)
│   ├── generator.py       # Candidate generation engine
│   ├── py.typed           # PEP 561 typing marker
│   └── strategies/        # Modular strategy implementations (pead, revision_breadth)
├── tests/                 # Unit tests covering catalog, engine, strategies, templates
└── docs/
    ├── API.md             # Complete API specification
    └── whitepaper.md      # Quantitative sentiment theory & PEAD dynamics

Testing

pytest tests/ -v

Security

Report vulnerabilities per SECURITY.md.

Contributing

See CONTRIBUTING.md for contribution guidelines.

License

Released under the MIT License. Maintained by Xtley001.

Metadata

Release files for brain-sentiment 0.1.0

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

Source distribution (sdist)

Source distribution for brain-sentiment 0.1.0
File Size Uploaded
brain_sentiment-0.1.0.tar.gz 23.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for brain-sentiment 0.1.0
File Interpreter ABI Platform
brain_sentiment-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 54.2 kB

Release files / brain_sentiment-0.1.0.tar.gz

Download URL brain_sentiment-0.1.0.tar.gz
Size 23.5 kB
Tags Source
SHA-256 checksum
How to use checksums
639185b02cd7c0417555b7f24007ea1e7d36bb3eb46ce98eb9f12dab8f24a4c2
BLAKE2b-256 checksum
How to use checksums
8388780a8182752c6fec934d5559a035b80d5a586741bb068164ca23419c82ae
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release files / brain_sentiment-0.1.0-py3-none-any.whl

Download URL brain_sentiment-0.1.0-py3-none-any.whl
Size 30.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
683dbf931e652436a45bb08de185a6cbec5a261f0102756496948679a4ffd3f7
BLAKE2b-256 checksum
How to use checksums
893a5c7c13b65522ebeedf17d09e5285314b39b8ed1fac65403b2bb95ef3f26b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

Release history Release notifications | RSS feed

This release

0.1.0 This release

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