This notebook uses a hidden Markov model, or HMM, to estimate whether the market is in a low, normal or high volatility regime. One of its inputs is downside semivariance. The code splits SPY's daily variation by the sign of its return and uses the portion associated with flat or down sessions. Original notebook
From regime to weights
Once it estimates the regime, the notebook picks how to allocate the portfolio.
| Regime | Allocation rule |
|---|---|
| Low volatility | Searches for the weights with the highest estimated Sharpe using the available history. |
| Normal volatility | Groups assets that tend to move together and spreads risk across groups. |
| High volatility | Gives more weight to the defensive assets with lower estimated volatility. |
The Docker replay recorded 56 rebalance decisions. The strategy used the low-volatility rule 19 times, the normal rule 28 times and the high-volatility rule 9 times. The log identifies the rule used before the weights were calculated and simulated orders placed at the next open.
The historical result
From February 2014 to December 2018, the portfolio gained 2.91% net versus 18.89% for URTH. Its maximum drawdown was 16.80%, compared with 20.72% for URTH. Prices exclude dividends. The simulation charges 0.10% of traded value and an initial 0.10% for the benchmark.
What the engine measured
Cumulative return
Worst drawdown from a peak
Ratios, with their 95% interval
- Strategy
- Reference: URTH
- Resampling range or 95% interval
Source: technical report of the test, linked below. Prices exclude dividends; the resampling uses the same historical series.
The technical report adds the margin of error to these figures. The Sharpe of the strategy was −0.13, with a 95% interval of −0.90 to 0.73. Against URTH, the average annual difference was −3.54%, with a t-statistic of −0.64: it cannot be told apart from zero.
When the same returns were resampled in blocks, the cumulative return fell between −21.11% and 36.70% in the central 90%, and the worst drawdown between 8.48% and 29.17%. What that resampling measures is explained in Block bootstrap and permutation Monte Carlo.
Test reports

How to read this document is explained in the guide to the technical report.
How to read both documents is in the guide to the technical report.
See Strateva's services if you want to check how your portfolio weights are set.