Skip to content

lukasegger22/alpha-trinity-core

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Alpha Trinity: Adaptive Multi-Asset Allocation Engine via Hybrid Ensemble Learning

Python License Status Math

📉 Abstract

Alpha Trinity is a quantitative trading framework designed to solve the dynamic portfolio allocation problem across Equities, Cryptocurrencies, and Commodities. The system utilizes a Hybrid Ensemble Learning architecture ($N=10$) combining deep Multi-Layer Perceptrons (MLP) and Random Forests to forecast asset returns.

To mitigate tail risk, the engine integrates a Macro-Regime Sensing Module (XGBoost) that dynamically scales portfolio leverage ($\lambda_t$) based on volatility regimes and yield curve signals. The framework is engineered for institutional-grade robustness, featuring vectorized backtesting with realistic cost modeling (slippage, spread, and cost-of-carry).


📐 Mathematical Framework & Methodology

The core strategy models the optimal portfolio weight vector $w_t$ by maximizing the risk-adjusted expected return under regime-specific constraints.

1. Hybrid Ensemble Signal Generation

The predictive signal $\hat{y}_{t+1}$ (expected return) is derived from a consensus of heterogeneous weak learners to minimize variance:

$$\hat{y}_{t+1} = \frac{1}{K} \sum_{k=1}^{K} \phi_k(X_t)$$

Where:

  • $X_t$: Feature matrix at time $t$ (Technical indicators, Macro factors).
  • $\phi_k$: The prediction function of the $k$-th model.
  • The ensemble consists of 5 Deep Neural Networks (MLP) and 5 Random Forest Regressors ($K=10$).

2. Macro-Regime & Volatility Scaling

Risk exposure is dynamically adjusted using a volatility targeting mechanism controlled by the XGBoost Macro-Classifier ($M_t$):

$$ \text{Leverage}_t = \begin{cases} 1.6 & \text{if } VIX_t < \theta_{low} \text{ (Bull Regime)} \\ 1.0 & \text{if } \theta_{low} \leq VIX_t < \theta_{high} \text{ (Neutral)} \\ 0.0 & \text{if } VIX_t \geq \theta_{high} \text{ (Bear/Panic)} \end{cases} $$

3. Portfolio Optimization

The allocation engine solves a constrained Mean-Variance Optimization problem:

$$\max_{w} \left( w^T \hat{\mu} - \frac{\gamma}{2} w^T \Sigma w \right)$$

Subject to:

  • $\sum w_i = 1$ (Fully invested relative to leverage target)
  • $0 \leq w_i \leq 0.30$ (Diversification constraint)

🏗 System Architecture

The system is built on a modular ETL-Inference-Execution pipeline designed for reproducibility and speed.

graph TD
    A[Data Ingestion] -->|Yahoo/FRED API| B(ETL & Cleaning)
    B -->|Parquet Storage| C{Feature Engineering}
    C --> D[Macro Brain XGBoost]
    C --> E[Ensemble Models 5xNN + 5xRF]
    D -->|Regime Signal| F[Allocation Engine]
    E -->|Return Forecast| F
    F -->|Vectorized Logic| G[Backtesting & Risk Check]
    G -->|Tearsheet| H[Performance Reporting]
Loading

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages