In the same line of thoughts as last post, today we will look at a way to incorporate the GARCH volatility model we introduced yesterday to create a regime switching strategy.

It is often discussed on the blogosphere that high volatility is good for daily MR, see previous editions of the state of short-term mean-reversion report by Michael over at MarketSci here and the moderator of daily follow-through MR series by David at CSS Analytics here and here. Concurrently, a low volatility environment is usually a good environment for trend following strategies; see Jez Liberty’s state of trend following report here.

With this in mind, since we want to maximize our return we want to be trading the appropriate strategy based on the volatility environment. Using volatility we can switch between MR and TF strategies dynamically to better adapt to the current market paradigm. To do this we can classify current volatility by percentile using a 252 day lookback period. The resulting series oscillate between 0 and 1, and is smoothed using a 21 day percentrankSMA (developed by David Varadi) using a 252 day lookback period. We now have a back of the envelope smoothed volatility regime oscillator where reading greater than .5 indicate high volatility and smaller than .5 low volatility in place.

For the following example, the regime switching (RS) strategy will be as follows: if the oscilliator is greater than .5 we trade the MR strategy and we trade the TF strategy when the oscillator is below the .5 treshold. The MR strategy proxy is the RSI2, and the TF strategy proxy is the MA 50-200 crossover for this simple test. Results on the SPY are presented below with equity curves for MR only (red), TF only (blue), buy and hold (green) and RS (yellow). Note that for this test, the input for the volatility is the running 21 day standard deviation of returns (ie. historical volatility).

The RS strategy outperforms both MR and TF strategies over 10 years. But wait a minute, the post was about regime switching using volatility forecast, not historical volatility. Simple, to do so, we calculate the oscilliator using the results of the garch model introduced in the last post. We now have the RS strategy using volatility forecast, good news is: it performs better! Results below using GARCH forecast (gold) vs using historical volatility (grey).

As mentioned before on many other blogs, incorporating volatility forecast in a strategy seems to improve results in this regime switching strategy.

QF

thanks for the mention!

v. interesting as I was planning to do similar analysis based purely on a TF strat (with market selection based on ideal volatility conditions ranking).

Side question: do you measure the statistical significance of the superiority of one approach vs. another, ie GARCH forecast (gold) vs using historical volatility (grey)?

I’m tempted to use a bootstrap test based on the daily returns difference between two curves but somehow feel it’s not the ideal approach – any thoughts on this?

Thanks for the comment,

I didn’t yet look at the significance as the post was getting crowded for my taste. But I had planned to do it using a method similar to what you suggested for a lack of a better idea. I will keep thinking about it and drop you a line or mention my method in the actual post when it comes out. In the meantime if you think of a better way to do it, i’d welcome the input.

Cheers,

QF

Great post! Love your simplicity and practicality. What platform do you use to code your strategies?

Thank you for the feedback Troy, I am glad you like it. I use R for my research and the graphs published on the blog.

Cheers,

QF

Ah yes dumb me; from your previous post: “using tseries and quantmod libraries for R”. It’s just that your pretty graphs caught my eye 🙂 I started using R for stat analysis but am eager to start coding trading strats in it…

Regarding tradeability, can you post the number of trades, winning/losing, and percent gain/loss per trade and average. It would be good to see the sensitivity of the strategy to slippage/commissions. Great work.

QF – great site – as you know David pointed us here. Glad he did!

To be clear: The historical volatility you use is: historical 21 day volatility, then take a 252 day lookback using percent rank…. OR do you mean 252 day volatility using a 21 day lookback using percent rank? I think it is the former but it is a little unclear.

You are correct about the notion that this idea has been making the rounds on the blogospere. And while the notion does test out, my sense however, is that MR has some definate downside when volatility is high. Jan 08, early October 08, and late Jan 09 are all time periods where vol was high, and MR had significant drawdowns, largely because MR was trying to buy weaknesses and the market continued down. I think the idea backtests well because super low vol environments are almost always periods where the market is grinding up and MR suffers badly and being out of a MR strategy during the few times like this in the last decade has helped (early 03, most of 09). The idea I am trying to work on right now is marry the vol regime with some sort of a trendiness regime like ADX. Using a rising ADX to not use MR strategies would have helped avoid the drawdowns MR had in 08 that I mentioned. But ADX is quite noisy and the jitteryness of it gives too many regime switches that end up not working. If you have any ideas let us know! -Brad

Hi Brad,

Thank you for the comment, what you say is true. I think that to make the concept better, we need to factor in more than volatility only. On the top of my head I think of the fractal efficiency and a stretch measure could perform better than ADX. I will dig into it and perhaps expand on the concept to create a viable strategy in a future post.

Cheers

QF

Hey QF I got off on a tangent (a more interesting one too!) but could you answer this question: Is the historical volatility you use :historical 21 day volatility, then take a 252 day lookback using percent rank…. OR do you mean 252 day volatility using a 21 day lookback using percent rank? I think it is the former but it is a little unclear.

Hey Brad,

It is 21 day standard deviation, then take a 252 days percentrank. Once you have that series, I smoothed it using a percentrankSMA. Sorry I wasn’t clearer in the post. I’d be curious what your tangent is, if you care to share you can drop me a line over e-mail.

Cheers,

QF

Hallo QF,

I have discovered this blog now and I have also a question about the calculation.

Is the Volatility Ranking calculation something like MA(percentrank(Stdev(close,21),252),21) ?

Thanks

Ken

Hey Ken,

Welcome around! Then regarding your question, it is actually: percentrank(MA(percentrank(Stdev(close,21),252),21),250).

Hope this helpls.

QF

Hi QF,

Some R-code would be awesome!

Thanks,

-Mark-

hi QF,

thanks for the insights..!

just to play the devil’s advocate, it seems the difference between the equity curves using realized and predicted volatility seems to only stem from a few points in time where the predicted volatility gave better results. the rest of the time it seems to track each other. Not sure if with a few results one can make such a conclusion….

this also seems to be borne out by the fact that thngs like standard deviation etc., remain about the same.

Please dont take this as a criticism, but just as an observation ..

regards

bgpl

Hi bgpl,

Thanks for the comment, the issue you raise is pertinent. I will address it in the next post by testing the significance of the difference between the two strategies. Also keep in mind that we wouldn’t expect both strategies to be very different, this would ring a bell regarding the validity of the model. Both volatility series are very similar (see previous post) and as such the difference in strategy returns are going to be generated during these divergence moments. Moments where the volatility forecast performed better rather consistently.

Overall it performed in-line with my expectations; slightly better and highly correlated. However, you are right, I should have been more careful in the wording of my conclusion.

Cheers,

QF

hi QF,

would it be different results if you test using $VIX as a measure of predicted volatility instead of GARCH calculations ?

you may already have tried that -> does it change anything ?

regards,

bgpl

Hey bgpl,

You are somewhat cutting the grass under my feet! I am in the middle of the analysis and its somewhere on my to do list. I’ll post result this weekend or early next week. Great comment (and suggestion).

Cheers,

QF

hi QF,

i had already been using VIX instead of realized volatility in some othe systems, hence the comment.

i actually am more interested in analysis *IF* there is a difference on why there is that difference. That would mean GARCH calculation is somehow better for trading than the market’s estimation of future 30-day volatility.. (the vix). I’ll wait for your posting…

best,

bgpl

Hey bgpl,

Under the same rules, the RS strategy using $VIX only seem to work slightly worse (though it is way to small to be significant in my opinion). I’ll have a look on different time frame and with different assets in the near future.

Cheers

QF

thanks QF !

a few questions :

(a) when you say “slightly worse”, do you mean slightly worse with respect to the projected volatility numbers with GARCH, or with respect to the historical volatility numbers ? Also, i am curious if the few points in time where the GARCH provides better results the the HV numbers, does the VIX provide the same as well ?

(b) are you calculating the returns from dividends as well (only applicable in the trend following part, as the MR would probably not be in the market for that long…).

(c)

I’d gotten lazy in the past and just used HV for historical, and VIX for projected volatility instead of calculating the projected volatility using GARCH.

Now I think should use GARCH as well, since it may be useful if one is trading a basket of ETFs to calculate projected volatilty of each independently instead of using VIX (only applicable for SPY). I think i will follow your same approach of using R for the GARCH calculation.

thanks again,

bgpl

Hey bgpl,

a) I will post on GARCH vs VIX for the RS strategy this week so you will see for yourself and I will make sure to address your question in it.

b) I used dividend adjusted values.

c) Glad to know that I can give new ideas to people, doing this and exchanging with other researchers is why I started the blog in the first place. I definitely think that it is an useful technique that can be easily applied to a vast universe of instrument. Also, I would imagine that the volatility structure is not the same for different asset classes (SPY vs GLD for example) the use for a volatility forecasting model not directly related to VIX could be helpful. Thank you very much for the comments.

Cheers

QF

Very interesting test and inquiries regarding vol indeed.

The improvement possibility is in the fact that vol forecasting is different accross different methodologies (GARCH vs. Historical vs. Implied) and across different periods ( days vs. 1 months vs. 3 months etc ) and across different asset classes ( Equities vs. Commodities vs. Currencies etc.)

You gotta find the right one for the specific strategy for specific underlying and specific period. Some inspiration is here:

http://ideas.repec.org/p/hhs/rbnkwp/0088.html

http://papers.ssrn.com/sol3/papers.cfm?abstract_id=6881

Click to access Vol_Forecast1.pdf

Click to access jlaws1004.PDF

Now if we talk only S&P underlying, for example, interesingly, GARCH is oftentimes better than VIX. The problem with VIX is that it overblows volatility after recent negative events, carrying it forward, while the reality has changed for the better in low realized vol and the reverse when previous vol was low. [stock process is antropological so I can assume this is sort of like if a person traumatized in one relationship (fear) carries the fear forward without need to the next relationship but the next+1 relationship is when fear subsides. Reverse is when relationship fear totaly subsides that the blow is coming lol :)]

In this case having VIX and subtracting from it the VIX Vol Arbitrage Index (e.g. S&P 500 Volatility Arbitrage Index) brings much better results than GARCH or others, with the exception of 2008. So just watch out for irrational exhuberance or other crash possibility indicators like peak in economic cycle models etc. Same with low vol – look out for crash possibility indicators.

Would love to take if further. If you provide R code would be even easier. Were you thinking to implement on S&P 500 ?

Cheers,

Vas

Hi QF, good posts !

Love the idea to switch between MR and TF strategies regarding volatility regimes.

Howevere, have you tested this during the 90s ? Because by experience I don’t believe MR strategies were quick efficient back then, and don’t believe historical/implied/GARCH volatility behaved that different as the time…

Just my 2 cents !

Thanks,

Phil

hi, QF. i m quite confused about the percentrank function.

first, you take Stdev(close,21) to get a current volatility based on past 21 days price.

then, you take percentrank(Stdev(close,21),252) to see how this current volatility ranks compared to history

after this, you take MA(percentrank(Stdev(close,21),252),21) to see, in the past 21 days, on average how this current volatility level ranks compared to history.

if i am right till now, what does it mean to finally use

percentrank(MA(percentrank(Stdev(close,21),252),21),250) ???

thanks