Skip to main content

Dynamic Asset Allocation via Hidden Markov Models: An Analysis


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.



Conclusion

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

Popular posts from this blog

Gone Too Soon: The Story Of Dražen Petrović

In the 1989-90 season, the Portland Trail Blazers bought out Dražen Petrović’s contract with Real Madrid and convinced him to join the NBA. This would mark the start of a trailblazing career that was tragically cut short.        Dražen Petrović was born in Šibenik, Croatia on the 22 nd of October, 1964. At the age of 15, he was already in the first team of his hometown club, and by the age of 18, Petrović had blossomed into a star for Šibenik. After serving in the military for a year, he moved to Cibona in 1984, where he would play till 1988. At Cibona, Petrović shined. He once scored 112 points in a Yugoslavian League game ( 40/60 FG, 10/20 3Pts, 22/22 FT), which is possibly the most efficient performance in any European league ever. He averaged 37.7 points in the Yugoslavian first division and 33.8 points in European competitions in his 4 years at Cibona, cementing his status as a European star. In 1988, at the age of 23, he moved to Real Madrid, where he stayed ...

JEPQ vs. QQQ: Finding Signals in the Noise

As a first-time investor, researching on what financial instruments to invest in, I narrowed my options to two technology ETFs, JEPQ and QQQ. QQQ tracks the NASDAQ 100 index, meaning its fluctuations are tied to that of the NASDAQ 100. JEPQ tracks some of the top stocks in the NASDAQ 100, and sells covered calls to generate monthly dividends for investors. On paper, it seems like JEPQ is for more conservative investors, capping the potential gains with the calls, but also insuring against sharp falls. QQQ, on the other hand, is subject to the whims of the market, with the potential for large gains, but also the risk of steep falls. I wanted to leverage my expertise with data, and see if there were any patterns or trends that I could spot, that would give me a better chance of having success with my investments. For this, I used the daily price data for JEPQ and QQQ from May 4 th , 2022, to December 25 th , 2025. If I invested on Day 1, what would be my total return on Day x ? To an...

Statistics to Help the Spurs

Every sports fan, diehard or casual, has watched Moneyball, the movie about the use of statistics in baseball. While sports has become more receptive to the use of statistics to identify players, many fans still do not like to use or misuse statistics to back up their opinions. As an avid NBA fan, I too love to concoct fictitious trades to help make my team better. Through the use of statistics, I am going to try to make well informed decisions regarding player acquisitions for the San Antonio Spurs, my favourite NBA team. To tackle this problem, I used a linear regression model. To create the model, I first collected box score data for the Spurs’ 2019-20 season. This data was then used to create a model that will give a composite score, which predicts a team’s record. According to the model, a score closer to 1 indicates a better record, while a score closer to 0 indicates a worse record. Using Basketball Reference, I identified 8 players who the Spurs could feasibly acquire and who...