Skip to main content

brain-core

Core utilities, configuration, AST deduplication, and shared data models for the Brain Alpha Engine.

CI License: MIT PyPI Python 3.9+

brain_core is the foundational contract and utility layer for the 7-library Brain Alpha suite. It defines the canonical AlphaCandidate dataclass, manages environment configuration with deferred .env loading, provides AST-level expression deduplication, and coordinates multi-provider LLM failover. For the formal type contract and normalization invariants, see the whitepaper.

Installation

pip install brain-core

Quickstart

from brain_core import Config, get_logger, SimSettings, SimMetrics, AlphaCandidate
from brain_core.utils.dedup import ASTDeduplicator

cfg = Config.load_from_env()
log = get_logger(__name__)

# Normalize and deduplicate expressions canonically
dedup = ASTDeduplicator()
norm_expr = dedup.normalize_expression("close + open")

settings = SimSettings(universe="TOP3000", delay=1, decay=15)
candidate = AlphaCandidate(
    alpha_id="alpha_001",
    expression=norm_expr,
    category="option",
    generation_source="template",
    settings=settings,
)

Architecture

brain_core/
├── brain_core/
│   ├── __init__.py        # Public re-exports
│   ├── config.py          # Config dataclass + lazy env loader
│   ├── logger.py          # get_logger() factory
│   ├── llm.py             # Multi-provider LLM tier adapter
│   ├── py.typed           # PEP 561 typing marker
│   ├── types.py           # SimSettings, SimMetrics, AlphaCandidate
│   └── utils/
│       ├── __init__.py
│       └── dedup.py       # ASTDeduplicator canonical normalizer
├── tests/                 # Pytest test suite
└── docs/
    ├── API.md             # Complete API specification
    └── whitepaper.md      # Quantitative type contract & AST specification

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-alpha-core 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-alpha-core 0.1.0
File Size Uploaded
brain_alpha_core-0.1.0.tar.gz 15.2 kB Details

Built distribution (wheel)

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

Total release size: 29.7 kB

Release files / brain_alpha_core-0.1.0.tar.gz

Download URL brain_alpha_core-0.1.0.tar.gz
Size 15.2 kB
Tags Source
SHA-256 checksum
How to use checksums
673537b721146a401679695829ce7d4c7a14bd77862fa39e3288949541a91c6f
BLAKE2b-256 checksum
How to use checksums
3d74b1d8ec22fe632c67139a17ebe9a71467400d15436c6176aa0f66f94487a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.11.17

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

Download URL brain_alpha_core-0.1.0-py3-none-any.whl
Size 14.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
4028f1ffd300b8ec037ea4880acb2a2ea17f9431874401adba64cbeae91f3447
BLAKE2b-256 checksum
How to use checksums
856e1aa907b7299b5e75bbdd3fca228a1b88c510e465d666a11e1a7e72411601
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