About the Project

Why Aegis-X Exists

Most trading systems fail for a simple reason: they assume markets behave the same way all the time. In reality, markets move through distinct regimes — calm, stressed, and transitional — and strategies that ignore this reality suffer large drawdowns during crises.

Aegis-X was built with a different mindset. Instead of asking “Where will price go next?”, it asks:

“Is this a safe environment to deploy capital?”

The goal is not aggressive profit maximization, but capital survival, drawdown control, and long-term robustness — the same priorities used by professional risk managers.


What the System Does

Aegis-X is a risk-first, regime-adaptive trading system for U.S. markets.

Rather than predicting prices, it uses unsupervised machine learning to detect the current market regime and dynamically adjust exposure.

  • In constructive regimes, capital is allocated to Equities (SPY)
  • In stress regimes, exposure is reduced or rotated into Defensive assets (TLT / Cash)

This allows the system to step aside during periods of elevated risk instead of riding market crashes.


Core Intelligence (Regime Detection)

The system uses a Gaussian Mixture Model (GMM) to cluster market behavior into latent regimes using structurally meaningful features:

  • Realized volatility (21-day, annualized)
  • Volatility acceleration
  • Medium-term momentum (63-day)
  • Distance from long-term trend (SMA-200)

Volatility is computed as:

$$ \sigma_{21} = \sqrt{252} \cdot \mathrm{StdDev}(r_{t-21:t}) $$

The cluster with higher average volatility is deterministically labeled as the Stress Regime, ensuring interpretability and auditability.


How Decisions Are Made (No Black Box)

Instead of binary signals, Aegis-X uses probabilistic confidence:

  • The GMM outputs regime probabilities
  • Probabilities are smoothed using a persistence filter
  • Asset allocation is adjusted continuously, not abruptly

Example (simplified):

if prob_stress > threshold:
    allocate_to = "TLT"
else:
    allocate_to = "SPY"

This reduces over-trading and prevents reaction to short-term noise.


Risk Management & Execution Discipline

The system enforces strict safety constraints:

  • No leverage
  • Kelly Criterion-based exposure scaling (with conservative caps)
  • Volatility-adjusted transaction costs
  • One-day execution lag to avoid look-ahead bias

Performance is evaluated using drawdowns, Calmar ratio, and crisis behavior, not just raw returns.


Validation Integrity

To ensure correctness:

  • An expanding-window walk-forward backtest is used
  • Models are retrained using only historical data available at the time
  • A true out-of-sample holdout is preserved

This prevents accidental future leakage — a common flaw in many trading demos.


What Makes This Different

  • Focuses on risk control, not prediction hype
  • Uses simple, explainable models instead of opaque deep learning
  • Explicitly documents limitations (e.g., stock-bond correlation breakdowns)
  • Designed with live deployment discipline in mind

Aegis-X is not a trading bot — it is a decision framework built to survive real markets.

Built With

  • language:-python-libraries:-pandas
  • matplotlib-data:-historical-u.s.-market-data-(spy
  • numpy
  • risk-based
  • scikit-learn
  • tlt)-methods:-unsupervised-learning
  • walk-forward-validation
Share this project:

Updates