Stock Market Prediction Using Recurrent Neural
Network
K. Ritwik Reddy B. Tarun Kumar V. Rohit Ganesh
Department of CSE (AI & ML) Department of CSE (AI & ML) Department of CSE (AI & ML)
Vardhaman College of Engineering, Vardhaman College of Engineering, Vardhaman College of Engineering,
Hyderabad, India Hyderabad, India Hyderabad, India
kolanritwikreddy20aiml@[Link] barkatarunkumar21aiml@[Link] rohitganeshveepuri20aiml@[Link]
Polisetty Swetha Prakash Kumar Sarangi
2022 IEEE International Conference on Current Development in Engineering and Technology (CCET) | 978-1-6654-5415-5/22/$31.00 ©2022 IEEE
Department of CSE (AI & ML) Department of CSE (AI & ML)
Vardhaman College of Engineering, Hyderabad, India Vardhaman College of Engineering, Hyderabad, India
swethabharath27@[Link] Prakashsarangi89@[Link]
Abstract— In the current world for investing money in the The prediction of financial stock market price is vital role
stock market is challenging forum and it also requires a lot of for different researchers. There are lots of work done by
brainstorming. Since financial stock market is volatile in many researchers related to field of AI, ML, and DL. In
nature. So, it is very difficult to predict. There are some addition to these models’ other approaches also can adopt
algorithms related to subject like Artificial Intelligence (AI), like Reinforcement Learning etc. Here using this deep
Machine Learning (ML), and Deep Learning (DL), which can learning model, we can predict the future stocks prices but
give efficient accuracy compare to other techniques. In this only for the short period of time after that it won’t be able
paper, our objective to predict financial stock market price to predict [3].
using Deep Learning techniques like Recurrent Neural
Network (RNN) and in particular Long-Short Term Memory It is because due the complexity errors occurring in the
model (LSTM). Using RNN and LSTM techniques for model. They are also explained study stock market price
different datasets, we have to explore the accuracy by behaviour based on different bioinformatics techniques [4],
increasing number of epochs. [5]. There was a survey article which helped us a lot to
Keywords—Stock Market, Stock Market Prediction, RNN, understand the difference between the different models like
LSTM HMM, SVM, NLP, CNN etc [6], [7] ,[8]. Here by
researching more and more we came to know that at the
I. INTRODUCTION beginning of the prediction the researchers used the model
called ARIMA which was not quite successful but it helped
The Financial stock market is an important part of our them a lot on understanding the complications occurring in
country because it depends up on economic growth of a the prediction of the future stocks [9]. Here we came to
particular country. For prediction of financial stock market know that our model which is built using the RNN and
is not simple task. Still many researchers are already LSTM are the much efficient one to predict the future stock
published different model to predict future price and also models. The much needed action in the world of trading is
an algorithm which predicts the exact output of a given
behaviour of financial stock market. Although the
input, many data scientists and data analysts are working
prediction chance is 50-50 using manual prediction day and night only with one aim that is making data easily
method, there are some AI, ML, and DL based techniques accessible so that we can store that data and using the long
are predicted the stock market price with better accuracy. short-term memory the algorithm can easily predict the
output.
The main objective of our work is to build a model
that guides the person to invest in a particular stock in In this paper, our model work in a pipe line manner, in
which the there won’t be any risk factor. The system uses the section III we have explained our proposed model based
the data given by that person and then it RNN and LSTM on RNN and LSTM algorithm. In the section IV, find the
to come up with a solution and here we are also used the prediction result. Finally in the section V, we have
concluded our proposed model and explained try to explore
plotly dash, the dash we can define it as a python
in future using other models.
framework. Our model suggests to the person when and
where to invest the money to maximize the profits and the III. PROPOSED WORK
risk factor is also less. The database used to analyze the
In this work, our proposed model is based on a pipeline
problem and tries to find a suitable solution is already manner. There are some steps to get accuracy of the model.
present in the system. There are several Artificial Here output of one step will be input of another step. The
Intelligence, machine learning and deep learning details of the steps are explained in below proposed fig. 1.
techniques, which are used by different researchers [1] [2].
Here we have planned to make different from them by By using the RNN that is the recurrent neural network the
increasing number of epochs. proposed system can extract the historical data and then
predicts the future stocks. First of all the system will collect
some information from the user such as in what stocks he
II. LITERATURE REVIEW want to invest his money and how much amount is and how
much loss can he bear and also what is the duration of that
Authorized licensed use limited to: Graphic Era (Deemed to be University). Downloaded on December 15,2023 at 08:55:10 UTC from IEEE Xplore. Restrictions apply.
investment. After collecting all the information provided We know that RNN has long-term memory and as well as
by the user the system will apply the machine learning the short-term memory and this analogy refers to the name
algorithms and them it will give an optimal solution to the of LSTM.
user that which stock is safe for him to invest his money for
minimizing the risk of loss factor and earning the maximum
profits.
Fig. 2. Internal Structure of the LSTM network
C. Recurrent Neural Network
Fig. 1. Proposed Model of our work The RNN is an important model of deep learning
techniques which can be commonly used for temporal
problems, for example translation of language, processing
A. Gathering the Data
of natural language, speech recognition, and image
captioning as shown in fig. 3.
Here the system we have proposed requires some amount
of data from the dataset of one of the stock exchanges such
as the NSE that is the national stock exchange. In the stock
market websites, there are various datasets that are
available and these are available the various kinds of format
such as the datasets in the monthly format or else in daily
format datasets and also in the weekly format also. We have
used the daily format datasets is the suitable one, now we
should select any one stock exchange and choose the kind
of the data format.
Now in this world there are many stock exchange markets
available but we have collected for the NSE that is also
known as the national stock exchange. In India it is the
biggest stock exchange available for the traders of stock, It
is also having the biggest online digital exchange in which
the users will be getting the option to buy or sell their stocks
online without any complicated problems. It is the biggest Fig. 3. Overall architecture of RNN
stock exchange in the entire Asia.
Here the system requires the stocks which will trade on the D. Implementation Part
daily basis format. Those stocks can be chosen that are well
established in the market and their periodical graph of close In the above fig. 4, flow diagram is explained about details
price should be also great and it will be great if the selected steps to process our model using LSTM. In the step one,
stocks are traded constantly. In NSE stocks are divided into input the historical data set from any sources and filter
number of sectors and each sector will be having 100 of them. In the second step, these preprocessing date have
stocks and one stock from each sector will be selected. used for dimensionally reduce using Principal Component
Analysis (PCA) to get high weighted features. In next step,
divide the entire datasets into training and test data. Choose
B. Long Short-Term Memory
Tanh activation function and apply LSTM algorithm for
The LSTM algorithm is based on artificial neural prediction of stock market closing price. We have to choose
network which is a part of artificial intelligence and deep LSTM model with one LSTM layer, this LSTM layer is
learning. This model based on feed forward neural network having 32 units. This is following 1 neuron of one dense
model as shown in fig. 2. This kind of RNN can process layer. In the LSTM model structure in the training part, we
single data points and also entire sequences of data (such as have to set 100 epochs with a fit function having batch size
speech or video). Let us take an example LSTM is of 8.
applicable in many tasks such as robotic control and speech
recognition and many more. The most cited neural network From the dataset the ratio of splitting between training and
in 20th century was LSTM [10]. testing is 80:20. From the training model result compared
with the testing dataset and drawn the prediction accuracy.
Authorized licensed use limited to: Graphic Era (Deemed to be University). Downloaded on December 15,2023 at 08:55:10 UTC from IEEE Xplore. Restrictions apply.
Fig. 6. Actual vs Predicted closing price of Infosys stock data
From the fig. 6 indicates actual vs predicted stock closing
price of Infosys stock data. Here X-axis represents
sequentially trading days and Y-axis indicated actual and
predicted closing price of the stock market. Error rate
calculation and comparison with 20 years dataset Mean
Absolute Percentage Error (MAPE) is 5.98.
Fig. 4. General Procedure for LSTM algorithm
IV. EXPERIMENTAL RESULTS AND ANALYSIS
For the experimental study, 4 GB RAM, i3 processor,
Jupyter note book for python implementations is used. The
data sets of different companies like TCS, Microsoft,
Infosys, and TATA are collected from yahoo finance.
In this paper, we have taken four companies like Microsoft,
Infosys, TCS, and Tata. Then apply all dataset in to LSTM
algorithm and drawn some inferences. Fig. 5 indicates
actual vs predicted stock closing price of Microsoft stock
Fig. 7. Actual vs Predicted closing price of TCS stock data
data. Here X-axis represents sequentially trading days and
Y-axis indicated actual and predicted closing price of the
stock market. Error rate calculation and comparison with
20 years dataset Mean Absolute Percentage Error (MAPE)
is 5.37.
Fig.8. Actual vs Predicted closing price of TATA stock data
Fig.5. Actual vs Predicted closing price of Microsoft stock data From the fig. 7 indicates actual vs predicted stock closing
price of TCS stock data. Here X-axis represents
sequentially trading days and Y-axis indicated actual and
predicted closing price of the stock market. Error rate
calculation and comparison with 20 years dataset Mean
Absolute Percentage Error (MAPE) is 3.06.
From the fig. 8 indicates actual vs predicted stock closing
price of TATA stock data. Here X-axis represents
sequentially trading days and Y-axis indicated actual and
predicted closing price of the stock market. Error rate
Authorized licensed use limited to: Graphic Era (Deemed to be University). Downloaded on December 15,2023 at 08:55:10 UTC from IEEE Xplore. Restrictions apply.
calculation and comparison with 20 years dataset Mean
Absolute Percentage Error (MAPE) is 4.14.
V. CONCLUSION AND FUTURE WORK
The financial stock market trading is very much popular in
national and international level. For this reason, it is also
encouraged to researchers for doing research in this
particular field by using different techniques to predict
future stock market price and its behaviors. The main
objective is providing better accuracy by comparing with
other techniques. In our work, two models RNN, and
LSTM are used. The database sample which we have
chosen for our system worked perfectly for the system and
every sector behavior was also represented in the correct
way and this shows that our built model is huge success.
The forecasting algorithms such as the LSTM and RNN
also forecasted the closing price of one quarter year exactly.
Since stock market is very volatile in nature in one dataset
we are getting nearly 97 % accuracy. In future different
machine learning models and deep learning models can be
implemented with same dataset.
REFERENCES
[1] Moghar, Adil, and Mhamed Hamiche. "Stock market prediction
using LSTM recurrent neural network." Procedia Computer
Science 170 (2020): 1168-1173.
[2] Reddy, V. Kranthi Sai, and Kranthi Sai. "Stock market prediction
using machine learning." International Research Journal of
Engineering and Technology (IRJET) 5.10 (2018): 1033-1035.
[3] Sarangi, Prakash Kumar, Birendra Kumar Nayak, and
Sachidananda Dehuri. "A Compression-Based Technique for
Comparing Stock Market Patterns Behavior with Human
Genome." International Journal of Engineering Science and
Technology (2012): 0975-5462.
[4] Sarangi, Prakash Kumar, Birendra Kumar Nayak, and
Sachidananda Dehuri. "Stock Market Price Behavior Prediction
Using Markov Models: A Bioinformatics Approach." Data
Analytics in Bioinformatics: A Machine Learning
Perspective (2021): 485-505.
[5] Sarangi, Prakash Kumar, Birendra Kumar Nayak, and
Sachidananda Dehuri. "A Novel Approach for Prediction of Stock
Market Behavior Using Bioinformatics Techniques." Data
Analytics in Bioinformatics: A Machine Learning
Perspective (2021): 459-484.
[6] Sarangi, P. K., and B. K. Nayak. "Stock market behavior prediction
using pattern matching approach." International Journal of
Engineering and Computer Science (IJECS) 3 (2014): 2319-7242.
[7] Mohapatra, Srikanta Kumar, et al. "Text classification using NLP
based machine learning approach." AIP Conference Proceedings.
Vol. 2463. No. 1. AIP Publishing LLC, 2022.
[8] Sahu, Premananda, et al. "Detection and Classification of
Encephalon Tumor Using Extreme Learning Machine Learning
Algorithm Based on Deep Learning Method." Biologically Inspired
Techniques in Many Criteria Decision Making. Springer,
Singapore, 2022. 285-295.
[9] Bamunif, Abdullah Omar Ali. "Sports Information & Discussion
Forum Using Artificial Intelligence Techniques: A New
Approach." Turkish Journal of Computer and Mathematics
Education (TURCOMAT) 12.11 (2021): 2847-2854.
[10] Verma, Akhil. "Encryption and decryption of images based on
steganography and cryptography algorithms: a new
model." Turkish Journal of Computer and Mathematics Education
(TURCOMAT) 12.11 (2021): 2839-2846.
Authorized licensed use limited to: Graphic Era (Deemed to be University). Downloaded on December 15,2023 at 08:55:10 UTC from IEEE Xplore. Restrictions apply.