brain-risk-model
Systematic factor premia, Betting-Against-Beta, and risk-model alpha generation engine for WorldQuant BRAIN.
brain_risk_model extracts systematic factor premia and risk anomalies from WorldQuant BRAIN risk model datasets (model51, model52, ValueScore: 7.0). It isolates the low-beta anomaly (Betting-Against-Beta), idiosyncratic volatility compression, and factor rotation into vector-neutral Fast Expressions with sub-industry neutralization. For institutional literature citations and mathematical factor derivations, see the whitepaper.
Installation
pip install brain-risk-model
Quickstart
from brain_risk_model import RiskModelAlphaEngine
engine = RiskModelAlphaEngine()
# Generate 5 systematic risk candidates
candidates = engine.generate_candidates(count=5)
for cand in candidates:
print(f"[{cand.archetype_name}] Universe: {cand.universe} Decay: {cand.decay}")
print(f"Formula: {cand.expression}\n")
Systematic Archetypes
| Archetype | Identifier | Core Factor Logic | Economic Hypothesis |
|---|---|---|---|
| Betting-Against-Beta | bab_low_beta |
ts_decay_linear(rank(-beta_last_60_days_spy), d) |
Leverage-constrained investors overbid high-beta assets, making low-beta assets structurally underpriced. |
| Idiosyncratic Volatility | idio_vol_discount |
ts_decay_linear(rank(-idio_vol_last_60_days), d) |
Stocks with high idiosyncratic volatility suffer from retail lottery demand and underperform over intermediate horizons. |
| Residual Momentum | residual_mom_spread |
rank(ts_decay_linear(mom - beta * spy_return, d)) |
Momentum calculated after stripping systematic market and sector beta generates superior risk-adjusted Sharpe. |
| Value-Growth Dispersion | val_growth_divergence |
rank(value_score) - rank(growth_score) |
Macro valuation dislocations between cash-flow multiples and speculative growth expectations revert cyclically. |
| Quality / Leverage Spread | quality_solvency_spread |
rank(fscore_bfl_quality) - rank(leverage_last_quarter) |
Isolates firms compounding returns with self-funded cash flow over debt-financed expansion. |
| Low-Risk Regime Gate | low_vol_regime |
trade_when(volatility_120 < ts_mean(...), rank(bab), -1) |
Activates factor exposure conditionally during calm volatility regimes when factor premia are most reliable. |
Architecture
brain_risk_model/
├── brain_risk_model/
│ ├── __init__.py # Public re-exports (RiskModelAlphaEngine, RiskModelCandidate)
│ ├── data/
│ │ └── catalog.json # Live BRAIN risk model field catalog
│ ├── catalog.py # RiskModelCatalog loader & field groupings
│ ├── archetypes.py # Systematic factor archetype 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 for all 6 archetypes
├── tests/ # Unit tests covering catalog, engine, strategies, templates
└── docs/
├── API.md # Complete API specification
└── whitepaper.md # Systematic risk model premia & BAB theory
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-risk-model 0.1.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | Provenance | Actions |
|---|---|---|---|---|
| brain_risk_model-0.1.0.tar.gz | 26.1 kB | Without provenance | Details for brain_risk_model-0.1.0.tar.gz |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Actions Reset |
|---|---|---|---|---|
| brain_risk_model-0.1.0-py3-none-any.whl | Python 3 | none | any | Details for brain_risk_model-0.1.0-py3-none-any.whl |
Total release size: 58.3 kB
Release files / brain_risk_model-0.1.0.tar.gz
| Download URL | brain_risk_model-0.1.0.tar.gz |
|---|---|
| Size | 26.1 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6e4d70da5d9291abcc9c1f43cf98f8725ee36b0734405f7fef5ae5371d2ef6f6
|
|
BLAKE2b-256 checksum How to use checksums |
5f11a9b3dffa4ddb94cafc09ffca28a135ec73aa28bfdfb70fc354d499c0bbd6
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Release files / brain_risk_model-0.1.0-py3-none-any.whl
| Download URL | brain_risk_model-0.1.0-py3-none-any.whl |
|---|---|
| Size | 32.2 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
052eb1dc95949d3cd7db41f9b7ece6c33d31c05fe43a40648ef7d9764262a989
|
|
BLAKE2b-256 checksum How to use checksums |
f01920240ec1a08bc29666a8396ebb06239eec5e6444ede637f00c6ebba48f0f
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
twine/7.0.0 CPython/3.14.7
|
Security for brain-risk-model 0.1.0
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.
No provenance found
None of the files in this release were uploaded with provenance metadata.
A note on package security
PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.
To learn more about protecting yourself from malicious actors, visit our package security documentation.