# The Influence and Prediction of Industry Asset Price Fluctuation Based on The LSTM Model and Investor Sentiment

Authors: Wenxiu Hu; Huan Liu; Xiaoqiang Ma; Xiong Bai
Journal: Mathematical Problems in Engineering
 (2022)

---

## Abstract

In a real-world environment, not only can different levels of market expectations be triggered by factors such as macroeconomic policies, market operating trends, and current company developments have an impact on sector assets, but sector asset rises and falls are also influenced by a factor that cannot be ignored: market sentiment. Therefore, this paper uses LSTM to construct a forecasting model for industrial assets based on investor sentiment and public historical trading data of industry asset markets to determine future trends and obtains two conclusions: first, forecasting models incorporating investor sentiment have better forecasting effects than those without the incorporation of sentiment characteristics, indicating that the factor of investor sentiment should not be ignored when studying the problem of industry asset forecasting; secondly, investor sentiment quantified by different methods.


---

## Body

## 1. Introduction

As people’s living standards rise, consumption is becoming a decreasing proportion of disposable income, replaced by investments, savings, and financial management [1]. Nowadays, investment and financial management are gradually coming into the public eye, and more and more people are concerned about and studying how to invest more effectively in order to allocate their disposable income rationally and maximize the return on their existing funds. The financial markets are developing at an unstoppable pace, and in the process of adapting to economic development, many investment options have emerged, most of which are based on the bond market, futures market, and the sector asset market [2]. Amongst these, the sector asset market has low investment thresholds and high liquidity, i.e., it can be quickly realized when investors need liquidity, making it the most common choice for retail investors to invest in the sector asset market to achieve a reasonable distribution of income. However, changes in the sector asset market are unpredictable and various factors, both imagined and unanticipated, may have an impact on sector assets to a greater or lesser extent, and the market may not respond to various impacts to the same extent. The impact on asset volatility in the industry is explained in [3].In the field of industry asset research, scholars hope to discover the overall operation and trends of industry assets through effective technical means, but after years of practice and research analysis, it is found that such ideas are difficult to realize in real life [4]. The efficient market hypothesis is considered a good theory to explain the changes in the development of the industry asset market, which believes that all effective information in the industry asset market is reflected in the historical prices of industry assets and that the future prices of industry assets are mainly affected by future information [5]. However, there are many factors that cause changes in future information that make forecasting future information very difficult, if not impossible, and therefore it is impossible to achieve forecasts of future industry assets using technical analysis under the efficient market hypothesis [6]. With the development of research and the emergence of other innovative theories, researchers have discovered that the role of investors’ psychology, i.e., irrational factors, can have an impact on their financial behavior, and this is what behavioral finance studies. With the current poor transmission mechanism in the financial markets and the time lag in information, investors have a certain speculative mentality when investing in sector assets, usually wanting to get relatively high returns for less cost, which confirms the adage “speculation is speculation.” In addition, sector assets influence investors’ decisions, which in turn influence sector assets, forming a two-way cycle, similar to the bank’s “run effect,” but investors’ decisions are often made with limited rationality mixed with some subjective judgment [7]. Family background, education, social background, etc. as the concept of behavioral finance has entered the public consciousness, some traditional theories are no longer applicable to the current financial markets. For example, while traditional asset pricing is theoretically defined based on the impact of macroeconomic policies, mesoindustry developments, and microfirm operating conditions on industry assets, there is usually a gap between asset prices in real markets and the theoretically expected prices, and behavioral finance has a unique understanding of the existence of this gap, which it sees as a result of investors’ emotional decisions. The existence of such a gap is uniquely understood by behavioral finance as a result of the “rational constraints” of investors’ emotions, which can create a systematic bias in the market as a whole and can also influence the next step in investor behavior [8].In this paper, we consider the textual comments that reflect investors’ sentiment positively and the proxy indicators that reflect investors’ sentiment laterally, and after obtaining the textual data of investors’ sentiment, we carry out sentiment identification through sentiment analysis to obtain the negative and positive sentiment classification, based on which we obtain the textual investors’ sentiment index that represents investors’ sentiment, and together with some of the proxy indicators, we achieve the construction of a comprehensive index of investors’ sentiment through factor analysis. Finally, the index is used as the input variable of the LSTM model to build a prediction model for industry asset trends [9]. The validity of the model is tested through comparative analysis of different models and different industry backgrounds. This paper integrates the theories in the field of investor sentiment research with those in the field of industry asset forecasting research and investigates the degree of influence of investor sentiment on different styles of industries classified by CITIC style series subindices, which has certain theoretical significance for enriching industry asset forecasting models [10].


## 2. Related Work

The low threshold of the sector asset market and the readiness of investors to realize funds when they need them have made the equity market one of the more active markets in the financial investment sector [11]. These characteristics make the stock market a more active market in the financial investment sector. In order to invest wisely and profitably, investors focus their attention on forecasting the trend of sector assets. The common methods used to forecast sector assets are fundamental analysis and technical analysis. Among them, the fundamental analysis method is highly subjective and mainly involves some financial researchers analyzing the future ups and downs of industry assets based on public information in the market (e.g. national policies, industry developments, company financial reports, company announcements, etc.) and combining it with their own experience, which is a test of the researcher’s professionalism and experience. For example, [12] proposed fundamental analysis methods such as the Delphi method, the principal probability method, and the cross-probability method to qualitatively forecast industry assets. Technical analysis methods are further divided into those based on statistical views and those based on data mining algorithms. Yang et al. [13] used GA-Elman neural networks to construct industry asset forecasting models, which not only achieve better forecasting results, but can also quickly calculate a large amount of data and save running time. An et al. [14] processed the mined news and financial text data and input them into a machine learning model to predict industry assets and analyzed various evaluation indicators to show that the prediction effect of the machine learning model based on text sentiment was significant.Industry asset forecasting research has been the focus of financial researchers, and scholars have proposed many models for forecasting industry assets based on empirical and optimization studies, such as autoregressive moving average models, GRU models, and artificial neural network-type models. In order to optimize the models to achieve better forecasting results, scholars have conducted various studies: Ma et al. [15] compared BP neural networks, grey GM (1, 1) and their hybrid models, and concluded that hybrid models have better forecasting results; Thakkar and Chaudhari [16] mixed SVM models with GARCH models in order to improve the forecasting results of SVM models, and incorporated sentiment factors. In order to improve the forecasting effect of the SVM model, they mixed it with the GARCH model and incorporated the sentiment factor and investor attention into the forecasting model, and obtained a better forecasting effect. The model with the sentiment incorporated had a better effect than the model without the sentiment incorporated; Nasekin and Chen [17] chose the LSTM model to analyze the industry asset forecasting problem, and the results showed that the LSTM model could not only forecast industry assets better, but also run quickly when the data volume was large, and investors could draw on the forecasting results of the model. The results show that the LSTM model is not only good at predicting industry assets but also fast when the volume of data is large [18].


## 3. LSTM Model Based on Principal Component Analysis

### 3.1. Obtaining Training Data

The nine basic data items of the selected sector assets were obtained through the sector asset data stations of the major financial websites and the TuShare financial data interface package for Python: opening price, closing price, high price, low price, previous closing price, up/down amount, up/down range, volume, and turnover amount. These are shown in Table1. The KDJ and MACD indicators calculated for the underlying data are used together as training data for the model.Table 1
Industry asset base data.
Ts codeTrade dateOpenHighLowClosePre closeChange0000001.SZ2019031412.3312.6212.5512.6410.20.050.1841000001.SZ2019031312.3412.5512.1212.370.010.08262000001.SZ2019031212.4912.6412.2412.3612.320.043999000001.SZ2002012110.199.579.610.18−0.59−5.78The KDJ indicator is a sensitive and fast technical analysis indicator that uses the real volatility of the price fluctuations of sector assets to reflect the strength of the price change trend and can signal a buy or sell before the sector assets have risen or fallen. The highest and lowest prices that have occurred in a period, the last closing price of the period, and the proportional relationship between these three are used to calculate the unripe stochastic value of RSV on the last day of the period, and then theK, D, and J values are calculated based on the sliding average method [19].The K value is the n-day moving average of the RSV and the K line, which is also known as the fast line, changes at a moderate rate among the 3 curves; theD value is the n-day moving average of the K value and the D line changes at the slowest rate among the 3 lines and is known as the slow line; the J value changes the fastest and is known as the ultra-fast or confirmation line as an aid to observing the buying and selling signals from the K and D lines. The three lines on the same coordinate make up the KDJ indicator, which reflects the trend of price fluctuations.(1)RSV=Cn−Ln/Hn−Ln×100,K=23Kp+13RSV,D=23Dp+13K,J=3×K−2×D,where Cn is the closing price on day n, Ln is the lowest price on day n, Hn is the highest price on day n, and Kp、and Dp is the previous day’s K and D values, both replaced by 50 if not available.MACD is also known as the moving average of divergence. The convergence and divergence of the fast and slow averages represent changes in market trends and are a common technical indicator for sector assets. The fast and slow-moving averages, EMA, are generally chosen as the 12-day and 26-day moving averages, and their divergence, DIF, and the divergence’s 9-day moving average, DEA, are calculated to give the MACD.(2)EMAn=n−1n+1×PEMAn+2n+1,DIF=EMA12−EMA26,DEA=n−1n+1×PDEAn+DIF,MACD=DIF−DEA×2,where n is the number of days of moving average, C is the closing price of the day, and PEMA and PDEA are the EMA and DEA of the previous day.


### 3.2. Dimensionality Reduction of Data Using Principal Component Analysis

The principal component analysis is a method of transforming multiple interrelated raw data into a small number of linear combinations of two uncorrelated variables without changing the structure of the sample data by rotating the spatial coordinates. This reduces dimensionality and simplifies complex multidimensional problems by replacing more variables with fewer variables while maximizing the information in the original data.To extract the principal components, the original data is first standardized, i.e., the mean of the corresponding variable is subtracted and then divided by the variance to eliminate the effect of differences in magnitudes.(3)Yij∗=xij−x¯jSj,i=1,2,⋯,m;j=1,2,⋯,n.The correlation coefficient matrixR is then calculated and the eigenvalues (i = 1, 2,...,n) are obtained by solving the characteristic equation λE-R = 0.The eigenvalue is the variance of each principal component. It is used to describe the amount of information contained in the direction of the corresponding eigenvector, i.e., the magnitude of the eigenvalue directly reflects the influence of each principal component. The value of an eigenvalue divided by the sum of all eigenvalues gives the variance contribution of the eigenvector.λi/∑k=1nλk is the contribution of the i-th principal component. ∑k=1lλk/∑k=1nλk is the cumulative contribution of the first i principal components. According to the rules for the selection of the number of principal components, the selected principal components must all have eigenvalues greater than 1 and a cumulative contribution of at least a high percentage (usually greater than 85%). It is guaranteed that the selected principal components contain most of the information of the original data.Finally, the principal component loadings are calculated and the principal component scores are obtained as new training data.(4)Tij=pzi,xj=λiaij,i=1,2,⋯,m;j=1,2,⋯,n.


### 3.3. Prediction Using LSTM Models

The full form of LSTM is long term short term memory artificial neural network, a temporal recurrent neural network suitable for processing and predicting important events with relatively long intervals and delays in a time series [20]. It is a variant of the recurrent neural network, and the LSTM has an additional cellular structure in the algorithm that determines whether the information is useful or not than the recurrent neural network, as shown in Figure 1.Figure 1
LSTM cell structure.The LSTM has 3 gates in a cell: the forgetting gate, the input gate, and the output gate. Once a piece of data enters the LSTM’s network, it is judged to be useful according to the rules, and those that match the algorithm’s rules are left behind, while those that do not are forgotten through the forgetting gate. Only information that meets the algorithm’s certification is left behind, while information that does not meet the rules is forgotten through the forgetting gate.(5)ft=σWf·ht−1,xt+bf.The input gate then updates the cell state, first determining the value to be updated through the sigmoid layer, and the vector of candidate values created by the tanh layer, which are multiplied together to obtain the new candidate values.(6)it=σWi.ht−1,xt+bi,Ct=tanhWC.ht−1,xt+bC.The old cell state is then multiplied by the discard information defined by the oblivion gate and the new candidate value is added to obtain the updated cell.(7)Ct=ft×Ct−1+it×Ct.Finally, based on the current cell state, the output component is determined by the sigmoid layer, which is multiplied by the tanh-processed cell state to obtain the value of the determined output(8)ot=σWoht−1,xt+bo,ht=ot×tanhCt.In LSTM models, the model can choose what to keep and what to forget so that the model can analyze the data that is most relevant to the task. LSTM models can also learn a more abstract representation of the data so that the model learns more features of the data. These features allow LSTM models to be more effective in analyzing industry asset trends when applied to industry assets [21].


## 3.1. Obtaining Training Data

The nine basic data items of the selected sector assets were obtained through the sector asset data stations of the major financial websites and the TuShare financial data interface package for Python: opening price, closing price, high price, low price, previous closing price, up/down amount, up/down range, volume, and turnover amount. These are shown in Table1. The KDJ and MACD indicators calculated for the underlying data are used together as training data for the model.Table 1
Industry asset base data.
Ts codeTrade dateOpenHighLowClosePre closeChange0000001.SZ2019031412.3312.6212.5512.6410.20.050.1841000001.SZ2019031312.3412.5512.1212.370.010.08262000001.SZ2019031212.4912.6412.2412.3612.320.043999000001.SZ2002012110.199.579.610.18−0.59−5.78The KDJ indicator is a sensitive and fast technical analysis indicator that uses the real volatility of the price fluctuations of sector assets to reflect the strength of the price change trend and can signal a buy or sell before the sector assets have risen or fallen. The highest and lowest prices that have occurred in a period, the last closing price of the period, and the proportional relationship between these three are used to calculate the unripe stochastic value of RSV on the last day of the period, and then theK, D, and J values are calculated based on the sliding average method [19].The K value is the n-day moving average of the RSV and the K line, which is also known as the fast line, changes at a moderate rate among the 3 curves; theD value is the n-day moving average of the K value and the D line changes at the slowest rate among the 3 lines and is known as the slow line; the J value changes the fastest and is known as the ultra-fast or confirmation line as an aid to observing the buying and selling signals from the K and D lines. The three lines on the same coordinate make up the KDJ indicator, which reflects the trend of price fluctuations.(1)RSV=Cn−Ln/Hn−Ln×100,K=23Kp+13RSV,D=23Dp+13K,J=3×K−2×D,where Cn is the closing price on day n, Ln is the lowest price on day n, Hn is the highest price on day n, and Kp、and Dp is the previous day’s K and D values, both replaced by 50 if not available.MACD is also known as the moving average of divergence. The convergence and divergence of the fast and slow averages represent changes in market trends and are a common technical indicator for sector assets. The fast and slow-moving averages, EMA, are generally chosen as the 12-day and 26-day moving averages, and their divergence, DIF, and the divergence’s 9-day moving average, DEA, are calculated to give the MACD.(2)EMAn=n−1n+1×PEMAn+2n+1,DIF=EMA12−EMA26,DEA=n−1n+1×PDEAn+DIF,MACD=DIF−DEA×2,where n is the number of days of moving average, C is the closing price of the day, and PEMA and PDEA are the EMA and DEA of the previous day.


## 3.2. Dimensionality Reduction of Data Using Principal Component Analysis

The principal component analysis is a method of transforming multiple interrelated raw data into a small number of linear combinations of two uncorrelated variables without changing the structure of the sample data by rotating the spatial coordinates. This reduces dimensionality and simplifies complex multidimensional problems by replacing more variables with fewer variables while maximizing the information in the original data.To extract the principal components, the original data is first standardized, i.e., the mean of the corresponding variable is subtracted and then divided by the variance to eliminate the effect of differences in magnitudes.(3)Yij∗=xij−x¯jSj,i=1,2,⋯,m;j=1,2,⋯,n.The correlation coefficient matrixR is then calculated and the eigenvalues (i = 1, 2,...,n) are obtained by solving the characteristic equation λE-R = 0.The eigenvalue is the variance of each principal component. It is used to describe the amount of information contained in the direction of the corresponding eigenvector, i.e., the magnitude of the eigenvalue directly reflects the influence of each principal component. The value of an eigenvalue divided by the sum of all eigenvalues gives the variance contribution of the eigenvector.λi/∑k=1nλk is the contribution of the i-th principal component. ∑k=1lλk/∑k=1nλk is the cumulative contribution of the first i principal components. According to the rules for the selection of the number of principal components, the selected principal components must all have eigenvalues greater than 1 and a cumulative contribution of at least a high percentage (usually greater than 85%). It is guaranteed that the selected principal components contain most of the information of the original data.Finally, the principal component loadings are calculated and the principal component scores are obtained as new training data.(4)Tij=pzi,xj=λiaij,i=1,2,⋯,m;j=1,2,⋯,n.


## 3.3. Prediction Using LSTM Models

The full form of LSTM is long term short term memory artificial neural network, a temporal recurrent neural network suitable for processing and predicting important events with relatively long intervals and delays in a time series [20]. It is a variant of the recurrent neural network, and the LSTM has an additional cellular structure in the algorithm that determines whether the information is useful or not than the recurrent neural network, as shown in Figure 1.Figure 1
LSTM cell structure.The LSTM has 3 gates in a cell: the forgetting gate, the input gate, and the output gate. Once a piece of data enters the LSTM’s network, it is judged to be useful according to the rules, and those that match the algorithm’s rules are left behind, while those that do not are forgotten through the forgetting gate. Only information that meets the algorithm’s certification is left behind, while information that does not meet the rules is forgotten through the forgetting gate.(5)ft=σWf·ht−1,xt+bf.The input gate then updates the cell state, first determining the value to be updated through the sigmoid layer, and the vector of candidate values created by the tanh layer, which are multiplied together to obtain the new candidate values.(6)it=σWi.ht−1,xt+bi,Ct=tanhWC.ht−1,xt+bC.The old cell state is then multiplied by the discard information defined by the oblivion gate and the new candidate value is added to obtain the updated cell.(7)Ct=ft×Ct−1+it×Ct.Finally, based on the current cell state, the output component is determined by the sigmoid layer, which is multiplied by the tanh-processed cell state to obtain the value of the determined output(8)ot=σWoht−1,xt+bo,ht=ot×tanhCt.In LSTM models, the model can choose what to keep and what to forget so that the model can analyze the data that is most relevant to the task. LSTM models can also learn a more abstract representation of the data so that the model learns more features of the data. These features allow LSTM models to be more effective in analyzing industry asset trends when applied to industry assets [21].


## 4. Analysis of Results

Based on the previous analysis, we use the CITIC style index and its constituent stocks as the research object when conducting the construction of the prediction models, and this section mainly presents the results based on the financial subindices. This section constructs LSTM models based on the four forecasting scenarios mentioned above, namely, the LSTM model based on textual investor sentiment index and historical data, the LSTM model based on proxy sentiment index and historical data, the LSTM model based on composite investor sentiment index and historical data, and the LSTM model based on K-line data. Figure2 shows the prediction results of scenario 3 on the training set compared with the real results. By tuning and optimizing the model, it can be seen that the predicted and actual values basically have the same trend, although there are certain deviations from each other, but they can capture the up and down trends well, indicating that the prediction results are more satisfactory and provide a strong reference for investors’ buying and selling behavior [22]. Figure 3 shows the comparison between the predicted and actual values of scenario 3 on the test set.Figure 2
Predicted and actual values for the training set of the integrated sentiment model.Figure 3
Predicted and actual values for the test set of the integrated sentiment model.Figures4–6 show the predicted versus true results for scenarios 1, 2, and 4 on the training and test sets, respectively.Figure 4
Predicted and actual values for the training set of the text sentiment prediction model.Figure 5
Predicted and actual values for the test set of the text sentiment prediction model.Figure 6
Predicted and actual values for the training set of the proxy sentiment prediction model can be seen from Figures4–6. Scenario 3, which incorporates a composite index of investor sentiment and historical data on industry assets, has the best predictions, with the smallest difference between the true and predicted values on both the test and training sets.Table2 shows the performance of each evaluation indicator for each scenario based on the LSTM model. Comparing the scenarios, it can be seen that the LSTM industry asset forecasting model incorporating a composite index of investor sentiment has the best forecasting performance, the LSTM industry asset forecasting model based on a sentiment proxy index has the second-best forecasting performance, and the K-line forecasting model based on historical industry asset data only has the worst forecasting performance.Table 2
LSTM model evaluation metrics based on each scenario.
Prediction schemeScheme IScheme 2Scheme 3Scheme 4Training setTest setTraining setTest setTraining setTest setTraining setTest setMAE0.0450.0570.0410.0510.0290.0390.0950.112MSE0.00340.00410.00260.00320.000120.00010.0150.0121RMSE0.05910.06480.0530.05580.1170.01420.1150.1104MAPE0.520.420.410.480.260.390.40.5Accuracy0.720.730.820.750.890.810.610.59


## 5. Conclusions

In this paper, when using technical methods to build LSTM stock forecasting models, traditional methods often result in poor generalization and poor forecasting due to a large number of input data variables selected, overlapping data information, and the large impact of outliers on training. To address such problems, we propose to use principal component analysis to reduce the dimensionality of the underlying data, then combine the KDJ and MACD as input data together with stock-related technical indicators and adjust the model according to the characteristics of the stock before making predictions. The experimental results show that the PCA-S-LSTM model can reduce the average error of prediction, reduce the running time, improve the stability of prediction, and predict the closing price of Ping An Bank more accurately.



---

*Source: 1113023-2022-03-21.xml*