Stock Market Prediction Using Deep Learning
Stock Market Prediction Using Deep Learning
https://doi.org/10.22214/ijraset.2022.41159
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
Abstract: Stock market is very uncertain and highly volatile as the prices of stocks keep fluctuating due to several factors that
make prediction of stocks a very difficult and complicated task. In the finance and trading world stock analysis and trading is a
method for investors and traders to make buying and selling decisions. Investors and traders try to gain an edge in the markets
by taking informed decisions by studying and evaluating past and current data. Stock market prediction has always been an
important research topic in the financial and trading field [2]. Prediction of stock market is the act of trying to determine the
future value of a company stock (nifty & sensex) or other financial instrument traded on an exchange. Our project explains the
prediction of a stock using Machine Learning, which itself employs different models to make prediction easier and authentic.
The paper focuses on the use of Recurrent Neural Networks (RNN) called Long Short Term Memory (LSTM) to predict stock
values. This will help us provide more accurate results when compared to existing stock price prediction algorithms. The eminent
analysis of the stock will be an asset for the stock market investors and will provide real-life solutions to the problems and also
yield significant profit.
Keywords: Stock Price Prediction, Machine Learning, Long Short-Term Memory, Recurrent Neural Networks
I. INTRODUCTION
Stock markets can be defined as dynamic, unpredictable, non-linear and highly volatile in nature. Stock price predictions are very
important among many business people and retail investors. Predicting stock market prices is a difficult and challenging task as they
are complex and diverse and it depends on various economic factors like economic uncertainty, company’s financial reports and
performance and price indicator as well as non-economic factors such as political conditions, and investor’s expectations, etc. The
prices of stocks are mainly governed by demand and supply, and the ultimate goal of buying shares is to make money by buying
stocks in companies whose share price is expected to jump up [6]. Therefore to obtain higher trading profits and reduce unnecessary
losses, the investors usually expect various techniques to predict and analyse the stock price movements and various trends. Stock
market prediction therefore has been a major research topic among researchers in the financial area and captivates the attention of
many investors. Interpreting the stock price pattern of a particular company by considering their past data and predicting their future
growth and financial development will be highly beneficial.
There are two common methods of attempting to forecast stock prices of an organization. The first is fundamental analysis, which
considers external factors like company profile, market situation, political and economic factors, textual-information in the form of
financial news articles, social media and even blogs by economic investigators. The second is technical analysis, that attempts to
find patterns in charts and use past price trends of stocks like closing and opening price, volume traded, adjacent close values and
many more, to predict future price action. Nowadays, for predicting stock prices, advanced intelligent techniques based on either
technical or fundamental analysis are used.
Based on the data of historical stocks the stock price can be predicted. The most promising and prominent technique involves the
use of Recurrent Neural Networks (RNN), that is basically the implementation of machine learning. Machine learning has been
widely used in the capital market and plays a major role in predicting future stock prices based on historical data. Machine learning
involves artificial intelligence which empowers the system to learn and improve from past experiences without being programmed
time and again, thereby increasing the accuracy [2].
The proposed approach considers the available historic data of a particular share and it provides predictions on a particular feature.
In order to predict a share price for a required time period, the proposed model uses the time series analysis. This model applies a
type of recurrent neural network (RNN) capable of addressing linear problems and predicting time series- Long Short Term
Memory (LSTM) networks. LSTM is a deep learning technique. Long-term Memory (LSTM) units execute very long sequences.
LSTM evaluates the time series data by using both the historical and the present stock data accurately [2]. LSTM replaces the
traditional artificial neurons in the network layer into the most useful memory cells. With these memory cells, networks are able to
associate memory with remote input over time. Over the past few years, LSTM has been applied to stock market prediction in
different stock markets around the world [2].
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 26
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
The most important aspect of machine learning is the dataset used. The dataset should be as solid and concrete as possible because a
little change in the data can prolong massive changes in the results. This dataset comprises the following closing variables for
companies like TATAGLOBAL, Facebook, Tesla, Microsoft and Apple. The model is then tested with the help of test data.
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 27
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
The system works on a Comma Separated Variable (CSV) file, which has a record of all the dates and its raw data of the closing
variable. From this raw data, knowledge is extracted by performing data pre-processing and refining to predict a close information
for requested date of future. Once the knowledge is available, it will be fed to the LSTM algorithm to perform stock prediction and
give a data visualization using python, this investment prediction will be subdivided into different time frames and a suitable advice
from the prediction can be given to the consumer, as shown above.
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 28
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
IV. METHODOLOGY
A. Recurrent Neural Network(RNN)
A recurrent neural network (RNN) is a type of artificial neural network which uses chronological data or time series data. Recurrent
neural networks utilize training data for knowledge. They are distinguished by their “memory” as they take information from
previous inputs to influence the current input and output. On the other hand, traditional neural networks assume that inputs and
outcomes are not related to each other, the output of the recurrent network depends on the prior attributes within the sequence. The
main and most important feature of RNN is Hidden state, which can remember some data about a sequence.
There are three gates in LSTM: input, forget and exit gate. These gates determine whether new input should be allowed, data deleted
because it is not important, or allow it to affect output at current timeline.
1) Forget Gate: It determines when certain parts of the cell will be inserted with data that is most recent. It subtracts 1 in parts of
the cell state to be kept, and 0 in values to be ignored.
2) Input Gate: Based on the input, this network category reads the conditions under which information should be stored or updated
in the state cell.
3) Output Gate: Depending on the input mode and the cell, this gate determines which information is forwarded in the next
location in the network.
C. Fundamentals
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 29
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
1) Data Collection: Data collection is the basic and initial step. It deals with the collection of the right dataset. Based on various
aspects, the dataset that is to be used in the stock market prediction has to be modified. Data collection also complements the
dataset by adding more data that is external. The data used in this project mainly consists of the previous few years' stock prices.
Initially, we will be analysing the Kaggle dataset and according to the accuracy, we will be using the model with the data to
analyse the predictions accurately [3].
2) Pre Processing: Data pre-processing is a part of data mining, which involves transforming raw data into a more reasoned
format. Raw data is usually incomplete or inconsistent and usually contains many errors. The data pre-processing involves
checking out for missing values, looking for categorical values, splitting the data-set into training and test sets and finally doing
a feature scaling to limit the range of variables so that they can be compared on common technologies [3].
3) Training the Machine: Training the machine is similar to feeding the data to the algorithm to test the data. The models are tuned
and fitted using Training sets. The training of the model comprises cross-validation where we get a well-grounded approximate
performance of the model using the training data.
4) Data Scoring: Scoring the data is referred to as a process of applying a predictive model to a set of data. The technique used to
process the dataset is the Long-Short Term Memory. We achieve interesting results, based on these learning models. Thus
describes how the result of the model can help to predict the possibility of a stock to rise and fall based on certain parameters
5) Output Block Description: The stock selected by the user acts as an input to the system. The selected stock contains the time
period for which the user needs the prediction. Analysis of the input data takes place resulting in generation of graph which acts
as an output.
The above image shows a graphical representation of the closing price of a particular user selected stock. This scattered plot shows
the date and time along with the closing price.
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 30
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
This GUI consists of a drop down, which consists of stocks. The user is supposed to select single or multiple stocks from given
stock list. It also shows a clear picture of highs and lows of selected stock.
This is stock analysis dashboard wherein the user can compare multiple stocks based on the past performance and he/ she can decide
whether they want to invest in these stocks or no.
The proposed model is able to predict the share price with very low loss and error rate. From the implementation and results, we can
thus infer that in general, the prediction accuracy of the LSTM model improves with increase in the size of the dataset and makes is
more efficient [6].
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 31
International Journal for Research in Applied Science & Engineering Technology (IJRASET)
ISSN: 2321-9653; IC Value: 45.98; SJ Impact Factor: 7.538
Volume 10 Issue IV Apr 2022- Available at www.ijraset.com
VI. CONCLUSIONS
Predicting the stock market is a time-consuming and strenuous procedure. However, with the introduction to Machine Learning and
its various algorithms, the Stock Market Prediction advancements have begun to include such approaches in analysing stock market
data. By measuring the accuracy of the different algorithms, we found that the most suitable algorithm for predicting the market
price of a stock based on various data points from the historical data is the Long-Short Term Memory (LSTM) algorithm. The
algorithm will be a great asset for brokers and investors for investing money in the stock market since it is trained on a huge
collection of historical data and has been chosen after being tested on a sample data. The project demonstrates the machine learning
model to predict the stock value with more accuracy as compared to other machine learning models.
In the future, the stock market prediction system can be further improved by utilizing a much bigger dataset having higher
computing capacities than the one being utilized currently and number of training epochs that better suit our assets and maximize
our predictions accuracy [3]. Furthermore, other models of Machine Learning could also be studied to check for the accuracy rate
resulted by them. The sentiment analysis from social media can be linked with the LSTM to better train weights and further improve
accuracy [6]. It has led to the conclusion that it is possible to predict the stock market with more accuracy and efficiency using
machine learning techniques.
VII. ACKNOWLEDGMENT
It is our privilege to express our sincerest regards to our project guide Prof. Suresh Babu K.S for giving his valuable time and
suggestions. We deeply express our gratitude to our Head of the Information Technology Department Dr. Satishkumar Varma and
our Principal Dr. Sandeep M. Joshi for encouraging us with whole-hearted cooperation and constructive criticism throughout the
duration of this work and allowing us to showcase our work.
REFERENCES
[1] Pritam Ahire, Hanikumar Lad, Smit Parekh, Saurabh Kabrawala, “LSTM Based Stock Prediction,” International Journal of Creative Research
Thoughts(IJCRT), vol. 9, pp. 5118-5122, Feb. 2021.
[2] Ya Gao, Rong Wang, and Enmin Zou, “Stock Prediction Based on Optimized LSTM and GRU Models,” Hindawi, vol. 2021, pp. 1-8, Sept. 2021.
[3] Adil Moghar and Mhamed Hamiche, “Stock Market Prediction Using LSTM Recurrent Neural Network,” Sciencedirect, vol. 170, pp.1168-1173, Apr. 2020.
[4] Mallikarjuna Shastry P. M. and Pramod B S, “Stock Price Prediction Using LSTM,” ResearchGate, vol. 83, pp. 5246-5251, May. 2020.
[5] Ishita Parmar, Navanshu Agarwal, Sheirsh Saxena, Ridam Arora, Shikhin Gupta, Himanshu Dhiman, Lokesh Chouhan, “Stock Market Prediction Using
Machine Learning,” in First Inter- national Conference on Secure Cyber Computing and Communications, 2018, doi: 10.1109/ICSCCC.2018.8703332
[6] Uttamraj K R, Raghav Nandakumar, Vishal R, Y.V Lokeswari, “Stock Price Prediction Using Long Short Term Memory,” International Research Journal of
Engineering and Technology (IRJET), vol. 05, pp. 3342-3348, Mar. 2018.
©IJRASET: All Rights are Reserved | SJ Impact Factor 7.538 | ISRA Journal Impact Factor 7.894 | 32