Using LSTM to predict the stock prices of top 5 most profitable stocks in Kenya
# Nairobi-Securities-Exchange-Stock-Price-Prediction-Using-LSTM
Prediction of future movement of stock prices has been an important area of research for a long time.
The prevailing theories are that stock prices are totally random and unpredictable. This is backed by the school of thought of the efficient market hypothesis which affirms that it is impossible to predict stock prices accurately.
In spite of all this, there are formal propositions demonstrating that with the choice of appropriate variable and suitable modeling, it is possible to predict the future stock prices and stock price movement patterns, with a fairly high level of accuracy.
In this work, I propose an LSTM model for stock price prediction. For the purpose of this study, I have used five leading Kenyan stocks in the Nairobi Stock Exchange (NSE) during the period January 01, 2015 till July 19, 2021.I then built an LSTM neural network using the training data that consisted of the index records during January 02, 2015 till July 19, 2021. Using this model, I predicted the close values of the five stocks for the period July 01, 2020 till July 19, 2021.
I then, augmented the predictive power of the forecasting framework by fine-tuning the hyper parameters of the LSTM models so that it is ensured that validation losses stabilize with the increasing number of epochs, and the convergence of the validation accuracy is achieved.
I exploited the power of LSTM regression model in forecasting the future close values of the five stocks for the next 30 days. The results clearly indicate that the LSTM model for predicting the future close value of the five stocks is a fairly accurate model. Lastly, I implemented a trading bot that informs the user when to make Buy/Sell decisions.
Keywords: Stock Price Prediction, Regression, Long and Short-Term Memory Network, Nairobi Stock Exchange, Hyper parameters Tuning, Buy/Sell.