Stock Market Prediction using LSTM
Priya Sidhu1, Dr. Himanshu Aggarwal2 , Dr. Madan Lal3
{
[email protected],
[email protected],
[email protected] }
Research Scholar, Dept.of Computer Science& Engineering, Punjabi University, Patiala1,
Professor, Dept.of Computer Science & Engineering, Punjabi University,Patiala2
Assistant Professor, Dept.of Computer Science & Engineering, Punjabi University,Patiala3
Abstract— In this paper, the analyses of stock is done using Long-Short-Term Memory
as it helps in predicting the future price of the stock market. LSTM focuses on predicting
the next output that will help to do the time series analysis. Therefore, to do the
forecasting of the stock price, we have to consider the closing price. LSTM helps to find
the future price using the previous day’s closing price. LSTM neural network helps in
predicting TATAGLOBAL stock by using multi-feature input variables to verify the
prediction effect on the stock time series.
Keywords: Stock Price ,LSTM, methodology
1 Introduction
To represent the budgetary statement of the owners in the company, so that they can
claim the partnership, that is called Stock or Share. The assemblage of markets and
exchanges those help to tell about the activities of publicly-held companies’ buying, selling,
and issuance of shares are done is known as The Stock Market [1]. The stock exchange is the
subset of the stock market. The public investor buy and sell their shares from the list equity
shares, all this is done in the stock market. Whereas, stock exchange is an environment that
grants permission for stocks trading [2]. Being “irrational”, Investors and analysts make
decisions individually on their personal experience and intuition to be there is always a
certain limit to it, but stock prices can neither be forecasted with high experiences nor can be
done with intuitions accurately. The accuracy fluctuates by causing greater risks, leading to
investors’ economic losses[1-10].
ICIDSSD 2020, February 27-28, New Delhi, India
Copyright © 2021 EAI
DOI 10.4108/eai.27-2-2020.2303545
Table 1. Difference between Common Stock and Preferred Stock
Feature Common Preferred
Ownership of Company Yes Yes
Voting Rights Yes No
Dividends Varies Fixed
Value if held to Maturity Varies Full
2 Indian Stock Market
The Stock market helps to represent the Capital of the country. To maintain discipline in
management of the company, Stock markets play a major role in this world. In the early
eighties of the initialization of liberalization, the evolution of the Equity market bloomed in
India. Later in the nineteens’ after the liberalization, reshuffling strategy had more focus on
the expansion of the capital market, then, activities of stock market were magnified. Indian
Market followed two standards that are structure and the operating efficiency of international
market standards [13].
Stocks market is same as vegetable market, here we buy and sell the stocks. Every day’s
opening price of the stocks is been determined by the stock market through the process of bid
and offer. Then, investor has right to do bidding and buying of the stock. He can offer the
valuable price to sell that stock.[1] Then, according to trend buyers engage themselves in
competing with other buyers for the best price and expect that the price of the stock should be
at the highest point to gain the profit. Indistinguishably, sellers also aggressively compete
with others at lowest price and then expect to go beyond that price to gain profit. The trade is
executed when the best bid price and the best offer price are emulated. There are 144 stock
exchanges in the world and India has 23 SEBI approved exchanges. The Indian stocks
Exchanges are the Bombay Stock Exchange, the National Stock Exchange and the Calcutta
Stock Exchange are permanent stock exchanges [14].
3 Methodology
Deep learning based on neural networks, improves the complex and nonlinear system’s
efficiency and accuracy. In this method, mechanism handling is highly parallel, the flexibility
of performance of structure is improved, the capacity of operation is extreme, fastening of the
functioning in nonlinear and self-learning organization ability is strong. In research field, this
method is highly considered. For this experiment, we have considered Long Short-Term
Memory[10].
3.1 Long Short-Term Memory
In a classical neural network, the next step input seldom is the output of last step but in
real-world phenomenon we can notice that in many situations the external input are non-
dependable on final output. For example, when a person is reading a paragraph, each
sentence does not depend on the current sequence of words but depends on the previous
sentence’s meaning or the factors that is generated by using the past sentences. It is not
important that person will start thinking from scratch every second[15].
3.2 The Working of LSTM
Recurrent neural network is form of Long short-term memory (LSTM) [17]. Due to the
design of LSTM, the problem of long-term dependence can be solved for recurrent neural
network. To prevent the input’s nerve, Long short-term memory is used. The output of
network tries to be in circular loop that decays or explodes through the feedback loop, and
the long-term dependency is main focus of LSTM[16].
Fig 1. Working of LSTM
LSTM is associated of two parts that are: unit and gates. Input-Output gate and forget gate
are the three gates used for memory time interval that are used for transmitting information of
time, as shown in Figure 1.[7]. Further, it can also be subdivided into: block input-output, cell
state, input-output gate and forget gate [7]. The equation is as shown below:
Block input (zt):
z-t=g (Wzxt+Rzyt-1+bz) (1)
-t
Input gate (i ):
i-t = σ (Wixt+Riyt-1+bi) (2)
Forget gate (ft):
ft= σ (Wfxt+Rfyt-1+bf) (3)
Cell state (ct):
ct=zt ʘ it+ct-1ʘ ft (4)
Output gate (ot):
ot= σ (Woxt+Royt-1+bo) (5)
Block output (yt):
yt=h(ct) ʘ ot (6)
Where, input weights are Wz,Ws,Wf,Wo ϵ RN×M, recursive weights Rz,Rs,Rf,Ro ϵ RN×M, the
offset to be are bz, bs, bf, boϵ RN, nonlinear functions are σ, g, and h, and usually to express as
a point-wise multiplication of two vectors are g(x)=h(x)=tanh (x).ʘ and σ (x)=(1/(1+ex )),
[17].
4 Result
The stock TATAGLOBAL has been considered in this study to predict the future price.
Tata Global Beverages Limited is non-alcoholic beverage company in India. The headquarter
of this company is in West Bengal, India and is the subsidiary of the Tata Group. It is the
second-largest manufacturer and distributor of tea and coffee in the world. The opening price,
closing price, highest price, lowest price, total trade quantity and turnover(in lacs) has been
consider to analyse the stock price. We have considered the data of five days to analyse and
forecast the future stock price.
Table 2. TATAGLOBAL Stock Price
Date Open High Low Close Total Trade Quantity Turnover(Lacs)
2018.10.08 208 222.25 206.85 215.15 4642146 10062.83
2018.10.05 217 218.6 205.90 209.2 3519515 7407.06
2018.10.04 223.5 227.8 216.15 218.2 1728786 3815.79
2018.10.03 230 237.5 225.75 227.6 1708590 3960.27
2018.10.01 234.55 234.6 221.05 230.9 1534749 3486.05
Fig 2. Prediction of TATAGLOBAL Stock
Conclusion
We can observe that the output predicted using LSTM has shown quite accurate price. The
variation in the original future price and predicted value is very less. As we considered the
TATAGLOBAL stock to predict the data and it gave better result on multivariate feature
input to meet actual demand. The experimental LSTM neural network used multivariate
values. The prediction can be more accurate is we train the model with more number of data
set.
References
[1] Idrees, S.: A Prediction Approach for Stock Market Volatility Based on Time Series Data.
,pp.17287–17298(2019)
[2] Sharma, A.: Survey of stock market prediction using machine learning approach. ,(2017)
[3] B. Wang, F. L. Zhang.: Comparison of artificial neural network and time series model for
forecasting stock prices. pp. 69-73(2005).
[4] J. Lin, Y. H. Guo.: Short term prediction of stock prices based on neural networks. pp. 299-304,
(1998)
[5] J. H. Sun, Long time series clustering method and its application in stock price. Diss. WuHan
University.(2011)
[6] Christian, D., Cincotti, S.: Clustering of financial time series with application to index and
enhanced index tracking portfolio. pp. 145- 151 (2005)
[7] Yin, H., Zhao, C.:Research on stock forecasting based on neural network. pp. 47-49 (2007)
[8] Gianni F., S. Surcis, S.: A cloud computing based real time financial system. pp. 1219-
1220(2009)
[9]Colah, Understanding LSTM Networks, 2015, [online] Available:
http://colah.github.io/posts/2015-08-Understanding-LSTMs/.
[10] Gers, F.: Learning to forget: continual prediction with LSTM. pp. 2451-71(1999)
[11] Martin, S.: LSTM neural networks for language modeling”, Interspeech, pp. 601-608 (2012)
[12] Alex, G.:Supervised sequence labelling with recurrent neural networks. vol. 385 (2012)
[13] https://www.investopedia.com/terms/t/technical-analysis-of-stocks-and-trends.asp
[14] Selvamuthu, D.: Indian stock market prediction using artificial neural networks on tick
data. Financial Innovation, 5(1).(2019)
[15] Ghosh, A.: Stock Price Prediction Using LSTM on Indian Share Market. , pp. 101-110(2019)
[16] Jhang, W.: Share Price Trend Prediction Using Attention with LSTM Structure. pp. 208-211
(2019)
[17] Louis, B.: Trend Forecasting with Technical Analysis: Unleashing the Hidden Power of
Intermarket Analysis to Beat the Market. Marketplace Books, 2000.