Skip to main content

brain-decorrelator

Strategy-agnostic alpha decorrelation engine with plugin-based orthogonalization axes.

CI License: MIT PyPI Python 3.9+

brain_decorrelator transforms correlated alpha expressions into orthogonal variants that pass WorldQuant BRAIN's correlation gate ($|\rho| < 0.70$) while preserving underlying economic Sharpe. It operates across all quantitative domains (Options, Sentiment, Risk Models) via an extensible plugin registry. For detailed mathematical formulations and before/after empirical benchmarks, see the Axes Guide.

Installation

pip install brain-decorrelator

Quickstart

from brain_decorrelator import DecorrelationEngine

engine = DecorrelationEngine()

# Automatically applies all 6 registered orthogonal axes
variants = engine.generate_orthogonal_variants(
    expression="rank(implied_volatility_call_30)",
    base_sharpe=1.65,
    max_variants=5,
)

for v in variants:
    print(f"[{v.axis_name}] -> {v.transformed_expression}")

The 6 Universal Orthogonal Axes

Axis Transformation Logic WorldQuant BRAIN Syntax Typical $\rho$ Sharpe Retention
Velocity Temporal phase shift via rate-of-change and decay decay_linear(ts_delta(expr, 5), 10) 0.35–0.50 $85-92%$
Neutralization Multi-level factor and sector group residualization group_neutralize(rank(expr), sector) 0.42–0.58 $95-110%$
Volatility Gating Regime scaling conditional on market variance expr / (ts_std_dev(returns, 20) + 1e-4) 0.48–0.62 $90-96%$
Rank Convexity Concentrating portfolio weight in extreme tails power(rank(expr) - 0.5, 3) 0.55–0.68 $92-98%$
Volume Weighting Tilting towards liquid names to damp market friction expr * rank(volume / (adv20 + 1e-4)) 0.38–0.55 $88-94%$
Calendar Modulation Seasonality & turn-of-month institutional rebalancing if_else(day_of_month(0) <= 5, expr*1.2, expr*0.8) 0.60–0.68 $92-95%$

Extending with Custom Plugins

from brain_decorrelator import AxisPlugin, register_axis

@register_axis
class MoneynessInversionAxis(AxisPlugin):
    name = "moneyness_inversion"

    def apply(self, expression: str, context: dict) -> list[str]:
        return [f"-({expression})"]

Architecture

brain_decorrelator/
├── brain_decorrelator/
│   ├── __init__.py        # Public re-exports (DecorrelationEngine, register_axis, unregister_axis)
│   ├── plugin.py          # AxisPlugin ABC + thread-safe registry
│   ├── engine.py          # DecorrelationEngine — orchestrator & variant dedup
│   ├── py.typed           # PEP 561 typing marker
│   └── axes/
│       └── universal.py   # 6 domain-agnostic built-in orthogonal axes
├── tests/                 # Unit tests covering registry and all 6 axes
└── docs/
    ├── API.md             # Complete API specification
    └── AXES.md            # Mathematical formulations & worked examples

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-decorrelator 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-decorrelator 0.1.0
File Size Uploaded
brain_decorrelator-0.1.0.tar.gz 12.9 kB Details

Built distribution (wheel)

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

Total release size: 23.8 kB

Release files / brain_decorrelator-0.1.0.tar.gz

Download URL brain_decorrelator-0.1.0.tar.gz
Size 12.9 kB
Tags Source
SHA-256 checksum
How to use checksums
e7e0cd0a21984097a47771c2333f8db60bcb39d64c73cc5ee47be7d4ff26f4ff
BLAKE2b-256 checksum
How to use checksums
17cf6db79dea7c01ce935ec299b31da298941e2f7a0bd1aaace6bc4008d5fff3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.14.7

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

Download URL brain_decorrelator-0.1.0-py3-none-any.whl
Size 10.9 kB
Tags Python 3
SHA-256 checksum
How to use checksums
fed4fb6874edbdf26678b101d98226112a9e9aad2808f29f2c1ae7024d97fab1
BLAKE2b-256 checksum
How to use checksums
30681885ba171ee3ec9119f4f8ac74e6f4c9b0c6ead65a3d5864256c3129a838
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