0% found this document useful (0 votes)
22 views8 pages

Stock Market Forecasting with LSTM

The document discusses a study on stock market forecasting using a metaheuristic LSTM approach combined with sentiment analysis. It highlights the effectiveness of the MLSTM model in predicting stock prices and correlations while providing risk assessments, demonstrating improved accuracy compared to traditional methods. The research emphasizes the importance of machine learning in financial markets and proposes a new deep learning technique for better forecasting outcomes.

Uploaded by

srav0706
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)
22 views8 pages

Stock Market Forecasting with LSTM

The document discusses a study on stock market forecasting using a metaheuristic LSTM approach combined with sentiment analysis. It highlights the effectiveness of the MLSTM model in predicting stock prices and correlations while providing risk assessments, demonstrating improved accuracy compared to traditional methods. The research emphasizes the importance of machine learning in financial markets and proposes a new deep learning technique for better forecasting outcomes.

Uploaded by

srav0706
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/364313640

Stock Market Forecasting Using Metaheuristic LSTM Approach with Sentiment


Analysis

Article · October 2022

CITATIONS READS

0 103

2 authors, including:

Manoj Kumar Rawat


Alliance University Bangalore
19 PUBLICATIONS 28 CITATIONS

SEE PROFILE

All content following this page was uploaded by Manoj Kumar Rawat on 12 October 2022.

The user has requested enhancement of the downloaded file.


SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

Stock Market Forecasting Using Metaheuristic LSTM Approach


with Sentiment Analysis

Gaurav J. Sawale1 Dr Manoj K. Rawat2


[Link],
Professor,
Department of Computer Science &
Department of Computer Science &
Engineering,
Engineering,
SAGE University Indore, Madhya Pradesh,
SAGE University Indore, Madhya Pradesh,
India,
India,
gsawale8@[Link]
[Link]@[Link]

Abstract
Machine learning, which differs from conventional algorithms and models in that it applies computer
algorithms and statistical models in a systematic and all-encompassing manner, is utilized extensively in a
variety of fields. Machine learning is mostly utilized in the realm of finance to analyze the trajectory of capital
market prices. In this study, we employed conventional models and machine learning models for predicting
linear and non-linear issues, respectively, to predict the time-series data of stocks with less risk. The LSTM
(long short-term memory) neural network model is used to train and forecast stock price and stock price sub-
correlation, and the proposed time series-based metaheuristic model is utilized to construct a prediction with
risk assessment. The experiment findings demonstrate that: (1) Stock price and stock price correlation are
accurately predicted by the MLSTM model; and (2) compared with the existing model for performance
checking. Finally, we analyze the proposed model using a number of indicators.
As a result, our suggested solution offers less complicated assistance and method for risk analysis.

Keywords: Stock market, LSTM, MLSTM, Performance.

1. Introduction
In general, the word "stock market" refers to a group of markets where equity, bond,
and other types of securities are issued and traded via various over-the-counter (OTC)
markets, physical exchanges, and electronic exchanges. One of the most crucial elements of
a market economy is the stock market because it gives businesses access to capital by
enabling investors to purchase shares of firm ownership. The stock market's environment
is continually changing as a result of process improvements. Given the daily differences it
delivers, investors must carefully prepare their strategies in order to succeed [1]. When
predicting stock market data, it is assumed that current publicly available data has some
predictive correlations to future stock returns. The very complex world of the stock market
makes stock trend forecasting one of the most challenging undertakings in the financial
sector. By predicting stock movements and reducing investment risk, stock market
investors are constantly looking for a strategy that may ensure simple earnings. This
encourages forecasting model developers to create new forecasting techniques [2]. Stock
prices can be thought of as a discrete-time series model, which is based on a set of clearly
defined numerical data items acquired at subsequent points at regular intervals of time.
Stock prices are not numbers that are generated at random; rather, they can be handled as
such. Since it is crucial to find a model to analyze stock price movements with sufficient
data for decision-making [3], it is advised that using CNN to convert the time series is a
better algorithmic method than directly forecasting because it produces more accurate

1800
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

results. Prior to processing, the MCNN Model transforms non-stationary data into
stationary data. It is one of the most widely used models for predicting data from linear
time series. A programming language and environment for statistical and graphical
processing, Python. Data analysts typically use the Python programming language for
statistical programming and data analysis [4].

1.1 Motivation and Background


The exchange of the venture's stocks or shares will take place on the stock market.
People who exchange shares must register with a company called the Security and
Exchange Board of India, which is a collaboration with a controlling body (SEBI). The SEBI
is given the mandate to support the growth of Indian stock exchanges. It protects the
interests of small-time investors in the same way as the legal system, market regulation,
and the activities of financial intermediaries do, assisting when it is challenging to predict
the stock market. Organizations typically take a very unstable stance when estimating
future stock costs. The strategy of anticipating stock costs makes future predictions of
stock costs based on historical data [5]. The stock exchange regularly displays stock costs
based on the production and consumption of goods. When there is interest in the
organization's stock costs, the stock costs will increase, however when there is less interest
due to risk at the organization's stock costs, the stock costs will decline. Financial experts
who may have invested in particular organizations need to increase their revenues. This
should be possible by promptly exchanging their offer [6].
The prediction of future stock exchanges is one of the most difficult tasks when we
consider the market as a whole. This is useful because it gives us a clear understanding of
how to separate the assets and how to foresee future expenses, which enables us to think
about the future. Financial experts also hope to effectively identify risks so that rewards
from speculating can be significantly more prominent. Economic expectations will aid in
ensuring that the interaction between producers and consumers is protected [7].
We have largely concentrated on the degree of accuracy of forecasting stock values
with less risk for various sectors in this work, which will help new investors to understand
the market and make a sensible decision to invest in the stock market.
The following are this paper's main contributions:
(1) A new deep learning technique (MCNN) is suggested to predict the stock price
with risk analysis by studying the correlation and time series of stock price data. CNN is
utilized in this method to forecast data as well as extract the time feature of the data [8]. It
can fully utilize the stock price data's time sequence to produce more accurate forecasts
with lower risk.
(2) It is demonstrated that MLSTM has high forecasting accuracy and is better
suitable for stock price forecasting with a lower risk factor by comparing the evaluation
indices of CNN with multilayer perceptron (MLP), CNN, RNN, LSTM, and CNN-RNN.

2. Related work
The stock price can be projected using either the traditional analysis method or the
machine learning method at the moment because the financial market is a noisy,
nonparametric dynamic system. The analysis of complicated, high-dimensional, and noisy
financial series data is not appropriate for using typical econometric approaches or
equations with parameters. Because it can extract data features from a huge number of

1801
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

high-frequency raw data without relying on prior information, neural networks have
recently been a popular research area in the field of stock forecasting. White utilized a
neural network to forecast IBM stock in 1988, but the experiment's outcomes weren't
promising. Zhang projected equities in 2003 using a neural network and an ARIMA
(autoregressive integrated moving average model). The experimental findings demonstrate
clear advantages of neural networks in nonlinear data forecasting, but accuracy still needs
to be increased. A time series forecasting technique based on a neural network was put
forth by Sun et al. in 2005. The optimum partition algorithm (OPA) and radial basis
function (RBF) neural network are combined in this approach. Adhikari et al. suggested a
method in 2014 to predict four financial time series data using a combination of random
walk (RW) and artificial neural network (ANN), and the results showed a certain
improvement in forecasting accuracy [9]. The network structure of stock price forecasting
based on the LM-BP neural network was proposed by Zhang et al. in 2018, which
addressed the limitations of the classic BP neural network training technique, including its
sluggish training speed and low precision. A convolutional neural network can predict time
series in 2018, according to Hu et alexperimental .'s findings, although deep learning is
more suited to handling the problem of time series. The forecasting accuracy of CNN alone
is, however, only moderate because it is more frequently used to address picture
identification and feature extraction problems.
Kamalov used MLP, CNN, and LSTM to predict the stock prices of four significant US
public firms for the year 2020. These three strategies outperformed comparable research
that predicted the direction of price change, according to experimental findings [10].
A high-precision short-term forecasting model for financial market time series was
developed by Xue et al. in 2020 and compared to the BP neural network, the conventional
RNN, and the enhanced LSTM deep neural network. The outcomes demonstrated that the
LSTM deep neural network has good forecasting accuracy and is capable of accurately
predicting stock market time series [12].
Zhang et al. (2019) build a model to forecast gas concentration using LSTM multi-
dimensional time-series data in this research study. The author has used the LSTM model,
which uses time series data from the gas concentration data set, to improve the accuracy of
the forecast of the gas concentration. The batch size and the number of layers are the
variables that are employed in the gas prediction model. This improved model is used to
forecast the gas concentration for upcoming time periods after fitting the LSTM model. The
training set is altered in this case to meet the range between 0 and 1. The Sklearn
preprocessing package's Minmax scaler method, which has been imported, is used for this
transformation.

2.1 Deep Learning Techniques Used in Stock Price Prediction


The LSTM model was used in this study by Fischer and Krauss (Fischer and Krauss;
2018), who saw it as a cutting-edge model suitable for sequence learning. The author
claims that while LSTM models are better appropriate for this type of data, they are rarely
used to financial time series data. For the purpose of predicting stock market data between
the years 1992 and 2015, the author deployed the LSTM model. The LSTM models have
outperformed memory-free classification models like Random Forest, Deep Neural
Networks, and Logistic Regression. They have developed a trading strategy based on
forecasts that are consistent with current literature with the use of the LSTM model. The

1802
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

outcomes are more trustworthy when they use volume-weighted average pricing (VWAP)
as opposed to closing prices [13].
As it is crucial to assess the viability of the position of an investment and the
associated risks, (Guo; 2020) has developed a method to anticipate volatility on the basis of
environmental, governmental, and social news flow. These environmental, governmental,
and social data are structured, and the ESG data can be incorporated and further fed into
the model. The output of this model is useful for developing professional investment advice
for ESG. The textual financial ESG data, according to the author, are the data that are fed
into the model. To forecast the news that is connected to ESG, they have employed a natural
language processing model, which is a deep learning technique. To convert the data from
text to numerical, they employed a language model that is based on transformers.
Mehtab and Sen (2019) used the NIFTY 50 dataset from the National Stock
Exchange of India in this research work. They have used the NIFTY 50 data's closing value.
The data set includes information from 2015 to 2017. They have made predictions for the
data from 2018 to 2019. They have used a variety of classification techniques to forecast
the movement of the stock price. To forecast the closing stock price value, they have used a
variety of regression models. To predict the closing value of the stock price, they have used
a variety of machine learning algorithms, including multivariate regression, bagging,
boosting, Random Forest, decision trees, and support vector machines. However, to predict
the close value of the stock price, they have used LSTM, a deep learning network [14].
In order to anticipate the stock price of future dates, this research article (Moghar
and Hamiche; 2020) uses Recurrent Neural Networks (RNN), particularly Long Short-Term
Memory (LSTM). The author is interested in learning how accurately the LSTM predicts the
future stock price. They also want to know how many epochs are employed to achieve the
best possible stock price forecast outcomes. The Network Stock Exchange provided the
data that they needed for the analysis (NYSE). The remaining 20% of the data was taken
into account for testing, and the remaining 80% was used for training. To enhance the
model's performance, they used mean squared error during the training process. To
evaluate the model's performance, they took into account various epochs in ascending
order. The author has noted that more epochs and less training data are needed to provide
effective forecasting results.
Deep learning approaches were used in this study work by Saud and Shakya (2020)
because they are more effective at anticipating stock prices. RNN models were used by the
author to assess the look-back period parameter. Vanilla RNN, GRU, and LSTM are the deep
learning models that the author employed for the analysis. The data set they selected for
the analysis includes stock price data for the banks on the Nepal Stock Exchange's list
(NEPSE). The data was preprocessed by the author, who used the next day's close price
column for the analysis. For scaling the data, they used Z score normalization. In a ratio of
nine to one, the data are divided into training data and testing data. The three models are
then fitted, and a comparison is done in light of the outcomes. The findings indicate that,
when compared to other deep learning models, the GRU model performs better [13].
Here, in this research work, the data from the most recent transaction were used to
extract the pertinent information by (Wen et al.; 2019). Forecasting future or immediate
ups and downs uses the information that has been gathered. The machine learning models
are capable of accurately identifying the nonlinear dependencies in the stock price. They
have selected the S & P 500 data set for the analysis. The stock price time series data will be

1803
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

exceedingly erratic and non-stationary. Therefore, it will be challenging to predict future


stock market statistics. The author has created a system that will recreate the sequences
that will be influenced by these sequenced patterns in order to stop these common
patterns from occurring [10]. Later, they used a convolutional neural network to
extrapolate the time series data' future stock price.

3. METHODOLOGY
3.1. MCNN Model
Because LSTM focuses on the most glaring features in the line of sight, it is
frequently utilized in feature engineering. LSTM, which is frequently employed in time
series, has the property of growing in accordance with the passage of time. A stock
forecasting model built on LSTM is constructed in accordance with its properties. The
figure displays the model's structure. The major component is an LSTM, which is also
present in the input layer, one-dimensional convolution layer, pooling layer, LSTM hidden
layer, and complete connection layer.

Figure 01: Work Flow for Predicting the Stock market prediction with risk analysis

The preprocessing step for categorizing sentiment analysis from reviews has been
done in the suggested technique.
Sentiment classification, score generation, preprocessing, train/validation/test
splitting, and dataset collection

4. Experiments
Using the same training set and test set data in the same operating environment, we
compared MCNN with MLP, CNN, RNN, LSTM, and CNN-RNN to demonstrate its efficacy.
Windows 10 and a running environment are used for all studies. Risk analysis is
anticipated based on the influencing elements, such as the opening price, maximum price,
lowest price, closing price, volume, turnover, ups and downs, and change.

1804
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

4.1. Data
The Shanghai Composite Index (000001) is chosen as the experimental data in this
experiment. The wind database is used to get the daily trading data. For risk analysis and
accurate stock prediction, each piece of data has several components, including the opening
price, maximum price, lowest price, closing price, volume, turnover, ups and downs, and
change. Consider some sample trading day data as the training set and some sample
trading day data as the test set. After testing and training the dataset under consideration,
certain companies' predictions with risk analysis are shown in the following figure.

Figure 03: Using MLSTM, a comparison between the closing price of some company and
the closing value as predicted.
After training MLP, CNN, RNN, and LSTM with the training set data that has been
processed The model developed during training are utilized to forecast the test set data for
CNN-RNN and MLSTM, respectively, and the real value is compared with the predicted
value as shown in the accompanying Figures.

Figure 04: The outcome of comparing mean absolute errors (MAE) across several
techniques.
5. Conclusion and Future Work
In this study, we conducted a critical analysis of the machine learning and deep
learning models used to predict stock prices. We used the proposed technique to identify
the company names in order to forecast the stock prices of various companies. The
extraction, transformation, and loading of the stock price data have all been successfully
completed since the postgres database has been utilized to store the dimension and stock
price data of the companies. Exploratory data analysis has been effectively completed with
minimal risk in order to obtain the inside details of the stock price prediction. The stock
price data has been analyzed using deep learning models like LSTM as well as machine
learning models like ANN and SVM. These models have each undergone a comparative time
series analysis including risk analysis. In comparison to currently used methods, the
Prediction value we have gotten for the Proposed model is lower. As a result, we were able

1805
SPECIALUSIS UGDYMAS / SPECIAL EDUCATION 2022 2 (43)

to apply, assess, and contrast the proposed approach's outcomes with those of existing
models. This study can be applied on a broad scale with other performance parameters in
the future if the data set includes more companies and their corresponding stock values.

References:
[1] R. Vanaga and B. Sloka, “Financial and capital market commission financing: aspects
and challenges,” Journal of Logistics, Informatics and Service Science, vol. 7, no. 1,
pp. 17–30, 2020.
[2] L. Zhang and H. Kim, “The influence of financial service characteristics on use
intention through customer satisfaction with mobile fintech,” Journal of System and
Management Sciences, vol. 10, no. 2, pp. 82–94, 2020.
[3] L. Badea, V. Ionescu, and A.-A. Guzun, “What is the causal relationship between stoxx
europe 600 sectors? But between large firms and small firms?” Economic
Computation And Economic Cybernetics Studies And Research, vol. 53, no. 3, pp. 5–
20, 2019.
[4] J. Sousa, J. Montevechi, and R. Miranda, “Economic lot-size using machine learning,
parallelism, metaheuristic and simulation,” Journal of Logistics, Informatics and
Service Science, vol. 18, no. 2, pp. 205–216, 2019.
[5] Coser, M. M. Maer-Matei, and C. Albu, “Predictive models for loan default risk
assessment,” Economic Computation And Economic Cybernetics Studies And
Research, vol. 53, no. 2, pp. 149–165, 2019.
[6] R. Qiao, “Stock prediction model based on neural network,” Operations Research
and Management Science, vol. 28, no. 10, pp. 132–140, 2019.
[7] Y. Xue, C. Wang, and C. Miao, “Research on financial assets transaction prediction
model based on LSTM neural network,” Neural Computing and Applications, vol. 1,
2020.
[8] Zhang, T., Song, S., Li, S., Ma, L., Pan, S. and Han, L. (2019). Research on gas
concentration prediction models based on lstm multidimensional time series,
Energies 12(1): 161.
[9] Chaudhary, V., Deshbhratar, A., Kumar, V. and Paul, D. (2018). Time series based
lstm model to predict air pollutant’s concentration for prominent cities in india,
UDM, Aug
[10] Fischer, T. and Krauss, C. (2018). Deep learning with long short-term memory
networks for financial market predictions, European Journal of Operational Research
270(2): 654–669.
[11] Guo, T. (2020). Esg2risk: A deep learning framework from esg news to stock
volatility prediction, Available at SSRN 3593885
[12] Mehtab, S. and Sen, J. (2019). A robust predictive model for stock price prediction
using deep learning and natural language processing, Available at SSRN 3502624
[13] Moghar, A. and Hamiche, M. (2020). Stock market prediction using lstm recurrent
neural network, Procedia Computer Science 170: 1168–1173.
[14] Qiu, M., Song, Y. and Akagi, F. (2016). Application of artificial neural network for the
prediction of stock market returns: The case of the japanese stock market, Chaos,
Solitons & Fractals 85: 1–7.

1806

View publication stats

Common questions

Powered by AI

LSTM models are better suited for sequence learning and handling temporal dependencies, making them superior for time-series data like stock markets. LSTM significantly improves forecasting accuracy by capturing long-term dependencies and outperforming memory-free models such as CNN and MLP, which may struggle with nonlinear data like stocks .

The number of epochs has a significant effect on the accuracy of LSTM models in stock price prediction. More epochs generally provide better forecasting results by enabling the model to learn complex patterns more thoroughly, although this also requires more training data to avoid overfitting .

Traditional econometric methods face challenges in predicting stock market trends as they struggle with high-dimensional, nonparametric, noisy financial series data. These methods typically rely on static and linear assumptions, making them unsuitable for capturing the dynamic, nonlinear characteristics of stock markets, unlike neural networks which can learn from raw data without relying on prior assumptions .

The GRU model might outperform other deep learning models in stock market predictions due to its simplified architecture, which combines memory cell and gate structures, making it efficient in capturing time-series dependencies without complexity. This results in better performance in handling non-linear dependencies typical in stock data .

LSTM improves the prediction of gas concentration from time series data by utilizing its sequence learning properties to capture temporal dependencies and effectively process multidimensional data sets. It allows for better accuracy by adjusting parameters like batch size and the number of layers to fit specific characteristics of the data set .

Incorporating ESG data into stock market prediction models enhances the prediction by providing additional structured data that reflect environmental, governmental, and social impacts on market volatility. This information is used with a natural language processing model for more accurate forecast development, offering insights into risks related to news flows .

The MCNN model integrates risk analysis by examining influencing factors such as opening, closing, maximum, and minimum prices, as well as volume and turnover. By using CNN to extract these features and LSTM to process time series data, the model computes anticipated ups and downs, allowing for an assessment of risks associated with stock price movements .

Data normalization, such as using Z score normalization, helps improve the accuracy of models like RNN, GRU, and LSTM by ensuring that data input to the models is scaled properly, leading to better convergence and more reliable training outcomes. This preprocessing step is crucial for effectively training these models to predict stock prices .

The MCNN method improves prediction accuracy by fully utilizing the time sequence of stock price data and performing risk analysis, showing better suitability for stock price forecasting with lower risk compared to traditional methods like CNN, RNN, and LSTM. The MCNN performs better by studying the correlation and time series data, whereas CNN alone has only moderate accuracy as it is often used for picture identification and feature extraction .

The prediction value from the proposed model is lower due to its enhanced capability in combining feature extraction and sequence learning, driven by LSTM and CNN, leading to more accurate risk analysis and reduced prediction errors. This model effectively handles the complexity and noisy nature of financial time series data, outperforming conventional models .

You might also like