A look at how Machine Learning is used in the stock market
Machine Learning provides machines with the ability to learn autonomously based on experiences, observations and analysing patterns within a given data set without any explicit programming.
The difference between a normal algorithm and a machine learning algorithm is the “learning” model, which allows the machine to learn from the data, and make its own decisions. This allows it to perform tasks which are otherwise impossible for it to perform. Such tasks can be as simple as recognizing human handwriting, or as complex as self-driving cars!
Why have traders started to learn and use machine learning?
The financial market generates a large volume of data. Thus, it is very difficult for a trader to study the data to find a pattern and then devise a strategy which works on it. Machine learning algorithms can be used to go through the data and create strategies that can assist us in predicting the asset prices with a significant amount of precision
How to use a machine learning algorithm for trading?
A trading strategy is created primarily to predict whether we should buy, sell, or remain neutral in the current market scenario.
We first create a data set of the historical prices of a stock (or other relevant inputs like fundamental data). To make sure that the algorithm created is not specific to a time period and can be generalized, we divide the data into parts, training data and test data.
We use the training data to train our algorithm and make a prediction on the future price of a stock. Once the algorithm is developed, we use it on the test data and analyse the performance of the algorithm by comparing the predicted trend to the actual performance of the stock.
Traders who have developed their strategies based on solid quantitative research and backtested their strategies in a scientific way have greater chances of performing better in live trading.
Let’s look at an example where a machine learning algorithm can be used to predict the trend of a specific stock market index, based on its relationship with the global stock markets.
In this specific example, we use the closing prices of major stock markets’ indices as input. The machine learning algorithm takes the data of the world’s major stock indices (a stock market index is a selection of a specific number of stocks in the exchange) and compares it to the S&P 500, which is an index consisting of 500 companies of the New York Stock Exchange (NYSE).
We are looking for a relation between the movement in overseas markets and the US stock market (S&P 500). If we find that the movements of the two instruments’ prices are in the same (or opposite) direction as the S&P 500 more often than not, we say that these two are related. As training data, we use the data for the year 2017.
Using machine learning, we find that the following are closely related to the S&P 500:
- Top 30 stocks of the German stock exchange (DAX)
- Price of the Australian dollar with respect to the US dollar (AUD/USD)
- International oil price (Brent crude)
Finally, we compare the simulated results of our model against the test data which is the price data for the year 2018. Based on the comparison of the simulated price against the test data, we can understand how precise the algorithm is.
Once we are reasonably confident of our algorithm, we will use it for trading. While an actual trading strategy would be complex, for this example, we will assume that we simply buy if the prediction is for the prices going higher, and sell when otherwise.
Machine learning has helped humans automate their tasks so that we can spend more time on research and development of strategies. The alternative is the traditional approach of coming up with trading hypotheses from experience or research and test them.
In the competitive world of trading, this traditional approach can leave you with a minuscule alpha (excess return of a strategy when compared to the returns of the market as a whole). Machine learning allows us to discover potentially new and hidden alpha in our trading and investment universe.
(The Author is Vice President, QuantInsti)