A comparative study of recurrent neural networks and statistical techniques for forecasting the stock prices of JSE-listed securities

Master Thesis


Permanent link to this Item
Journal Title
Link to Journal
Journal ISSN
Volume Title
As machine learning has developed, the attention of stock price forecasters has slowly shifted from traditional statistical forecasting techniques towards machine learning techniques. This study investigated whether machine learning techniques, in particular, recurrent neural networks, do indeed provide greater forecasting accuracy than traditional statistical techniques on the Johannesburg Securities' Exchanges' top forty stocks. The Johannesburg Securities Exchange represents the largest and most developed stock exchange in Africa, though limited research has been performed on the application of machine learning in forecasting stock prices on this exchange. Simple recurrent neural networks, Gated Recurrent Units and Long-Short Term Memory Units were thoroughly evaluated with a Convolutional Neural Network and a random forest were used as machine learning benchmarks. Historical data was collected for the period 2 January 2019 to 29 May 2020, with the 2019 calendar year being used as the training dataset. Both a train once and a Walkforward configuration were used. The number of input observations utilised were varied from four to fifteen observations whilst making forecasts from one up to ten timesteps into the future. The Mean Percentage Error was utilised to measure forecasting accuracy. Different configurations of the Neural Network models were assessed, including considering whether bidirectionality improved forecasting accuracy. The neural networks were run using two different datasets, the historical stock prices on its own and the historical stock prices with the market index (the JSE All Share Index) to determine whether including the market index improves forecasting accuracy. The study found that bidirectional neural networks provided more accurate forecasts than neural networks that did not incorporate bidirectionality. In particular, the Bidirectional Long Short-Term Memory provided the greatest forecasting accuracy for one step forecast whilst the Bidirectional GRU was more accurate two to eight time steps into the future with the Bidirectional LSTM model being more accurate for nine and ten time steps into the future. However, the classical statistical model, the theta method, significantly outperformed all machine learning models. This is likely the result of the unforeseen impact of the covid-19 pandemic on financial markets that would not have been factored into the training sets of the machine learning algorithms. . . .