Stock Price Prediction Using Machine Learning and LSTM-Based Deep
Learning Models
Abstract
Prediction of stock prices has been an important area of research for a
long time. While supporters of the efficient market hypothesis
believe that it is impossible to predict stock prices accurately, there
are formal propositions demonstrating that accurate modeling and
designing of appropriate variables may lead to models using which stock
prices and stock price movement patterns can be very accurately
predicted. Researchers have also worked on technical analysis of stocks
with a goal of identifying patterns in the stock price movements using
advanced data mining techniques. In this work, we propose an approach of
hybrid modeling for stock price prediction building different machine
learning and deep learning-based models. For the purpose of our study,
we have used NIFTY 50 index values of the National Stock Exchange (NSE)
of India, during the period December 29, 2014 till July 31, 2020. We
have built eight regression models using the training data that
consisted of NIFTY 50 index records from December 29, 2014 till December
28, 2018. Using these regression models, we predicted the open
values of NIFTY 50 for the period December 31, 2018 till July 31, 2020.
We, then, augment the predictive power of our forecasting framework by
building four deep learning-based regression models using long-and
short-term memory (LSTM) networks with a novel approach of walk-forward
validation. Using the grid-searching technique, the hyperparameters of
the LSTM models are optimized so that it is ensured that validation
losses stabilize with the increasing number of epochs, and the
convergence of the validation accuracy is achieved. We exploit the power
of LSTM regression models in forecasting the future NIFTY 50 open
values using four different models that differ in their architecture and
in the structure of their input data. Extensive results are presented on
various metrics for all the regression models. The results clearly
indicate that the LSTM-based univariate model that uses one-week prior
data as input for predicting the next week’s open value of the
NIFTY 50 time series is the most accurate model.