0% found this document useful (0 votes)
28 views7 pages

Stock Price Prediction with LSTM

This document summarizes a research paper about using LSTM (Long Short-Term Memory) neural networks to predict stock prices. The paper trains an LSTM model on historical stock price data from the National Stock Exchange of India. It finds that LSTM can accurately predict stock prices by analyzing patterns in past price movements and related financial data. The model considers features like opening price, high, low, close price, trading volume over time for its predictions. The paper aims to develop a more accurate stock price prediction system compared to traditional statistical methods.

Uploaded by

Aakash Debnath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
28 views7 pages

Stock Price Prediction with LSTM

This document summarizes a research paper about using LSTM (Long Short-Term Memory) neural networks to predict stock prices. The paper trains an LSTM model on historical stock price data from the National Stock Exchange of India. It finds that LSTM can accurately predict stock prices by analyzing patterns in past price movements and related financial data. The model considers features like opening price, high, low, close price, trading volume over time for its predictions. The paper aims to develop a more accurate stock price prediction system compared to traditional statistical methods.

Uploaded by

Aakash Debnath
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

See discussions, stats, and author profiles for this publication at: [Link]

net/publication/348390803

Stock Price Prediction Using LSTM

Article in Test Engineering and Management · January 2021

CITATIONS READS

13 15,651

2 authors, including:

Mallikarjuna Shastry Pm
Reva University
13 PUBLICATIONS 15 CITATIONS

SEE PROFILE

All content following this page was uploaded by Mallikarjuna Shastry Pm on 11 January 2021.

The user has requested enhancement of the downloaded file.


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

Stock Price Prediction Using LSTM


Pramod B S1*, Mallikarjuna Shastry P. M.2
1
M tech [pt] 6th Semester in CSE, REVA University, Bengaluru
2
Professor, REVA University, Bengaluru
1
[Link]@[Link]

Article Info Abstract


Volume 83 The prediction of stock value is a complex task which needs a robust
Page Number: 5246-5251 algorithm background in order to compute the longer term share
Publication Issue: prices. Stock prices are correlated within the nature of market; hence
May - June 2020
it will be difficult to predict the costs. The proposed algorithm using
the market data to predict the share price using machine learning
techniques like recurrent neural network named as Long Short Term
Memory, in that process weights are corrected for each data points
using stochastic gradient descent. This system will provide accurate
outcomes in comparison to currently available stock price predictor
algorithms. The network is trained and evaluated with various sizes
Article History of input data to urge the graphical outcomes.
Article Received: 19 November 2019
Revised: 27 January 2020 Keywords: Machine Learning, Stock Price Prediction, Long Short-
Accepted: 24 February 2020 Term Memory, Stock Market, Artificial neural Networks, National
Publication: 16 May 2020 Stock Exchange

1. Introduction stock exchange entity, the NSE was the first exchange in
The share market is a place where the shares of a public India to provide a modern, provides latest facility to the
company are traded. As discussed in [7] the volatile investors spread across the length and breadth of the
nature of the stock market makes it an area which needs country. It has thoroughly modern with all latest
an abundance of analysis with the old data predicated. facilities, , which provides investors with the facility to
The previous stock trend prediction algorithms use the trade from anywhere in India. This has a decisive role in
historic time series stock data. the typical scientific stock reforming the Indian equity market to add increased
price forecasting procedures are focused on the statistical transparency, convergence and efficiency to the capital
analysis of stock data. In the paper will develop a stock market. NSE's Common Index, The CNX NIFTY, is used
data predictor program that uses previous stock prices prodigiously by the investor across India as well as
and data will be treated as training sets for the program to globally. It provides accommodation for the exchange,
predict the stock prices of a particular share this program settlement and clearing in equity and debt market and
develops a procedure. additionally in derivatives. This is one of India's most
This model considers the historical equity share price astronomically enormous mazuma, currency and index
of a company price and applies RNN (Recurrent) options trading exchanges worldwide. There are
technique called Long Short Term Memory (LSTM). The numerous domestic and ecumenical companies which
proposed approach considers available historic data of a have an interest in the exchange. Several regional
share and it provides prediction on a particular feature. companies include TATA, WIPRO, HDFC and YES
The features of shares are Opening price, day High, day BANK ltd. Among pilgrim investors, few are strategic
Low, previous day o price, Close price, Date of trading, holdings of the city party, Mauritius limited, Tiger
Total Trade Quantity and Turnover. The proposed model Ecumenical five holdings.
uses the time series analysis in order to predict a share As suggested by [3] The Long Short Term Memory
price for a required time span. the proposed will be (LSTM) networks are a type of recurrent neural network
considering Indian stock exchange Company named as (RNN) capable of addressing linear problems. LSTM is a
The National Stock Exchange of India Limited deep learning technique. Long-term Memory (LSTM)
(NSE).The National Stock Exchange (NSE) is the Indian Units are enforced to learn very long sequences. This is a
more general version of the gated recurrent system.
LSTM is more benign than other deep learning methods

Published by: The Mattingley Publishing Co., Inc. 5246


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

like RNN or traditional feed forward because LSTMs is being applied. In the alluded to paper the stock worth
tackle the evanescent gradient issue possessed by [10]. gauge has been finished by utilizing the self-confident
Paper is ordered as follows. In Section II, related timberland figuring is being used to betoken the expense
works are discussed. Section III represents the proposed of the stock utilizing fiscal extents structure the
system used and Section IV represents the proposed perspective quarter. This is just a single technique for
algorithm. In Section V the results are presented and optically crusading the circumstance by advancing toward
conclusions are drawn in Section VI. it utilizing an insightful model, utilizing the capricious
` boondocks to anticipate the future expense of the stock
2. Related work from recorded data. However, there are continuously
While doing the literature survey, the data about Stock different components that influence the cost of the stock,
market prediction systems that are as of now being such as the suspicions of the money-related authority, the
utilized are considered. general assessment of the association, news from sundry
Over the most recent two decades determining of outlets, and even events that cause the entire trade
stock returns has become a significant field of research. protection to change, by using the cash related size in the
In the majority of the cases the scientists had endeavored vicinity of a model that can strongly separate
to build up a straight connection between the information assumptions, the accuracy of the stock value forecast
macroeconomic factors what's more, the stock returns, be model can be extended.
that as it may, with the revelation of non linear slants in It is also mentioned in [1] that stock value Prediction
the financial exchange record returns, there has been an by methods for Multi-Source multiple instance learning
incredible move in the focal point of the scientists unequivocally foreseeing the protections trade is a
towards the nonlinear expectation of the stock returns. troublesome task, anyway the web has wind up being a
Despite the fact that, there after numerous writing have useful gadget in making this task less difficult, due to the
come up in nonlinear measurable displaying of the stock related course of action of the data, it is certainly not
returns, the majority of them required that the nonlinear difficult to evacuate certain inclinations right now, it is
model be indicated before the estimation is done. in any less difficult to establish associations between different
case, for the explanation that the financial exchange variables and, for the most part, a case of adventure The
returns being boisterous, unsure, confused and nonlinear way in which budgetary trade information can be
in nature. There are various functions used to forecast the adequately predicted is through the use of some different
parameters. Mainly include, binary threshold, linear options from specific legitimate data and the use of
threshold, hyperbolic sigmoid, and brown. different strategies, such as the use of a feeling analyzer,
The Investigation of Stock Market Prediction Using to suggest a remarkable relationship between the
Machine Learning Approach has been mentioned. The emotions of individuals and how they are influenced by
stock exchange forecast has become a sharp area of the enthusiasm for express stocks. One of the
interest. Particular assessment is one of them, yet it does progressively noteworthy areas of the desire strategy was
not reliably deliver specific results, so it is essential to to extract huge events from web news to see how they
develop strategies for progressively accurate gauge. All had an impact on stock costs. It is also mentioned that
the procedures recorded under the backslide have their trade prediction protection: using historic data analysis.
own ideal conditions and obstacles over their various The stock or offer expense can be foreseen using
accomplices. The way in which straight backslide models chronicled data and its example in all actuality there is
act is that they are consistently fitted using the least need to apply counts to anticipate the expenses. The
squares approach, however they may be fitted in different customary frameworks are just worried about variety of
habits, for example by reducing the "non-appearance of an element that is selected for forecast. The latter is
fit" in some other standard, or by diminishing a disabled usually achieved with the benefit of the Genetic
variation of the least squares setback work. Again, the Algorithms (GA) or the Artificial Neural Networks
least squares approach can be used to fit nonlinear (ANN's)[5], but they neglect to establish a relationship
models. between their stock costs as long-distance fleeting
The impact of the financial ratios and technical dependencies.
analysis on stock price forecasting using random forests, RautSushrut et al.[2] suggested that supervised
The use of AI and human-made awareness frameworks to learning classifier be used to forecast stock price
predict stock costs is a growing example. A constantly movement based on financial index data, and determine
increasing number of experts spend their time every day their ability. In the financial market computational
considering ways to deal with techniques that can further analytical approaches have been portfolio modeling. A
improve the precision of the stock conjecture model. As a discussion about the statistical AI methodology has been
result of the galactic number of decisions available, there addressed; the usage of SVM methodology has been
can be n number of ways on the most capable strategy to shown in the paper and also shown that tactical
envision the expense of the stock, anyway all techniques methodologies can be applied to predict the stock prices.
don't work a comparable way. The yield changes for each Manoj S Hegde et al.[3] investigated that The Long
methodology whether or not comparative educational file Short Term Memory (LSTM) networks are a type of
recurrent neural network (RNN) capable of solving in

Published by: The Mattingley Publishing Co., Inc. 5247


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

volute linear problems, and also there is a discussion which we can utilize multiple source of information to
about the usage of RNN (Recurrent Neural Networks ) to predict the stock values.
predict the share prices. Tao Xing and Yuan Sun et al. [9] suggested a model
M. Roondiwala et al.[4] proposed that the Long Short- which considers the historical equity share price of a
Term Memory is the most popular RNN architecture. In company price and applies RNN (Recurrent) technique
the secret network layer, LSTM introduces a memory called Long Short Term Memory (LSTM). The proposed
cell; a processing device that replaces conventional approach considers available historical data of a share and
artificial neurons, using these memory cells, networks can it applies prediction on a particular feature. The features
effectively link memory and remote input in time, making of shares are Opening price, day High, day Low, previous
it suitable to dynamically capture data structure over time day o price, Close price, Date of trading. The proposed
with a high predictive limit. It is also shown in the paper model uses the time series analysis in order to predict a
that the stock prediction can be done on the NIFTY50 share price for a required time span.
shares. The data collection is one of the major step and Jordan Prosky et al. [10] suggested that, the CNN
later the training of our model and there is a need to test methodologies and its usage in predicting stock prices, a
the algorithm by applying different data set to the method to apply sentiment analysis on stock prediction.
algorithm. Our procedure will be discussed in coming As mentioned by X. Shao and D. Ma [11] it is a more
sections general version of the gated recurrent system. LSTM is
As Kim and H. Y. Kim et al.[5] identified that more benign than other deep learning methods like RNN
.another significant issue with basic ANNs for stock or traditional feed forward neural networks because
forecast is the marvel of detonating fleeting inclination, LSTMs tackle the evanescent gradient issue possessed by
where the loads of a gigantically huge system either RNNs and it is also mentioned that how to implement
become excessively massively enormous or too inuscule LSTM along with K-means algorithms for a short term
(respectively),drastically easing back their union to the stock predictor systems.
ideal worth. This is regularly brought about by two
components: loads are instated self-assertively and the 3. Proposed System
loads progressively proximate to the end of the system As represented in the previous section getting the
moreover slope to transmute significantly more than historical data from market is mandatory step. Then there
those at the beginning. It is also mentioned in the paper is a need to extract the feature which is required for data
that the usage of LSTM networks can be applied in analysis, then divide it as testing and training data,
procedure of predicting share prices. training the algorithm to predict the price and the final
As discussed by S. Selvin et al.[6], Customary types step it to visualize the data. Fig. 1 represents the
for dealing with the financial exchange investigation and Architecture of the proposed system.
the stock-value forecast include a major review of the
past stock-exhibition gander and the general credibility of
the organization itself, and a measurable investigation
that is solely concerned with the calculation and
recognition of stock-value designs, it also mentioned in
the paper that different types of analysis that can be
performed in order to predict the stock value.
Loke.K.S et al.[7] suggested that the volatile nature of
the stock market is an area that needs a lot of analysis
based on historical data. Traditional stock trend forecast
algorithms use historical time series stock data,
traditional technical forecasting procedures for stock
prices are based on statistical data analysis. in the paper
author also talks about the change and advancements in
the process of predicting stock prices using AI and
Machine Learning methodologies, there are many
research which are being conducted to find a accurate Figure 1: System Architecture
model to predict the stock prices and there is no universal
solution which is available to apply, hence the historic The typical LSTM unit consists of a cell, an info door,
data of a share will be considered for stock price an entrance door and a door with a view. The cell collects
prediction. values over discretionary time intervals, and the three
Xi Zhang1 et al. [8] suggested that the stock markets inputs manage the progress of data into and out of the
play critical roles in modern society's economic cell. The main advantage of the LSTM is its ability to
operations. It is also metioned in the paper that the learn context-specific temporal dependence. Each LSTM
analysis can be performed an the data that is retrieved unit collects information for either a long or short period
from a legitimate source and proposed a methodology in of time (hence the name) without explicitly using the
activation function within the recurrent components. A

Published by: The Mattingley Publishing Co., Inc. 5248


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

significant certainty to note is that any cell state is


uniquely increased by the output of the overlooked Algorithm 1: Stock prediction using LSTM
entryway, which changes somewhere in the range of 0
and 1. In other words, the overhead door in the LSTM Input: Historic stock data
cell is responsible for both the loads and the capacity to Output: prediction of stock price using price variation
initiate the cell state. Subsequently, data from a past cell
state can pass through a cell unaltered rather than Step 1: Start.
expanding or decreasing exponentially at each time-step Step 2: Data Preprocessing after getting the historic data
or layer, and loads can meet their ideal quality in a from the market for a particular share.
reasonable measure of time. This allows LSTM's to take Step 3: import the dataset to the data structure and read
care of the evaporating slope issue – as the value put the open price.
away in the memory cell is not iteratively adjusted, The Step 4: do a feature scaling on the data so that the data
inclination does not disappear when prepared with back values will vary from 0 and 1.
engendering, where markets such as NSE and BSE are Step 5: Creating a data structure with 60 timestamps and
considered to be Indian trading entities for our analyzes. 1 output.
Step 6: Building the RNN (Recurrent neural network) for
3.1. Parameters used Step 5 data set and Initialize the RNN by using sequential
List of parameters/Symbols used in this paper is listed in repressor.
Table 1 Step 7: Adding the first LSTM layer and some Dropout
regularization for removing unwanted values.
Table 1:Parameters Used Step 8: Adding the output layer.
Step 9: Compiling the RNN by adding adam optimization
and the loss as mean_squared_error.
Parameter
Step 10: Making the predictions and visualizing the
Meaning
Used results using plotting techniques.
Date Date of stock price
Before processing the data there is a important step
Open Open price of a share
that is to collect the information from market.
Close Closing price of a share
Information assortment is the principle step in our
Volume/
proposed framework importing of the information from
trade
advertise clearing organizations like BSE (Bombay Stock
quantity Number of shares traded
Exchange) and NSE (National Stock Exchange). The
High Highest share value for the day dataset that will be utilized in the market expectation
Low Lowest share value for the day must be utilized to be separated dependent on different
Turnover Total Turnover of the share perspectives. Information assortment additionally
supplements to upgrade the dataset by including more
information that is outside. Our information for the most
4. A Stock Price Predictor Using LSTM
part comprises of the earlier year stock costs. For python
The proposed framework that learns online anticipating available packages for retrieving the data from NSE is
the close costs of the stock with the assistance of Long NSEpy
Short Term Memory (LSTM). The Long Short Term The next step is to preprocess the data; in this step the
Memory (LSTM) is a counterfeit intermittent neural Information Pre-Processing is a significant advance in
system (RNN) design[1] used in the field of deep information mining here the change in crude information
learning, Unlike standard feed forward neural systems, into a basic configuration is required. The information
LSTM has input associations. Not only does the which is retrieved from source will be conflicting,
procedure not focus on single information (e.g. pictures) fragmented and it will contain mistakes. The
but also on full information arrangements, (For example, preprocessing step will purify the information; toward the
a speech or a video). For example, LSTM is material for end there is a need to perform highlights scaling which
undertakings, such as un partitioned, associated will restrict the factors.
penmanship recognition, speech recognition and The preparation of the model incorporates cross-
recognition of peculiarities in arranged traffic or IDS approval, which is a very well-founded, projected
(interruption location frameworks). execution of the model using the preparation information.
the purpose of the tuning models is to explicitly tune the
calculation training is to add information to the
calculation itself. The test sets are immaculate, as a model
ought not to be made a decision about dependent on
concealed information. Scale up the information to the
genuine offer costs. The final step is to draw the data

Published by: The Mattingley Publishing Co., Inc. 5249


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

using visualization technique that helps to show the


variation of data in the outcome of our algorithm.

5. Results and Discussion


The implementation of proposed LSTM model using
python which predicts the future price of
TATAMOTORS share based on its historical data. The
below visualization figure shows the visualization of
TATASHARE prediction. In our paper the
implementation of an algorithm which predicts the stock
price of a share for given period of time, the below graph
from our algorithm will show the predicted price of
TATAMOTORS share. In the result shown in the below
graph is the plotted form our algorithm outcome by
applying 96 LSTM units for achieving the accuracy.
The Fig 2 is drawn from original dataset and also
shown the result by comparing its correctness with the
trained model from algorithm that is defined in the
previous section. the “x” axis is share price. The “y” axis
is days. The data is slot of 1500 days is shown in the Fig
3.

Figure 3: predicted stock price


In the Fig 2, the graph has been plot for whole data set
along with some part of trained data. the graph is showing
the open price of TATAMOTORS share for 1484 th day’s
opening price with very minimal loss. the algorithm has
plotted the graph successfully along with the predicted
price testing price (blue) and true price (red), there is a
slight difference in predicting the price between the
predicted price testing price (blue) and true price (red),
which proves that our algorithm is able to predict the with
minimum loss rate for the given complete data set of a
particular share.
In the Fig 3, the graph is showing the open price of
TATAMOTORS share for 300th day’s opening price with
very minimal loss. the algorithm has plotted the graph
successfully along with the predicted price testing price
Figure 2: predicted testing stock price (blue) and actual testing price (red), there is a slight
The Fig 3 is drawn from original dataset also shown difference in predicting the price between the predicted
the result by comparing its correctness with the trained price testing price (blue) and actual testing price (red),
model from algorithm which that is defined in the which proves that our algorithm is able to predict the with
previous section. the “x” axis is share price. The “y” axis minimum loss rate of 0.0024.
is days. The data is slot of 300 days is shown in the Fig 3. The proposed algorithm is able to predict the share
price with very low loss and error rate, if increase the
epoch batch rates the training will be more efficient, in
the above section we have used epoch batch size of 50 to
predict the stock prices.
The figures shown in the previous section (fig 2 and
fig 3) of the proposed algorithm is able to predict the
price, with loss: 0.0024
300th days open price was 172 rupees INR and our
predicted price is 166 rupees per share.

Published by: The Mattingley Publishing Co., Inc. 5250


May - June 2020
ISSN: 0193-4120 Page No. 5246-5251

6. Conclusion Stocks" - arXiv:1712.05785v2 [[Link]], 18 Jan


The study of the share is carried out in this paper and it 2018.
can be carried out for several shares in the future. [11] X. Shao, D. Ma, Y. Liu, Q. Yin. "Short-term
Prediction could be more reliable if the model trains a forecast of stock price of multi-branch LSTM
greater number of data sets using higher computing based on K-means", 2017 4th International
capacities, an increased number of layers, and LSTM Conference on Systems and Informatics
modules. (ICSAI).
In future enhancement the inclusion of sentiment
analysis from social media to understand what the market
thinks about the price variation for a particular share and
it can be implement this by adding twitter and Facebook
API to our program as Facebook is a leading social media
which has lots of market trend information posted by
users.

References
[1] Hiba Sadia, Aditya Sharma, Adarrsh Paul,
SarmisthaPadhi, Saurav Sanyal- “Stock Market
Prediction Using Machine Learning
Algorithms”, IJEAT, 2019.
[2] Raut Sushrut Deepak, Shinde Isha Uday, Dr. D.
Malathi, “Machine Learning Approach In Stock
Market Prediction”, IJPAM 2017
[3] M. S. Hegde, G. Krishna and R. Srinath, "An
Ensemble Stock Predictor and Recommender
System," 2018 International Conference on
Advances in Computing, Communications and
Informatics (ICACCI), Bangalore, 2018, pp.
1981-1985.
[4] M. Roondiwala, H. Patel and S. Varma,
"Predicting stock prices using LSTM,"
International Journal of Science and Research
(IJSR), vol. 6, no. 4, pp. 1754-1756, 2017.
[5] T. Kim and H. Y. Kim, "Forecasting stock prices
with a feature fusion LSTM-CNN model using
different representations of the same data," PloS
one, vol. 14, no. 2, p. e0212320, April 2019.
[6] S. Selvin, R. Vinayakumar, E. A. Gopalkrishnan,
V. K. Menon and K. P. Soman, "Stock price
prediction using LSTM, RNN and CNN-sliding
window model," in International Conference on
Advances in Computing, Communications and
Informatics, 2017.
[7] Loke.K.S. “Impact Of Financial Ratios And
Technical Analysis On Stock Price Prediction
Using Random Forests”, IEEE, 2017.
[8] . Xi Zhang1, Siyu Qu1, Jieyun Huang1, Binxing
Fang1, Philip Yu2, “Stock Market Prediction via
Multi-Source Multiple Instance Learning.” IEEE
2018.
[9] Tao Xing, Yuan Sun, Qian Wang, Guo Yu. "The
Analysis and Prediction of Stock Price", 2013
IEEE International Conference on Granular
Computing (GrC), ISBN: 978-1-4799-1282-7,
DOI: 10.1109/GrC.2013.6740438.
[10] Jordan Prosky, Andrew Tan, Xingyou Song,
Micael Zhao. "Sentiment Predictability for

Published by: The Mattingley Publishing Co., Inc. 5251

View publication stats

You might also like