Machine Learning being such a buzzword lately. Everyone is talking about it. But who is actually using it? Here we demonstrate how to use decision tree learning to predict next day's price of OMXH25.
Our model is based on historical price changes of OMXH25. We gathered 1, 2, 3, 5, 7, 15 and 30-day price changes and asked a computer: "Can you predict next day's price with this information?"
Before we go to the actual results, its good to state the problems that backtests usually face. Our backtest uses closing prices, which might not be the price the algorithm would actually get. We also cant estimate the market effect that this strategy could have and lastly, we didn't consider transaction fees.
We asked a computer:
"Can you predict next day's price
with this information?"
We simulated this strategy with the idea where we buy OMXH25 when the prediction for the following day is positive and sell when it is negative. This is what we achieved:
Returns of the algorithm and the index between 10-02-2016 and 07-02-2018.
In theory, this strategy was profitable and it was able to beat the market. The algorithm also outperformed the index with a beta of 0.46 and Sharpe of 2.63 compared to index's Sharpe of 1.09. Annualised return for the algorithm is 49.1 %, whereas for index it was 28.1 %.
Importance of features learned autonomously by the computer.
When looking at the importance of features, we can notice that one day return has the greatest impact on the model's predictions. Other key features were 30 and 7-day returns. This is probably because the model was able to find mean reversion properties of prices and to make a technical analysis from returns - yet it is hard to look inside the machines so-called 'black-box' and really learn to know how it operates. For all we know, it operates in a way where it is able to outperform the market. All these trading rules are what the computer learned to do by itself. Isn't it fascinating?
"It is hard to look inside
the machines so-called 'black-box' and
really learn to know how it operates."
This is a simple example of using machine learning and algorithmic trading that you can easily try yourself. Stay tuned for more Algo/Quant trading posts.
We used closing prices of OMXH25 between 02-01-2014 and 08-02-2018. The model was trained with the first half of the data and validated with prices between 10-02-2016 and 07-02-2018. We had a total of 994 observations. The model was created with R and data obtained from Google Finance.