Here is a notebook I have created with an overview of two methods. The HMM was lifted from a post on QuantStart. The SVM is my own. I will post two backtests shortly.
Here is a notebook I have created with an overview of two methods. The HMM was lifted from a post on QuantStart. The SVM is my own. I will post two backtests shortly.
Here is a backtest with OCSVM on the SPY. The algo holds the SPY when the OCSVM detects a "normal" regime, and holds cash when an anomaly is detected. Note how cash is held during the 2008 and 2011 downturns and how, even by just holding the SPY as asset, it lowers beta by 30%.
Hi Luc,
Thanks for sharing.
In both implementations you measure the last 20 days returns, right? So in the algo it's implicitly assuming that the market is still in that regime?
That is, last 20 days = "abnormal" -> today is assumed "abormal".
When you use the word "unclustered" what kind of behavior do you think the regime detector is picking up on if you would say it with words?
Thanks again,
Bjarke
The HMM uses the a single day return and volume as features. i.e. if you train it with 1000 day of data, you have a (1000,2) training data set. The algo will use the previous day return and volume to determine the current day regime.
The SVM uses 20 day time series. So, if 1000 days of price data is used, the training data shape is (1000,20). The algo uses the previous 20 days prices to predict the current regime.
The SVM assumes that most of the 20 day time series will be clustered. All those clustered time series are assumed to be the "base" or "normal" regime. The outliers (or abnormal) to that cluster will be deemed a different regime then the "base" regime. That is somewhat a limitation of non-supervised learning, is that the learner will find clusters, but theses clusters need to be interpreted. In this case, the assumption the the base regime is a low vol, uptrending market and that the outlier regime is a higher vol. downtrending seems to hold by just looking at the notebook.
I hope I answer the question.
/Luc
Yes, thanks I understand i little better now.
For the SVM could you say that the assumption of clustered is detecting that they are similar? I.e. in a volatile downwards market (like we have now), many days will be up a lot or down a lot, whereas in a more tranquil market(your base case) most days will look alike (upwards tendency, but no big moves in either direction).
How do you program the SVM to see the latter as the base case? I can't suss that out from the code above.
Thanks!