In my previous analysis, I explored the structural trade-offs between pure growth equities via QQQ and options-derived income via JEPQ. While static back tests provided valuable insights into performance across historical market phases, I wanted to create a more rigorous quantitative analysis, taking into account the non-stationarity of financial markets.
To this
end, I developed an unsupervised 3-state Gaussian Hidden Markov Model (HMM)
that dynamically identifies market regimes in real-time and allocates capital
among QQQ, JEPQ, and Risk-Free Cash.
1.
Methodology & Unsupervised State Discovery
Feature
Engineering & Emission Selection
Rather than relying on ad-hoc technical indicators, the HMM relies on two mathematical features observed at daily frequency:
1. QQQ Daily Log Returns:
2. QQQ 5-Day Realized
Volatility:
These
emissions capture both price momentum and local volatility clustering.
Model
Mechanics & Expectation-Maximization
A
Gaussian HMM assumes that observed market returns and volatility are generated
by an unobserved (hidden) discrete state . The model parameters, (state mean vectors
, covariance matrices
, and transition probabilities
) are optimized iteratively using the Baum-Welch
algorithm (an implementation of Expectation-Maximization) without human bias or
manual threshold tuning.
2.
In-Sample Transition Dynamics & Regime Routing
To
prevent overfitting, the dataset was split chronologically into a 70% In-Sample
Training Set and a 30% Out-of-Sample (OOS) Test Set.
Fitting the HMM on the
training data yielded the following transition probability matrix :
Mathematical
Dwell Time & Regime Behavior
The
expected persistence (dwell time) of each state in trading days is derived
using :
A
notable structural pattern emerges from the transition matrix: the probability
of transitioning directly from a Bull / Low Vol regime into a Bear / High Vol
regime is . This indicates that markets do not jump
instantaneously from calm upward trends into acute crashes. Instead, volatility
expands into an intermediate Sideways / Medium Volatility buffer first (
). This intermediate state acts as an early-warning
signal, enabling the strategy to de-risk prior to full crash realization.
3.
Strict Out-of-Sample (OOS) Validation & Execution Lag
To ensure the strategy translates to live trading execution, the model was tested under strict out-of-sample conditions:
1. Frozen Parameters: The
trained HMM parameters () were locked and evaluated strictly on unseen
test data.
2. 1-Day Execution Lag (): To eliminate look-ahead bias, state
inference generated at time
dictates
asset allocation executed at time
.
3. Allocation Logic:
1. Bull State: 100% QQQ (Capitalize on uncapped equity growth).
2. Sideways State: 100% JEPQ (Harvest option yield in range-bound conditions).
3. Bear State: 100% Risk-Free Cash (Capital preservation during sell-offs).
4.
Out-of-Sample Performance Analysis
Risk-Adjusted Alpha & Drawdown Reduction
While QQQ and JEPQ suffered severe peak-to-trough drawdowns of -22.77% and -20.08% respectively, the OOS Dynamic Strategy restricted maximum drawdown to just -8.17%. The strategy achieved an OOS Sharpe Ratio of 1.0949 (vs. QQQ's 0.6872 and JEPQ's 0.6047) and a Sortino Ratio of 1.2738, which shows superior risk efficiency. The dynamic overlay also captured 92.2% of QQQ's annualized return (18.57% vs. 20.14%) while operating with nearly half the annualized risk (13.04% vs. 23.05%). This creates a lower volatility in the strategy as compared to operating solely in JEPQ or QQQ.
By
replacing fixed allocation rules with an unsupervised Gaussian Hidden Markov
Model, this framework demonstrates that quantitative regime-switching can
systematically reduce downside volatility without sacrificing long-term equity
compounding. The combination of intermediate state buffering, execution lag
enforcement, and out-of-sample validation provides a rigorous template for portfolio construction.




Comments
Post a Comment