In our last blog, we witnessed a typical attribute to the stock markets - stock returns tend to have mean reverting features. I.e. whenever stock prices fluctuate from their average, they eventually tend to revert back to their mean - especially if the return of an individual day is exceptionally large compared to the market return. This strategy is called follow the loser strategy, where wealth is transferred from over-performing stocks to underperforming believing that the market over- and undervaluates securities.

"We decided to get our hands on the data of all stocks in OMXH25 and see if we could employ a Mean Reverting strategy using algorithmic trading"

The outcome of our Machine Learning trading algorithm was that 1-day return was the most important variable with an importance of 21,7 % of the predictions. Our initial thoughts were: "How could we benefit from such information?"

We decided to get our hands on the data of all stocks in OMXH25 and see if we could employ a Mean Reverting strategy using algorithmic trading. The idea of this strategy is that if a stock's change of return is exceptional compared its corresponding securities, the algorithm either puts more or less weight on that specific stock.

What we believe is that whenever there is a big drop in a stock's price, investors tend to overreact and push the sell button too easily which further causes the price of a security to sink. This is where our algorithm detects this dip and puts more weight on that specific stock. In addition, the larger a price drop compared to the market, the more weight it assigns to the stock. Vice versa happens, when the returns are exceptionally high.

Eventually, for each day, the sum of weights equals 1, which means that we'll always have a position with our total wealth. In this algorithm we did not consider short selling as an option. Now lets see how this strategy worked out:

This strategy seems to be quite volatile, yet it was able to beat the market with a beta of 0.94 and Sharpe 1.28 (index Sharpe 0.78). The annualized return of the algorithmic strategy was 28.4 % wheras for the index it was 13.3 %.

To further demonstrate the rationale behind this strategy we'll make a quick analysis of it's performance. This is one of the best-performing scenarios the algorithm was able to trade.

On 04/08/2016 (lets call it day 0), price of Metsä Board Oyj sunk significantly compared to the market. With this information the algorithm takes a huge position with a weight of 67,4 % of the total wealth of the portfolio. On the next day (day 1), the rational behind the algorithm is unambiguous: The major raise of the previous day must mean overvaluation and it decides to sell all of its positions on METSA and assign weight on other securities. Again on day 2, the price-drop is rather large and the algorithm takes a major position in METSA.

Obviously, in this case, the weights are relatively high as the drop wasn't caused by systematic movement of the market but was more unsystematic movement of an individual security.Simultaneously the rest of the weights are assigned to other securities with a corresponding rationale.

This algorithm is made for skimming the butter from over extended dips of irrational markets.

We used closing prices of the index and all stocks of OMXH25 between 01-07-2013 and 12-07-2017. We had a total of 1159 observations. The model was created with R and data obtained from Google Finance.