Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
4 views

Paper_98-A_Comparative_Study_of_Deep_Learning_Algorithms

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Paper_98-A_Comparative_Study_of_Deep_Learning_Algorithms

Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 10

(IJACSA) International Journal of Advanced Computer Science and Applications,

Vol. 14, No. 10, 2023

A Comparative Study of Deep Learning Algorithms


for Forecasting Indian Stock Market Trends

Mrinal Kanti Paul, Purnendu Das


Department of Computer Science, Assam University, Silchar, Assam, India-788011

Abstract—This research underscores the vital significance nificantly improving stock investments’ efficiency. They are
of providing investors with timely and dependable information extensively utilized to develop innovative ideas and modes that
within the dynamic landscape of today’s stock market. It delves simplify the process of creating stock portfolios for investors
into the expanding utilization of data science and machine [2].
learning methods for anticipating stock market movements. The
study conducts a comprehensive analysis of past research to This paper delves into the growing interest among financial
pinpoint effective predictive models, with a specific focus on researchers in Machine Learning (ML) owing to its success
widely acknowledged algorithms. By employing an extensive in various domains. It focuses on exploring and comparing
dataset spanning 27 years of NIFTY 50 index data from the Na- the latest prediction algorithms and techniques proposed by
tional Stock Exchange (NSE), the research facilitates a thorough
researchers for forecasting stock market trends and behavior
comparative investigation. The primary goal is to support both
investors and researchers in navigating the intricate domain of in both academic and industry settings.
stock market prediction. Stock price prediction is challenging due This paper encompasses a concise overview of both Ma-
to numerous influencing factors, and identifying the optimal deep chine Learning (ML) and Deep Learning algorithms. It goes
learning model and parameters is a complex task. This objective
is accomplished by harnessing the capabilities of deep learning,
on to conduct a thorough examination of a wide array of
thereby contributing to well-informed decision-making and the algorithms, coupled with an extensive survey of correlated
efficient utilization of predictive tools. The paper scrupulously research. This inclusive approach serves to fortify the the-
examines prior contributions from fellow researchers in stock oretical underpinnings of the study while also delving into
prediction and implements established deep learning algorithms pertinent algorithmic issues. Moreover, the research delves into
on the NIFTY 50 dataset to assess their predictive accuracy. The the practical application of existing work and prevalent deep
study extensively analyzes NIFTY 50 data to anticipate market learning algorithms, commonly employed as the bedrock of
trends. It employs three distinct deep learning models—RNN, numerous researchers’ investigations. A pivotal aspect of this
SLSTM, and BiLSTM. The results underscore SLSTM as the study involves a comprehensive comparative analysis of the
most effective model for predicting the NIFTY 50 index, achieving outcomes achieved through these algorithms.
an impressive accuracy of 99.10%. It’s worth noting that the
accuracy of BiLSTM falls short when compared to RNN and To accomplish our research objectives, we conducted an
SLSTM. extensive survey of prior studies on stock market prediction
Keyword—Stock prediction; machine learning technique; deep utilizing data science and machine learning. We meticulously
learning; stock market; National Stock Exchange analyzed the methodologies and algorithms employed by
various researchers to forecast stock prices. Moreover, we
assembled an extensive dataset of NIFTY 50 data obtained
I. I NTRODUCTION
from the National Stock Exchange India, covering a period of
Scholars have been actively engaged in researching the 27 years. This dataset facilitated a comprehensive evaluation
prediction of stock trends due to the stock market’s pivotal of prediction models across a range of market scenarios.
role as a significant investment avenue across various financial
This study involves a comparative analysis of well-known
instruments. The goal of stock portfolio selection is to allocate
algorithms: LSTM, BiLSTM, SVM, and RNN. The analysis
investment funds across multiple stocks in the market, aiming
utilizes a collected dataset as training data to predict NIFTY
to maximize returns for investors [1]. Investors encounter two
50 stock index movement accurately. The primary goal is to
broad categories of challenges when creating stock portfolios
identify the algorithm that performs best in terms of predictive
“The selection of stocks by an investor” and “Allocating funds
accuracy. The algorithms are trained on the dataset, and their
across various major sectors”
performances are evaluated using appropriate metrics. The
With the advent of faster and high-performance computers, study aims to offer insights into which algorithm is most
data transfer in the modern computing world has become effective for predicting NIFTY 50 movement, aiding in more
effortless, making the stock market more accessible to global informed decision-making within the financial realm. The
investors. The internet revolution of the last decade further study focuses on four algorithms: SLSTM (Stacked Long
increased accessibility, as it provides crucial event information Short-Term Memory), BiLSTM (Bidirectional Long Short-
that directly or indirectly influences the stock market, leading Term Memory) and RNN (Recurrent Neural Network). Fig.
to the emergence of important tasks like strategy formulation 1 depicts the process flow of our study.
and decision-making support using this information.
In the upcoming sections of this paper, we will delve into
Data science (DS) and machine learning (ML) algorithms various aspects of our study. Section II will be dedicated to
have become powerful tools in the financial domain, sig- discussing the related work that has shaped the foundation of
www.ijacsa.thesai.org 932 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

our research. Moving forward to Section III, we will provide M.R. Hassan and B. Nath proposed the use of Hidden
an in-depth description of our implementation plan. Within Markov Model (HMM) for predicting unknown values in time-
Section III , specifically in subsection III(A) and III(A)(1), we series stock market data. They applied this model to forecast
detail our meticulous implementation process using the RNN stock prices for four airlines, utilizing a partitioned approach
model. Furthermore, we will present a comprehensive analysis that involved four distinct states for more accurate predictions
of the results derived from this implementation. Transitioning [6]. The paper’s noteworthy aspect is that it doesn’t require any
to subsection III(B) and III(B)(1), we will outline the steps specialized knowledge to construct the model. However, the
taken for the implementation of the SLSTM model. Alongside study’s limitations are that it’s restricted to Airline Industries
this, we will conduct a thorough examination of the results ob- and was evaluated using a relatively small-scale dataset, which
tained from this implementation. Similarly, in subsection III(C) might not result in a general prediction model.
and III(C)(1), we will provide insights into our implementation
Ming-Chi Lee’s paper introduced a Support Vector Ma-
approach for the BiLSTM model and present a comprehensive
chine based prediction model with a hybrid feature selection
analysis of the results.
approach that combined Supported Sequential Forward Search
Advancing to Section IV, our focus will shift towards (FSSFS) and F-score filtering wrapping methods. This fusion
conducting a Comparative Study of the results derived from aimed to identify an optimal feature subset for improved
our various implementations. This section will not only provide prediction. The study acknowledges feature selection’s impact
a comprehensive comparison of the implementation outcomes on SVM performance and highlights the need for further
but will also identify potential avenues for Future Research investigation into SVM generalization and performance mea-
Opportunities, illuminating areas that warrant further explo- surement guidelines [7].
ration. As we reach the concluding stages of this paper, Section Justin Sirignano and Rama Cont introduced a model uti-
V will encapsulate our findings and insights. This concluding lizing Deep Learning on a large-scale, high-frequency dataset
section will succinctly summarize the key takeaways from our from NASDAQ stocks. Their approach involves a Neural
research journey, offering a cohesive wrap-up to our study. Network with three layers, including LSTM, a feed-forward
layer with rectified linear units (ReLUs) and the Stochastic
II. R ELATED W ORKS Gradient Descent (SGD) algorithm for optimization [8]. The
In the history of the stock market, researchers have em- model developed by the authors was regarded as a universal
ployed algorithms like Neural Networks (NN), Support Vector solution but incurred high training costs. They observed that
Machines (SVM), Genetic Algorithms (GA), Linear Regres- conducting feature selection before training would have been
sion (LR) and Case based Reasoning (CR) for predicting more beneficial, effectively lowering computational complex-
market trends. However, Neural Networks (NN) have gained ity.
prominence recently due to their consistent superiority in Li-Ping Ni et al. suggested a predictive model for the
various scenarios. Their ability to capture intricate patterns Shanghai Stock Exchange Index (SSECI) daily trends. They
in financial data has led to more accurate and adaptable combined a fractal feature selection method with SVM and
predictions of market behavior, making them the preferred compared it against five common feature selection approaches,
choice among these algorithms [3]. demonstrating superior prediction accuracy with their method
White’s implementation of the Feed Forward Neural Net- and surpassing both no feature selection and the other five
work (FFNN) was the pioneering stock market prediction methods [9]. The authors’ model, based solely on a technical
model, inspiring many researchers to develop accurate models indicator, should be assessed with additional factors that influ-
for predicting share market trends. Despite continuous efforts, ence stock prices, given the multifaceted nature of stock price
achieving 100% accuracy in stock market forecasting remains dynamics.
elusive due to historical data reliance and external factors’ Sean McNally et al. devised a model predicting Bit-
impact on stock prices, driving persistent research in this coin’s USD price using Bayesian-optimized LSTM and RNN
domain [3]. networks. LSTM achieved 52% accuracy and 8% RMSE.
Earlier research emphasized optimizing learning algorithms Comparing to ARIMA, their deep learning models excelled.
but overlooked dimensionality reduction and eliminating irrel- GPU training surpassed CPU by 67.7%, underscoring research
evant patterns. To overcome this, Kyoung-jae Kim and Ingoo strength in optimization and feature engineering, with impli-
Han introduced a hybrid model in the early 2000s, blending cations for dataset processing advancements [10].
Artificial Neural Networks (ANN) and Genetic Algorithm Bin Wenga et al. Martinez created a short-term stock
(GA). Their model incorporated daily direction of change and price prediction model employing machine learning techniques
technical indicators for Korea Stock Price Index prediction, yet including Random Forest Regression (RFR), Support Vector
it had limitations in fixed processing elements, input features Regression Ensemble (SVRE), Neural Network Regression
and optimization objectives in the hidden layer (set at 12) [4]. Ensemble (NNRE) and Boosted Regression Trees (BRT) [11].
Mingyue Qiu et al a hybrid solution, GA-ANN, aimed at Yakup Kara et al. utilized ANN and SVM to predict
forecasting the Japanese Stock Market. Their method involved the stock price index, using time series data from Istanbul
integrating Genetic Algorithms (GA) with a refined Artificial Stock Exchange between January 1997 and December 2007.
Neural Network (ANN) model, resulting in an enhanced pre- Their study lacked clear performance comparisons with prior
dictive model. This approach combined the strengths of both models. They employed diverse data sets from various sources,
techniques to achieve improved forecasting outcomes for the including open-source APIs and the Technical Training Rules
Japanese Stock Market [5]. (TTR) R package, for training their research model [12].
www.ijacsa.thesai.org 933 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

Xinyi Li and colleagues introduced DP-LSTM, an inno- Qingfu Liu et al. innovatively treat stock price charts as
vative deep neural network for predicting stock prices. By images and utilize deep learning neural networks (DLNNs) to
integrating differential privacy, sentiment-ARMA modeling, predict short-term price movements by integrating price charts
LSTM, VADER model, and multiple news sources, the ap- and stock fundamentals. The study highlights the supremacy
proach minimizes prediction errors, enhances robustness, and of deep learning over single-layer models in forecasting the
demonstrates significant advancements in accuracy and Mean Chinese stock market, underlining the importance of historical
Squared Error (MSE) improvement for forecasting the S&P price trends in predicting future price changes compared to
500 market index [13]. stock fundamentals [19].
Sidra Mehtab et al. conducted a study using NIFTY 50 Somenath Mukherjee et al. introduced a pair of approaches
index data from India’s NSE, covering December 2014 to July for predicting stock market trends. The first utilized a Feed-
2020. They initially trained on NIFTY 50 data from December forward Neural Network with backpropagation, achieving
2014 to December 2018, developing eight regression models. 97.66% prediction accuracy but facing challenges with data
Subsequently, they forecasted NIFTY 50 open values from volume and overfitting. Regularization was applied to address
December 2018 to July 2020, employing four LSTM-based these issues. The second approach employed a Convolutional
deep learning regression models with walk-forward validation. Neural Network, offering a more efficient solution with im-
Their research highlighted the efficacy of a univariate LSTM proved accuracy (98.92%) on a smaller dataset and training
model in predicting NIFTY 50 open values for the following time, outperforming the initial model [20].
week, utilizing the preceding week’s data as input, leading to
enhanced predictive accuracy [14]. Yanli Zhao et al. proposed an innovative LSTM-based
model enriched with sentiment analysis to predict stock market
Hadi NekoeiQachkanloo et al. introduced an artificial stock trends, acknowledging the impact of investor psychology. The
counselor trading system, combining support vector regression study integrated sentiment indexes to capture emotional facets,
for stock value prediction with portfolio theory and fuzzy utilizing Sentiment Analysis (SA) to convert textual content
investment counsel for optimal budget allocation. Their ap- into daily sentiment indexes. The model’s refinement with
proach encompasses optimization-based technical analysis and Denoising Autoencoders (DAE) improved its performance by
fuzzy logic incorporating technical and fundamental aspects, extracting crucial information [21].
demonstrating efficacy through experimental results on the
NYSE [15]. Abdul Quadir Md and collaborators present an innovative
strategy for stock price prediction that employs a Multi-
In their study, M. Nabipour et al. explored the accuracy of Layer Sequential Long Short Term Memory (MLS LSTM)
tree-based models (Decision Tree, Bagging, Random Forest, model integrated with the Adam optimizer. This technique
Adaboost, Gradient Boosting, XGBoost) and neural networks involves dividing normalized time series data into discrete time
(ANN, RNN, LSTM) in predicting values for four stock steps, effectively capturing historical and future associations
market sectors using regression. Forecasting was done across and yielding remarkable prediction accuracy rates of 95.9%
different time horizons (1, 2, 5, 10, 15, 20, and 30 days and 98.1% on the test dataset, outperforming alternative deep
ahead), employing exponentially smoothed technical indicators learning approaches. [22].
as inputs. The research found that LSTM outperformed other
methods, showcasing the highest performance and notably Arsalan Dezhkam et al. introduced HHT-XGB, a novel
improving the accuracy of stock market predictions within this model that merges Hilbert-Huang Transform (HHT) for feature
context [16]. engineering and extreme gradient boost (XGBoost) for close
price trend classification, facilitating the prediction of changing
Hiransha M et al. employed MLP, RNN, LSTM, and CNN trends in upcoming close stock prices. The model’s output
deep learning architectures to predict stock prices across NSE sequence optimizing portfolio weights demonstrated a remark-
and NYSE. Using TATA MOTORS’ NSE data, these models able 99.8% improvement over raw financial data, surpassing
accurately forecasted prices for MARUTI, HCL, AXIS BANK benchmark strategies even in challenging market conditions,
(NSE), as well as BANK OF AMERICA and CHESAPEAKE substantiated through back-testing results [23].
ENERGY (NYSE). The study demonstrated the models’ ability
to identify patterns in both markets, revealing shared dynamics. Liheng Zhang et al. introduced the State Frequency Mem-
DL models outperformed ARIMA and CNN excelled in cap- ory recurrent network, designed to capture diverse trading pat-
turing sudden changes, although the research did not explore terns and enhance short and long-term stock predictions. Their
hybrid network approaches for further improvement [17]. novel approach demonstrates superior performance compared
to conventional methods in real market data analyses [24].
Manuel R. Vargas et al. proposed a deep learning approach
combining financial news titles and technical indicators for Guanzhi Li et al. presented a novel framework consisting of
predicting intraday directional movements of the S&P Pearson Correlation Coefficient (PCC) and Bayesian Regular-
500 index. Their study emphasized Convolutional Neural ized Neural Network Least Squares (BLS), applied for short-
Networks (CNN) for extracting text meaning and Recurrent term stock price prediction in Shenzhen and Shanghai Stock
Neural Networks (RNN) for capturing context and temporal Exchanges. The approach involved using PCC to select rele-
trends, achieving improved results over similar prior work. vant input variables from a pool of 35 variables, followed by
Notably, the model’s utilization of news from the preceding training the BLS model with these chosen combinations. The
day underscored the short-term impact of news articles on PCC-BLS model demonstrated superior accuracy compared to
financial market predictions [18]. ten other machine learning methods, as evidenced by results
across five evaluation metrics [25].
www.ijacsa.thesai.org 934 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

Shouvik Banik et al. created an LSTM-based Decision purposes. This meticulous division allows us to methodically
Support System for accurate stock value prediction, catering appraise the predictive prowess of the RNN, SLSTM, and
to swing traders. The system generates comprehensive reports BiLSTM models when applied to the NIFTY 50 dataset.
with forecasts for the next 30 days, incorporating technical
It’s essential to note that during the data preprocessing
indicators like MFI, RSI, Support and Resistance levels, Fi-
phase, we’ve diligently filtered out records with missing clos-
bonacci retracement levels, and MACD analysis. The model’s
ing values or date fields, as well as those with incorrect
strong performance, boasting low error values, underscores its
data types. This meticulous approach ensures the dataset’s
superiority over existing methods [26].
uniformity and consistency, providing a solid foundation for
Stock prices are impacted by politics, economics, news, our models’ assessments. Fig. 2 on page 935 displays the
and investors use fundamental and technical analysis for NIFTY 50 closing values from 1997 to 2021.
predictions [27]. Fundamental analysis of a company’s stock
involves evaluating historical performance, anticipated future
growth, and key factors such as profits, product quality, indus-
try competition, financial balance, and cash flow projections
[28]. Technical analysis involves predicting stock price trends
through market trends and statistical data, addressing questions
like optimal buying and selling times. It relies on tables, charts,
and coefficients to make short-term and long-term predictions
for specific stocks [28]. The review of existing studies and
comparisons highlights the success of deep learning models
like LSTM, ANN, RNN, SVM, SLSTM and BiLSTM in
achieving accurate stock price predictions with minimal error. Fig. 2. NIFTY 50 movement from 1997 to 2021.
This prompts our exploration into studying these algorithms for
potential research opportunities. We did a comparative study of
all the machine learning algorithms used till date in financial The Fig. 3 on page 936 illustrates the sequential process of
instruments. our experimental framework, which is specifically designed for
predicting the closing movements of NIFTY 50. Our approach
III. I MPLEMENTATION involves the utilization of the deep learning model mentioned
A. Experimental Setup previously. In our experimentation, we systematically evalu-
ated these models across three distinct setups. Our aim was
In this research paper, our focus lies in implementing and to derive valuable rules from these evaluations and ultimately
comparing three distinct models: RNN, SLSTM, and BiLSTM. identify a model and combination of factors that not only
Our primary goal revolves around evaluating and contrasting yield high predictive accuracy but also enhance efficiency in
their performance utilizing data sourced from the National forecasting NIFTY 50 closing movements.
Stock Exchange. Specifically, we’re utilizing the NIFTY 50
index dataset, which covers a substantial 27-year timeframe, B. Implementation of Recurrent Neural Network on Nifty 50
ranging from January 1, 1997, to December 31, 2021. This Index Dataset
dataset comprises an extensive record of over 6000 days,
detailing NIFTY 50 movements. The dataset includes data RNNs are a Neural Network variant that handles sequences
attributes such as Opening, High, Low, and Closing values. by utilizing the previous step’s output as the current step’s
However, our primary attention within this study is focused input. The standout feature is the hidden state, acting as
on the Closing value, as our objective centers on forecasting memory, which preserves sequence information. This memory
daily index movements. state, also called the Memory State, empowers the network
to grasp sequential relationships and patterns in data. While
Recurrent Neural Networks (RNNs) share the input-output
structure with other deep neural architectures, they diverge in
how information flows. Unlike traditional architectures with
distinct weight matrices per layer, RNNs maintain consistent
weights across the network. They compute hidden states (Hi)
for inputs (Xi) using specific formulas, allowing the network
to retain memory across sequences.
We employed the RNN algorithm for predicting NIFTY 50
index movements, utilizing a dataset spanning January 1, 1997,
to December 31, 2021. Our strategy centered on forecasting
closing values based on historical closing points. The structure
Fig. 1. Process flow diagram.
consisted of four layers of regressors with a dropout rate of
0.2. Moreover, we integrated a dense layer housing a single
neuron. Optimization was achieved through the utilization of
Throughout our experimental setup, we’ve meticulously the Adam optimizer, aiming to elevate the overall performance
partitioned the dataset into two segments: 70% for training of the deep learning model. We systematically endeavored to
and the remaining 30% for rigorous testing and validation enhance the model’s predictive abilities through 12 diverse
www.ijacsa.thesai.org 935 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

Fig. 3. Overall experimental framework.

TABLE I. RNN P REDICTION R ESULTS

Number of Neurons Number of Neuron Mean Absolute Prediction


Sr. Batch Size Epoch Sequence Length Training Time
in RNN in Dense Layer Percentage Error Accuracy
1 16 10 1 10 15 104.81 1.97 98.03
2 32 10 1 10 15 122.66 2.38 97.62
3 64 10 1 10 15 143.77 2.02 97.98
4 16 10 1 50 15 487.67 2.33 97.66
5 32 10 1 50 15 588.08 1.75 98.25
6 64 10 1 50 15 643.61 3.7 96.3
7 16 32 1 10 15 44.19 4.06 95.94
8 32 32 1 10 15 49.04 1.60 98.40
9 64 32 1 10 15 58.62 1.59 98.41
10 16 32 1 50 15 193.112 1.77 98.23
11 32 32 1 50 15 218 1.81 98.19
12 64 32 1 50 15 242.26 1.35 98.65

combinations of neuron counts, batch sizes, and epochs. Here, analysis, showcasing the model’s proficiency in estimating
epochs refer to the total number of complete passes made values.
through the training dataset. The accompanying Table I on
Graphs depicting the loss vs. epoch are a valuable tool
page 936 visually presents the outcomes of our tests, offering
for visualizing the training progress of a neural network. This
insights into the predictive efficacy of the RNN models across
graphical representation involves plotting the loss metric on
various configurations.
the vertical axis against the number of training epochs on the
1) Result analysis: After a comprehensive analysis of the horizontal axis. Each point along the line represents the loss
NIFTY 50 closing movement predictions using RNN across value recorded in consecutive epochs. In this context, the Fig.
12 distinct configurations (as outlined in Table I on page 936), 4(d) illustrates the loss vs. epoch graph for the RNN model
we have identified a standout performer. Specifically, the RNN that achieved the highest accuracy in predicting the movement.
model with 64 neurons, a batch size of 32, and 50 training This visual representation allows for a clear understanding of
epochs consistently outperformed all other combinations in how the model’s loss evolves throughout the training process,
terms of prediction accuracy. Impressively, this configuration offering insights into its learning dynamics and convergence.
achieved an average prediction accuracy of 98.65%, demon-
strating its robust performance. Additionally, the training time C. Implementation of Stacked Long Short-Term Memory on
for this model was deemed satisfactory. Nifty 50 Index Dataset
In Fig. 4(a), we present a visual comparison between the LSTM (Long Short-Term Memory) stands out as a highly
predicted and actual movement of NIFTY 50 closing prices, potent solution for tackling sequence prediction challenges. Its
along with the associated differences. This graphical repre- strength lies in its ability to retain past information, a critical
sentation showcases the alignment of the predicted movement factor for predicting future trends and records in daily QC
with the real data. Furthermore, Fig. 4(c) illustrates the training items. Unlike traditional RNNs, LSTM networks effectively
data’s movement and provides a detailed comparison between mitigate the issues of forgetting and gradient vanishing through
the predicted and actual movements. The chart in Fig. 4(b) the incorporation of self-loops and a unique internal gate
provides insights into the prediction accuracy versus error structure. LSTM’s unique architecture is characterized by four
www.ijacsa.thesai.org 936 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

(a) Prediction vs. actual vs. difference. (b) Accuracy percentage vs. MAPE.

(c) RNN model implementation data. (d) Losses vs. epoch.

Fig. 4. RNN model testing matrix (a) Prediction vs. actual vs. difference, (b) Accuracy Percentage vs. MAPE, (c) RNN model implementation data, (d) Losses
vs. epoch.

essential gates: Input Gate, Cell State, Forget Gate and Output 1) Result analysis: Upon conducting a comprehensive
Gate. The forget gate plays a crucial role in determining which analysis of NIFTY 50 closing movement predictions using
information is allowed to pass through the cell. Subsequently, SLSTM across 12 distinct configurations (as detailed in Ta-
the input gate decides how much new information should ble II on page 938), a clear standout has emerged. Specifically,
be incorporated into the cell state. Finally, the output gate the LSTM model featuring 32 neurons, a batch size of 10, and
regulates the information that is used for generating the output 50 training epochs consistently demonstrated superior predic-
message. The development of the LSTM network was moti- tive accuracy compared to all other parameter combinations.
vated by the necessity to address the challenge of vanishing Notably, this configuration achieved an impressive average
gradients. The critical breakthrough in the design of LSTM prediction accuracy of 99.10%, underscoring its robust perfor-
involves incorporating non-linear, data-dependent controls into mance. Moreover, the training time for this model was deemed
the RNN cell. These controls are trainable elements that satisfactory. Similarly, the model with 64 neurons, 50 epochs,
serve the purpose of preventing the gradient of the objective and batch sizes of 10 and 32 yielded comparable accuracy rates
function from diminishing in relation to the state signal. This of 99.01% and 99.08%, respectively. The analysis revealed
innovation significantly boosts the network’s ability to learn that even the lowest achieved prediction accuracy was 98.03%.
during training and enhance its predictive potential [29]. It’s noteworthy that all 12 tested LSTM configurations yielded
prediction accuracies exceeding 98%.
A SLSTM, an extension of the LSTM architecture, involves
layering multiple LSTM units to process sequential data. Each To provide a visual representation of our findings, Fig.
layer in the stack handles output sequences from the preceding 5(a) offers a comparison between predicted and actual NIFTY
one, enabling the model to grasp intricate patterns. This layered 50 closing price movements, along with the corresponding
structure enhances the model’s ability to learn hierarchical discrepancies. This graphical presentation effectively show-
features and representations in the data, similar to deep neural cases the alignment between predicted and actual trends.
networks. Stacked LSTMs excel in capturing complex tem- Additionally, Fig. 5(c) highlights the movement in the training
poral patterns in sequences, making them valuable for tasks data and offers a comprehensive juxtaposition of predicted
like time series prediction, natural language processing, and and actual trends. Finally, Fig. 5(b) presents a chart depicting
speech recognition. The accompanying Table II on page 938 the relationship between prediction accuracy and error, further
visually presents the outcomes of our tests, offering insights demonstrating the model’s adeptness at value estimation. Fig.
into the predictive efficacy of the SLSTM models across 5(d) illustrates the loss vs. epoch graph for the SLSTM model
various configurations. that achieved the highest accuracy in predicting the movement.
www.ijacsa.thesai.org 937 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

TABLE II. SLSTM P REDICTION R ESULTS

Number of Neuron Mean Absolute


Number of Neurons Prediction
Sr. Batch Size in Dense Epoch Sequence Length Training Time Percentage
in SLSTM Accuracy
Layer Error
1 16 10 16, 1 10 15 30.60 1.70 98.3
2 32 10 16, 1 10 15 30.14 1.70 98.30
3 64 10 16. 1 10 15 34.19 1.00 99.00
4 16 10 16, 1 50 15 148.07 1.10 98.90
5 32 10 16, 1 50 15 156.50 0.9 99.10
6 64 10 16, 1 50 15 185.01 0.99 99.01
7 16 32 16, 1 10 15 15.94 1.60 98.40
8 32 32 16, 1 10 15 15.46 1.40 98.60
9 64 32 16, 1 10 15 19.08 1.37 98.63
10 16 32 16, 1 50 15 66.77 1.04 98.96
11 32 32 16, 1 50 15 68.68 1.02 98.98
12 64 32 16, 1 50 15 87.23 0.92 99.08

(a) Prediction vs. actual vs. difference. (b) Accuracy percentage vs. MAPE.

(c) SLSTM model implementation data. (d) Losses vs. epoch.

Fig. 5. SLSTM model testing matrix (a) Prediction vs. actual vs. difference, (b) Accuracy percentage vs. MAPE, (c) SLSTM model implementation data, (d)
Losses vs. epoch.

D. Implementation of Bidirectional Long Short-Term Memory outcomes of our tests, offering insights into the predictive
on Nifty 50 Index Dataset efficacy of the BiLSTM models across various configurations.

A Bidirectional LSTM, abbreviated as BiLSTM, is a se- 1) Result analysis: After a comprehensive evaluation of
quence processing architecture composed of two LSTMs. One NIFTY 50 closing movement predictions using BiLSTM
LSTM processes input data in the forward direction, while the across 12 distinct configurations (as outlined in Table III on
other processes it in reverse. This dual approach significantly page 939), a prominent frontrunner has surfaced. Specifically,
enhances the information accessible to the network, thereby the BiLSTM model with 64 neurons, a batch size of 32, and
enriching the contextual understanding of the algorithm. For 50 training epochs consistently exhibited superior predictive
instance, in text analysis, a BiLSTM comprehends not only accuracy compared to all other parameter combinations. This
the current word but also the words that follow and precede configuration notably achieved an impressive average predic-
it in a sentence, amplifying its contextual awareness. The tion accuracy of 96.27%, highlighting its robust performance.
accompanying Table III on page 939 visually presents the Additionally, the training time for this model was satisfactory.
www.ijacsa.thesai.org 938 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

TABLE III. B I LSTM P REDICTION R ESULTS

Number of Neurons Number of Neuron Training Time Mean Absolute Prediction


Sr. Batch Size Epoch Sequence Length
in BiLSTM in Dense Layer (Seconds) Percentage Error Accuracy
1 16 10 10,5,1 10 20 81.76 20.99 79.01
2 32 10 10,5,1 10 20 66.44 47.90 52.10
3 64 10 10,5,1 10 20 177.06 51.10 49.90
4 16 10 10,5,1 50 20 335.74 12.97 87.03
5 32 10 10,5,1 50 20 313.74 13.43 86.57
6 64 10 10,5,1 50 20 677.32 45.25 54.75
7 16 32 10,5,1 10 20 32.86 7.72 92.28
8 32 32 10,5,1 10 20 28.88 4.19 95.81
9 64 32 10,5,1 10 20 96.95 4.69 95.31
10 16 32 10,5,1 50 20 114.81 4.87 95.13
11 32 32 10,5,1 50 20 117.90 6.49 93.51
12 64 32 10,5,1 50 20 377.99 3.73 96.27

However, it’s worth noting that the model with 32 neurons, external data sources, is a key avenue. Exploring alternative
10 epochs, and batch size of 10 indicated underfitting, while deep learning architectures and hybrid models holds poten-
the model with 64 neurons, batch sizes of 10 and 32, and tial for improved results. Moreover, incorporating sentiment
epochs of 10 and 50 demonstrated overfitting. These outcomes analysis from various sources such as financial news, social
yielded prediction accuracies that were suboptimal for our media, and macroeconomic factors can offer a more com-
NIFTY 50 trend prediction dataset. prehensive understanding of market movements. Investigating
the interpretability of deep learning models and their capacity
To visually depict our conclusions, Fig. 6(a) provides a to capture underlying market dynamics is essential for their
comparative view of predicted and actual NIFTY 50 closing practical acceptance and use in the real world.
price movements, along with discrepancies. Fig. 6(c) presents
the movement in training data, effectively comparing predicted
and actual trends. Fig. 6(b) offers a chart illustrating the con- V. C ONCLUSION
nection between prediction accuracy and error, underscoring
the model’s proficiency in value estimation. Additionally, Fig. After a thorough exploration of diverse algorithms, we have
6(d) showcases the loss vs. epoch graph for the RNN model uncovered their significant relevance within stock markets.
with the highest predictive accuracy. In summary, the identified Given the intricate interplay of factors shaping stock market
BiLSTM configuration demonstrates significant promise for dynamics, there exists a compelling opportunity to refine and
NIFTY 50 trend prediction. elevate the algorithms and models employed for predicting
stock prices. Our comparative analysis has illuminated the
robust performance of deep learning models, including LSTM,
IV. C OMPARATIVE S TUDY AND F UTURE R ESEARCH ANN, RNN, SLSTM, and BiLSTM, in efficiently forecasting
O PPORTUNITIES stock prices with minimal errors. To delve deeper, we focused
Based on our analysis of the RNN, SLSTM, and BiLSTM on implementing RNN, SLSTM, and BiLSTM deep learning
models, the SLSTM model emerged as the standout performer models within this study, harnessing a comprehensive 27-year
for predicting NIFTY 50 closing movement, achieving an im- dataset of NIFTY 50 data as our input. Our methodology
pressive prediction accuracy of 99.10%. The RNN model also allocated 70% of the dataset for model training, reserving the
showcased strong predictive capabilities, yielding an average remaining 30% for validation purposes.
accuracy of 98.65%.
During the validation phase, our findings emphatically
However, in contrast, the BiLSTM model did not demon- underscored the superior predictive capabilities of the SLSTM
strate consistent success across various cases. In its most model. It consistently outperformed the other three models in
favorable scenario, the BiLSTM model achieved an average accurately predicting the closing movement of the NIFTY 50
accuracy of 96.27%. It’s noteworthy that the training time of index, achieving an impressive average accuracy of 99.10%.
the BiLSTM model was comparatively higher when compared Our analysis further unveiled captivating behaviors inherent
to SLSTM and RNN. Additionally, the BiLSTM model was in deep learning models, presenting avenues for subsequent
more susceptible to issues of both underfitting and overfitting. exploration and model refinement. By enhancing the consis-
In summary, the SLSTM model showcased remarkable pre- tency of error patterns and elevating accuracy, these models’
dictive prowess, while the RNN model also performed well. efficacy can be further amplified. Furthermore, our research
On the other hand, the BiLSTM model faced challenges and lays the groundwork for extending prediction prowess to both
did not consistently match the accuracy levels achieved by short-term and long-term future movements. The scope of its
the other two models. Fig. 7(a) illustrates the comparison applicability can be expanded to encompass stock prices within
of predicte values, while Fig. 7(b) depicts the accuracy of other sectors, thereby fostering new realms of inquiry.
predicted movements of the models.
This study has advanced our understanding of stock market R EFERENCES
prediction but also highlights several promising directions for [1] X. Huang, “Portfolio selection with a new definition of risk,”
future research. Enhancing prediction accuracy through the European Journal of Operational Research, 2008. [Online]. Available:
refinement of existing models, including the integration of https://doi.org/10.1016/j.ejor.2007.01.045

www.ijacsa.thesai.org 939 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

(a) Prediction vs. actual vs. difference. (b) Accuracy percentage vs. MAPE.

(c) BiLSTM model implementation data. (d) Losses vs. epoch.

Fig. 6. BiLSTM model testing matrix (a) Prediction vs. actual vs. difference, (b) Accuracy percentage vs. MAPE, (c) SLSTM model implementation data, (d)
Losses vs. epoch.

(a) RNN vs. SLSTM vs. BiLSTM prediction. (b) RNN vs SLSTM vs BiLSTM prediction accuracy.

Fig. 7. (a) RNN vs. SLSTM vs. BiLSTM prediction, (b) RNN vs. SLSTM vs. BiLSTM prediction accuracy.

[2] A. Farooq and P. Chawla, “Review of data science and ai [5] M. Qiu and Y. Song, “Predicting the direction of stock market index
in finance,” in 2021 International Conference on Computing movement using an optimized artificial neural network model,” PloS
Sciences (ICCS). IEEE, 2021, pp. 216–222. [Online]. Available: one, vol. 11, no. 5, p. e0155133, 2016.
https://doi.org/10.1109/ICCS54944.2021.00050 [6] M. R. Hassan and B. Nath, “Stock market forecasting using hidden
[3] P. D. Yoo, M. H. Kim, and T. Jan, “Machine learning techniques markov model: a new approach,” in 5th International Conference on
and use of event information for stock market prediction: A Intelligent Systems Design and Applications (ISDA’05). IEEE, 2005,
survey and evaluation,” vol. 2, 2005. [Online]. Available: https: pp. 192–196.
//doi.org/10.1109/CIMCA.2005.1631572 [7] M.-C. Lee, “Using support vector machine with a hybrid feature
[4] K.-j. Kim and I. Han, “Genetic algorithms approach to feature selection method to the stock trend prediction,” Expert Systems with
discretization in artificial neural networks for the prediction of stock Applications, vol. 36, no. 8, pp. 10 896–10 904, 2009. [Online].
price index,” Expert systems with Applications, vol. 19, no. 2, pp. 125– Available: https://doi.org/10.1016/j.eswa.2009.02.038
132, 2000. [Online]. Available: https://doi.org/10.1016/S0957-4174(00) [8] J. Sirignano and R. Cont, “Universal features of price formation
00027-0 in financial markets: perspectives from deep learning,” Quantitative

www.ijacsa.thesai.org 940 | P a g e
(IJACSA) International Journal of Advanced Computer Science and Applications,
Vol. 14, No. 10, 2023

Finance, vol. 19, no. 9, pp. 1449–1459, 2019. [Online]. Available: deep learning: The case of china,” Finance Research Letters, vol. 46,
https://doi.org/10.2139/ssrn.3141294 p. 102209, 2022. [Online]. Available: https://doi.org/10.1016/j.frl.2021.
[9] L.-P. Ni, Z.-W. Ni, and Y.-Z. Gao, “Stock trend prediction based on 102209
fractal feature selection and support vector machine,” Expert Systems [20] S. Mukherjee, B. Sadhukhan, N. Sarkar, D. Roy, and S. De, “Stock
with Applications, vol. 38, no. 5, pp. 5569–5576, 2011. [Online]. market prediction using deep learning algorithms,” CAAI Transactions
Available: https://doi.org/10.1016/j.eswa.2010.10.079 on Intelligence Technology, vol. 8, no. 1, pp. 82–94, 2023. [Online].
[10] S. McNally, J. Roche, and S. Caton, “Predicting the price Available: https://doi.org/10.1049/cit2.12059
of bitcoin using machine learning,” in 2018 26th euromicro [21] Y. Zhao and G. Yang, “Deep learning-based integrated framework for
international conference on parallel, distributed and network-based stock price movement prediction,” Applied Soft Computing, vol. 133,
processing (PDP). IEEE, 2018, pp. 339–343. [Online]. Available: p. 109921, 2023. [Online]. Available: https://doi.org/10.1016/j.asoc.
https://doi.org/10.1109/PDP2018.2018.00060 2022.109921
[11] B. Weng, L. Lu, X. Wang, F. M. Megahed, and W. Martinez, [22] A. Q. Md, S. Kapoor, C. J. AV, A. K. Sivaraman, K. F. Tee,
“Predicting short-term stock prices using ensemble methods and online H. Sabireen, and N. Janakiraman, “Novel optimization approach for
data sources,” Expert Systems with Applications, vol. 112, pp. 258–273, stock price forecasting using multi-layered sequential lstm,” Applied
2018. [Online]. Available: https://doi.org/10.1016/j.eswa.2018.06.016/ Soft Computing, vol. 134, p. 109830, 2023. [Online]. Available:
[12] Y. Kara, M. A. Boyacioglu, and Ö. K. Baykan, “Predicting direction https://doi.org/10.1016/j.asoc.2022.109830
of stock price index movement using artificial neural networks and [23] A. Dezhkam and M. T. Manzuri, “Forecasting stock market for an
support vector machines: The sample of the istanbul stock exchange,” efficient portfolio by combining xgboost and hilbert-huang transform,”
Expert systems with Applications, vol. 38, no. 5, pp. 5311–5319, 2011. Engineering Applications of Artificial Intelligence, vol. 118, p. 105626,
[Online]. Available: https://doi.org/10.1016/j.eswa.2010.10.027 2023.
[13] X. Li, Y. Li, H. Yang, L. Yang, and X.-Y. Liu, “Dp-lstm: [24] L. Zhang, C. Aggarwal, and G.-J. Qi, “Stock price prediction
Differential privacy-inspired lstm for stock prediction using financial via discovering multi-frequency trading patterns,” in Proceedings
news,” arXiv preprint arXiv:1912.10806, 2019. [Online]. Available: of the 23rd ACM SIGKDD international conference on knowledge
https://doi.org/10.48550/arXiv.1912.10806 discovery and data mining, 2017, pp. 2141–2149. [Online]. Available:
https://doi.org/10.1145/3097983.3098117
[14] S. Mehtab, J. Sen, and A. Dutta, “Stock price prediction using
machine learning and lstm-based deep learning models,” in Machine [25] G. Li, A. Zhang, Q. Zhang, D. Wu, and C. Zhan, “Pearson correlation
Learning and Metaheuristics Algorithms, and Applications: Second coefficient-based performance enhancement of broad learning system
Symposium, SoMMA 2020, Chennai, India, October 14–17, 2020, for stock price prediction,” IEEE Transactions on Circuits and Systems
Revised Selected Papers 2. Springer, 2021, pp. 88–106. [Online]. II: Express Briefs, vol. 69, no. 5, pp. 2413–2417, 2022. [Online].
Available: https://doi.org/10.48550/arXiv.2009.10819 Available: https://doi.org/10.1109/TCSII.2022.3160266
[15] H. NekoeiQachkanloo, B. Ghojogh, A. S. Pasand, and M. Crowley, [26] S. Banik, N. Sharma, M. Mangla, S. N. Mohanty, and S. Shitharth,
“Artificial counselor system for stock investment,” in Proceedings “Lstm based decision support system for swing trading in stock
of the AAAI conference on artificial intelligence, vol. 33, no. 01, market,” Knowledge-Based Systems, vol. 239, p. 107994, 2022.
2019, pp. 9558–9564. [Online]. Available: https://doi.org/10.48550/ [Online]. Available: https://doi.org/10.1016/j.knosys.2021.107994
arXiv.1903.00955 [27] Z. K. A. Bodie and A. J. Marcus, Investments and portfolio manage-
[16] M. Nabipour, P. Nayyeri, H. Jabani, A. Mosavi, and E. Salwana, ment. McGraw Hill Education (India) Private Limited, 2013.
“Deep learning for stock market prediction,” Entropy, vol. 22, no. 8, [28] D. Spahija and S. Xhaferi, “Fundamental and technical analysis of
p. 840, 2020. [Online]. Available: https://doi.org/10.3390/e22080840 the stock price,” International Scientific Journal Monte, vol. 1, 2019.
[17] M. Hiransha, E. A. Gopalakrishnan, V. K. Menon, and K. Soman, [Online]. Available: https://doi.org/10.33807/monte.1.201904160
“Nse stock market prediction using deep-learning models,” Procedia [29] M. Sundermeyer, R. Schlüter, and H. Ney, “Lstm neural networks
computer science, vol. 132, pp. 1351–1362, 2018. [Online]. Available: for language modeling,” in Thirteenth annual conference of the
https://doi.org/10.1016/j.procs.2018.05.050 international speech communication association, 2012. [Online].
[18] M. R. Vargas, B. S. De Lima, and A. G. Evsukoff, “Deep Available: https://doi.org/10.1016/j.physd.2019.132306
learning for stock market prediction from financial news articles,”
in 2017 IEEE international conference on computational intelligence Disclaimer: This analysis is for research purposes only
and virtual environments for measurement systems and applications and should not be considered as trading recommendations;
(CIVEMSA). IEEE, 2017, pp. 60–65. [Online]. Available: https: individuals who choose to do so assume their own risk for
//doi.org/10.1109/CIVEMSA.2017.7995302
potential losses.
[19] Q. Liu, Z. Tao, Y. Tse, and C. Wang, “Stock market prediction with

www.ijacsa.thesai.org 941 | P a g e

You might also like