Advanced Algorithms

Adaptive strategies for high-frequency quantitative trading

🎯 Algorithm Suite

Our trading platform implements three complementary algorithm families optimized for different market conditions:

πŸ“Š Regime Detection

Hidden Markov Models identify market states (trending, mean-reverting, volatile) in real-time.

β†’ Adapts strategy selection dynamically

πŸ€– Agent-Based Models

Chiarella Multi-Agent simulates heterogeneous traders (fundamentalists, chartists, noise).

β†’ Predicts price impact & volatility

⚑ Adaptive Execution

CARA/Risk Parity/Sparse optimize portfolio allocation under risk constraints.

β†’ Maximizes Sharpe with controlled drawdowns

πŸ” Regime Detection via HMM

We use a 3-state Hidden Markov Model to classify market conditions:

\[ P(S_t | r_{1:t}) = \frac{P(r_t | S_t) \cdot \sum_{S_{t-1}} P(S_t | S_{t-1}) P(S_{t-1} | r_{1:t-1})}{\sum_{S_t} P(r_t | S_t) \cdot \sum_{S_{t-1}} P(S_t | S_{t-1}) P(S_{t-1} | r_{1:t-1})} \]

States

πŸ“ˆ Trending

Characteristics:

  • High autocorrelation
  • Low mean reversion
  • Positive momentum

Strategy: Breakout/Momentum

↔️ Mean-Reverting

Characteristics:

  • Negative autocorrelation
  • Fast reversion (Ο„ < 5 min)
  • Stable volatility

Strategy: Pairs/Stat Arb

πŸ’₯ Volatile

Characteristics:

  • High variance
  • Low predictability
  • News/event-driven

Strategy: Reduce exposure

Implementation

πŸ“Š Market Returnsr₁, rβ‚‚, …, rβ‚œ
↓
Forward PassΞ±[s,t] = P(rβ‚œ | Sβ‚œ=s) Γ— Ξ£ P(Sβ‚œ=s|Sβ‚œβ‚‹β‚=sβ€²) Ξ±[sβ€²,tβˆ’1]
↓
Backward PassΞ²[s,t] = Ξ£ P(rβ‚œβ‚Šβ‚|Sβ‚œβ‚Šβ‚=sβ€²) Γ— P(Sβ‚œβ‚Šβ‚=sβ€²|Sβ‚œ=s) Γ— Ξ²[sβ€²,t+1]
↓
Most Likely Statearg max_s Ξ±[s,t] Γ— Ξ²[s,t]
↓
Strategy SelectionMomentum / Mean-Reversion / Risk-Off

Performance: 85% accuracy on S&P 500 data (2018-2024), < 100ΞΌs latency per update.

πŸ€– Chiarella Agent-Based Model

Simulates market microstructure with 3 trader types:

\[ \frac{dp_t}{dt} = \lambda \left( \sum_{i=1}^N w_i D_i(p_t, F_t) \right) + \sigma_p dW_t \] where \( D_i \) is the demand function for agent type \(i\), \( F_t \) is fundamental value, \( \lambda \) is price adjustment speed.

πŸ“š Fundamentalists

\( D_F = \alpha_F (F_t - p_t) \)

Mean revert to fair value. Stabilizing force.

πŸ“ˆ Chartists

\( D_C = \alpha_C (p_t - p_{t-1}) \)

Follow trends. Destabilizing (momentum).

🎲 Noise Traders

\( D_N \sim \mathcal{N}(0, \sigma_N^2) \)

Random demand. Liquidity providers.

Price Dynamics

πŸ“ˆ ChartistsTrend Following
↓
πŸ“š FundamentalistsMean Reversion
←
Price
p(t)
β†’
🎲 Noise TradersRandomness
↓
Equilibrium: D_F + D_C + D_N = 0
↓
Stable Marketw_F > w_C β†’ Reversion to F
Volatile Marketw_C > w_F β†’ Bubbles / Crashes

Calibration: Fit \( \alpha_F, \alpha_C, w_i \) to historical order flow. Use case: Predict impact of large orders (>1% ADV).

⚑ Adaptive Portfolio Strategies

Three optimization frameworks for different objectives:

1. CARA (Constant Absolute Risk Aversion)

\[ \mathbf{w}^* = \arg\max_{\mathbf{w}} \left\{ \mathbf{w}^\top \boldsymbol{\mu} - \frac{\gamma}{2} \mathbf{w}^\top \boldsymbol{\Sigma} \mathbf{w} \right\} \] Subject to: \( \sum w_i = 1, \; w_i \geq 0 \)

Closed-form solution: \( \mathbf{w}^* = \frac{1}{\gamma} \boldsymbol{\Sigma}^{-1} \boldsymbol{\mu} \) (rescaled to sum to 1).

Best for: Short-term mean-reversion strategies with stable covariance.

2. Risk Parity

\[ \text{RC}_i = w_i \frac{\partial \sigma_p}{\partial w_i} = \frac{1}{N} \sigma_p \quad \forall i \] where \( \sigma_p = \sqrt{\mathbf{w}^\top \boldsymbol{\Sigma} \mathbf{w}} \) is portfolio volatility.

Equalizes risk contribution across assets. Best for: Diversified portfolios with heterogeneous volatilities.

3. Sparse Optimization (L1 Penalty)

\[ \mathbf{w}^* = \arg\min_{\mathbf{w}} \left\{ \mathbf{w}^\top \boldsymbol{\Sigma} \mathbf{w} - \lambda \mathbf{w}^\top \boldsymbol{\mu} + \rho \|\mathbf{w}\|_1 \right\} \]

Promotes sparsity (few non-zero positions). Best for: High transaction costs, limited capital.

Without Sparse Penalty (ρ=0)

95 assets with w > 0.001 Β· Transaction Costs: 2.1% Β· Turnover: High

With Sparse Penalty (ρ=0.05)

Only 12 assets selected Β· Transaction Costs: 0.3% Β· Turnover: Low

πŸ”„ Integration: Adaptive Pipeline

1

Data β†’ Regime Detection (HMM)

Market Data (1-min bars) β†’ Viterbi Algorithm β†’ State: {Trending, Mean-Reverting, Volatile}

β†’ Confidence: 0.87
↓
2

Regime β†’ Strategy Selection

Trending β†’ Momentum Β· Mean-Reverting β†’ Stat Arb Β· Volatile β†’ Risk-Off

β†’ Selected: Mean-Reverting (confidence > 0.8)
↓
3

Strategy β†’ Chiarella Simulation

Ξ±_F=0.5, Ξ±_C=0.3, w_F=0.6, w_C=0.3, w_N=0.1 Β· 1000 paths (Ξ”t=1s, horizon=5min)

β†’ Expected Price: $105.23 (Β±0.15) Β· Impact: βˆ’0.08%
↓
4

Position Sizing β†’ Adaptive Optimization

High Costs β†’ Sparse (L1) Β· Low Costs β†’ Risk Parity Β· Mean-Reversion β†’ CARA (Ξ³=2.0)

β†’ w* = [0.35, 0.28, 0.20, 0.12, 0.05]
↓
5

Execution β†’ Trade Signals

Generate orders β†’ TWAP/VWAP slicing β†’ Send to broker β†’ Monitor fills β†’ Loop

πŸ“Š Performance Metrics

Sharpe Ratio

2.8

Annualized (2023-2024 backtest)

Max Drawdown

-8.2%

Controlled by risk parity

Win Rate

62%

On 10,000+ trades

Regime-Specific Performance

πŸ“ˆ Trending

Sharpe: 3.2

Strategy: Momentum (breakout)

Avg Hold: 12 hours

↔️ Mean-Reverting

Sharpe: 4.1

Strategy: Stat Arb (pairs)

Avg Hold: 45 minutes

πŸ’₯ Volatile

Sharpe: 0.9

Strategy: Reduced exposure

Avg Hold: N/A (mostly flat)

πŸš€ Ressources & Documentation

πŸ““ Interactive Notebooks

πŸ”’ Unlock interactive Jupyter notebooks with an Educational or Professional account.

Try it out live by subscribing to a Hobbyist tier and access the interactive Streamlit platform.

Available notebooks:
β€’ Regime Detection (HMM)
β€’ Kalman Filter Market Making
β€’ Mean Field Games Portfolio
β€’ Differential Evolution
β€’ Sparse Mean Reversion

πŸ“š Theoretical Documentation

πŸ”¬ Regime Detection (HMM)

Hidden Markov Models theory with Forward-Backward and Viterbi algorithms

πŸ“Š Chiarella Agent-Based Model

Multi-agent market microstructure with heterogeneous traders (Fundamentalists, Chartists, Noise)

βš™οΈ Adaptive Portfolio Strategies

Risk Parity, Sparse L1 optimization, and CARA utility maximization

πŸ“‚ Browse all theoretical documentation β†’

πŸš€ Try it Live

🎯 Streamlit Interactive Platform

Test algorithms on real market data with an interactive interface

πŸ’³ View Pricing & Subscription Tiers

From Hobbyist (€9/month) to Professional (custom pricing)

πŸ†“ Free Beta Access

Try the platform with limited features. No credit card required.

Launch Beta β†’