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 ...

An Analysis of Car and Driver Impact on Formula 1 Success - Part 2

  In the previous part of this project, I looked at the variables I was using, and some of the trends that I identified through a preliminary analysis. Part 2 of this project is dedicated to:  - The research questions I formulated  - The statistical analyses that I used for each question  - The interpretation of my analysis  - What conclusions I was able to draw to answer each research question Research Questions Based on my preliminary analysis of the variables that I was working with, I came up with more questions that I was interested in exploring, in addition to my original goal of figuring out whether the car or driver was more crucial to Formula 1 success. One of the first things that piqued my interest was how the different points systems affected overall scoring. While it was immediately clear that the change in point scoring systems from 10 points for a win to 25 points for a win resulted in drastic changes to the point totals, my hypothesis was ...

The Evolution Of Moreyball

Most casual NBA fans know the term ‘Moreyball’ from watching the Houston Rockets. It gets it name from the Rockets’ GM, Daryl Morey, who helped turn Houston from also-rans into consistent championship contenders. But most people don’t know the origins of Moreyball and how it evolved into its current form. Moreyball has its roots in analytics, consistent with Morey’s status as a co-founder of the MIT Sloan Sports Analytics Conference. The essence of the style is to take analytics-friendly shots (3 pointers and shots at the rim) while reducing the amount of non-analytical friendly shots (the long two or mid-range shot). This is mainly achieved by surrounding a big man with four shooters, ensuring that both 3-pointers as well as shots at the rim are taken. One of the first iterations of Moreyball was showcased by the 2009 Orlando Magic, who surrounded star center Dwight Howard with four shooters. This novel idea helped the Magic reach the 2009 NBA Finals, where they would go on to los...