# Application of Neural Networks in Financial Time Series Forecasting Models

Authors: Xinhui Li
Journal: Journal of Function Spaces
 (2022)

---

## Abstract

At present, the economic development of the world’s major economies is showing a positive and positive state. Driven by the development of related industries, the development of the financial field is also changing with each passing day. Various activities in the financial industry are in full swing, and the forecasts of related prospects are also full of uncertainties. Summarizing the laws of financial activities through technical means and making accurate predictions of future trends and trends is a hot research direction that relevant researchers pay attention to. Accurate financial forecasts can provide reference for financial activities and decision-making to a certain extent, promote the steady development of the market, and improve the conversion rate of financial profits. As an algorithm model that can simulate the biological visual system, the convolutional neural network can predict the numerical trend of the next period of time based on known data. Therefore, this paper integrates the support vector machine with the established model by establishing a convolutional neural network model and applies the prediction model to the prediction of financial time series data. The experimental results show that the model proposed in this paper can more accurately predict the trend of the stock index.


---

## Body

## 1. Introduction

With the development of the economic market, the financial system is becoming more and more mature. At present, the financial market occupies an important position in the national economic system, and the development of the national economy can also be reflected by the performance of the financial market. Because the financial market has unlimited business opportunities, it attracts many investors. Investors can analyze the movement trend of the financial market based on the historical information they have and then formulate investment plans based on the results of the analysis to obtain higher returns. The validity of historical financial data and whether the acquired historical data can be accurately analyzed determine the effectiveness of investment strategies. Therefore, obtaining effective financial data and analyzing and mining the data to obtain effective information to predict the movement trend of the financial market is a research hotspot in the academic and financial circles.An important basis for formulating investment strategies is the analysis of historical financial data and the prediction of future data based on the analysis results. The nonlinearity, instability, high noise, and other characteristics of financial data are the important reasons why it is difficult to predict accurately [1]. Financial time series involves many fields, such as stock market, price index, and national income and output. Designing an appropriate financial time series forecasting model requires mining the hidden relationship between the overall economy and fiscal markets [2], but this task is extremely difficult. Most of the reasons why financial time series are difficult to predict are caused by different economic systems and business cycles, which usually show irregular changes and fluctuations, so it is difficult to predict irregular changes and fluctuations. The stock market plays an important role in the development of Japan’s national economy, maintaining a healthy and stable economy from the perspectives of financing, fair pricing of securities, optimization of resource allocation, and macroeconomic management. It plays an important role above [2]. Stock market prices are changing rapidly, and equity investment has the characteristics of high risk and high return.On the premise of ensuring the safety of the principal, they can obtain higher than bank interest. Income is the main purpose of its securities investment. Therefore, people urgently need to analyze the stock data to find the changing laws, so as to guide them to make correct and effective investments and obtain the maximum net investment benefits. To improve the excess returns of equity investors, many researchers have analyzed financial time-series data and found legislative changes that pose serious challenges to securities market analysis techniques [3]. More and more researchers are getting involved in stock market analysis techniques. Financial time series faces many challenges in forecasting due to the large amount of data, nonlinearity, nonlinearity, high dimension, macro-environmental influence, high feature correlation, and high noise.In recent years, due to the continuous in-depth research on artificial intelligence by scholars from all over the world, related algorithms and solutions have been continuously applied in the related fields of financial time series [4]. The establishment of complex system forecasting models can effectively process data information, which provides a new direction for forecasting financial time series. At the same time, the neural network can effectively reduce the misjudgment of stock market investment caused by human factors such as personal mood fluctuations [5, 6]. Therefore, neural networks are well suited for financial time series stock forecast modeling, and the technique can be used to predict stock trends over time.The forecasting technology of financial time series involves many disciplines, so it is a relatively complex system engineering. On the one hand, there are few algorithm models for the general identification and analysis of financial time series, which can well handle the dynamic changing stock market in a complex environment; on the other hand, the existing technology still cannot handle financial time series stocks well. Big data volume information in the market. In addition, my country’s stock market is not mature enough compared with developed countries, and market forecasting technology is still in the market cultivation stage and has not been widely used in actual economic life [7]. Therefore, the research on the modeling and forecasting of financial time series is of great importance significance.In this paper, the convolution neural network model is established, the support vector machine is combined with the established model, and the prediction model is applied to the prediction of financial time series data. The proposed two prediction models are still the best for Nasdaq stock index, and BP neural network prediction model is better than support vector machine prediction model. It can be seen from the correlation coefficient table that cnn-svm hybrid prediction model has the best prediction effect on the next trend of all five stock indexes. CNN prediction model is a mixed prediction model to predict the next trend. The innovative contribution of this paper lies in the feasibility of the two models in stock index prediction. The hybrid prediction model of convolutional neural network and support vector machine provides the best prediction effect. Only convolution neural network has better prediction effect than traditional BP neural network and support vector machine.This paper is organized as follows. The first chapter introduces the socioeconomic background of the study of financial forecasting problems and analyzes the motivation of this paper. The second chapter introduces the research status of related fields at home and abroad and summarizes the research significance of this paper. The third chapter shows how to build a stock index prediction model based on convolutional neural network, explains the influence of various parameters of convolutional neural network on the prediction result, and determines the appropriate convolutional parameters. The fourth chapter tests and analyzes the proposed scheme and compares it with other methods to verify the effectiveness of the scheme. Chapter 5 summarizes the research content of this paper and looks forward to future research directions.


## 2. The Related Works

A variety of methods have been applied to financial forecasting, and the commonly used methods can be broadly classified into qualitative forecasting methods, quantitative forecasting methods, and data mining-based forecasting methods. The following is a brief introduction of these three aspects of forecasting methods and focuses on the current status of research on financial forecasting based on data mining.Qualitative forecasting method is a more intuitive and subjective financial forecasting method, which is mainly based on the past and present information of the forecast object as well as personal experience and judgment ability by the experts concerned to make advance judgment and speculation on the future development trend and pattern of financial activities. Quantitative forecasting method is a kind of forecasting method based on statistical theory [8].Data mining techniques are now widely used in the field of financial forecasting such as stock and futures [9]. Lu et al. [10] established an AR model for the Frankfurt stock market to predict and analyze the stock price, and the prediction results were more accurate. The moving average method is simple and fast, but the prediction accuracy is not high. Salehi et al. [11] predict the future price of the stock market based on historical data and uses the number of different poles and zeros of the ARMA model to predict the stock price of the next day. By comparing with the ARMA model, Luo et al. [12] found that the minimum mean square error was combined with the fractional integral autoregressive moving average model. The combined method is more accurate in predicting the stock price. Exponential smoothing is low cost, simple, and practical, and its prediction accuracy is high, even comparable to many more sophisticated and more statistically based methods. If the time series has obvious seasonal periodicity, its statistical characteristics also show regular seasonal changes. At this time, the seasonal coefficient method can be used for prediction, thereby improving the accuracy of the prediction results. Shahvaroughi et al. used BPNN for stock price prediction, and the experimental results showed that BPNN had a smaller prediction error than the comparison experiments in the paper [13]. Kumar and Yadav [14] use the Shanghai Composite Index to calculate the volatility trend of stock prices. Since the changes in asset prices on trading days are not considered, especially on trading days with large changes in asset prices, the estimated value of the volatile GARCH model will be lower than the actual volatility. Syriopoulos et al. [15] proposed a fuzzy GARCH modeling method to predict stock market returns, which considers time-varying fluctuations and adjusts the adaptability of the model through gradual model construction. Cheng et al. used support vector machine to forecast the Korea Composite Stock Price Index (KOSPI) and showed better prediction performance than BP neural network and case-based inference methods [16]. Xiangfei Li et al. combined both support vector machine and empirical mode decomposition (EMD) methods to predict the error sequence of the initial forecast set and correct the original forecast value using the error forecast value. Experiments show that this method is better than the prediction by support vector machines alone [17]. Kumar et al. constructed a wavelet support vector machine to predict the volatility of two simulated stocks by replacing the Gaussian kernel function of the support vector machine with a wavelet kernel function, which showed better prediction performance than the Gaussian kernel [18]. Support vector machines have a great advantage in solving high-dimensional nonlinear data problems with robustness and generalization capabilities.From the above research status at home and abroad, it can be concluded that domestic and foreign scholars mainly use LSTM neural network to predict stock closing price and return rate and obtain a high accuracy rate in short-term prediction accuracy, which is better than traditional time series prediction methods. Due to the many and changeable factors affecting the stock market, domestic and foreign scholars mainly focus on the comparison of model effects between different models and mainly improve the training and prediction accuracy of LSTM neural network from three aspects. These include the improvement of the LSTM neural network structure or the combination of different models, the innovation of dataset input, the improvement of the prediction accuracy of the improved model compared with the basic network prediction accuracy, and the solution of model overfitting [19]. In addition, the sequence dependence characteristics of financial time series data are an indispensable part of financial time series data forecasting. Although ARMA, GARCH, and other models can consider the sequence dependence characteristics of financial time series data, the determination of the sequence correlation length may be complicated. Or it is difficult to achieve automatic identification of sequence-dependent lengths based on the research problem [20]. Therefore, traditional econometric models have certain limitations for forecasting financial time series data with complex characteristics.


## 3. Convolutional Neural Network Based Stock Index Prediction Model

### 3.1. Convolutional Neural Networks and Support Vector Machines

Due to the huge and diverse characteristics of financial markets, financial time series usually do not have stable statistical characteristics and are highly nonlinear. Financial time series is a kind of time series data, which has strong timeliness and strong dependence on the front and back of the data. It is impossible to adjust the order. They are generally two-dimensional data. Because time series have strong sequence lines, and there are generally dependencies, cycles, and other relationships before and after the data, it is possible to predict future data based on existing data through statistical knowledge. The high intensity of price volatility in financial markets results in nonstationary financial time series. Therefore, the salient features of financial time series are nonlinear and unstable characteristics. This also means that using linear forecasting models can only extract linear relationships in financial time series, but not nonlinear relationships. Therefore, complex nonlinear relational data can only be extracted and analyzed through machine learning models, deep learning models, or nonlinear data models. Combining the advantages of convolutional neural network and support vector machine, this paper innovatively proposes a new solution. The structure of the financial time series forecasting model designed according to the convolutional neural network in this paper is shown in Figure1.Figure 1
convolutional neural network for handwritten character recognition task.The training process of the algorithm model in the scheme proposed in this paper can be divided into the following two main steps:(1)
Forward propagation process. A sample is randomly selected from the training sample setX,YP, where X is the network input and YP is the desired network output. The information of the input X is propagated from the input layer to the output layer through layers of computation, and the actual output of the input X is calculated according to the following equation:(1)OP=Fn⋯F2F1XW1W2⋯Wn.(2)
Backward propagation process. This process is used to perform error back propagation. That is, it calculates the difference between the actual outputOP and the desired output YP:(2)EP=12∑jypj−opj2.SVMs have unique advantages in handling function approximation problems, performing complex tasks such as solving other pattern recognition problems such as function approximation. SVMs use structural risk minimization as a criterion, which allows training the resulting classifier to obtain a globally optimal solution.Figure2 depicts the basic principle of SVM. The two samples in the figure are represented by black circles and white circles, and the curve H represents the optimal classification hyperplane between the two samples. The curves 1H and 2H pass through the sample with the smallest distance to the optimal classification hyperplane in their respective classes. The distance between 1H and 2H is called the classification interval.Figure 2
Schematic diagram of the optimal classification surface.The optimal classification hyperplane is the one that not only classifies the samples of both categories correctly, but also maximizes the classification interval. The classification error rate that can be trained by correctly classifying samples of both categories is 0, i.e., the empirical risk is minimized.Letxi,yi,i=1,⋯,n,x∈Rd,y∈+1,−1 denote the linearly separable sample set, where +1 and − 1 denote the category symbols. The linear discriminant function is denoted by gx=w⋅x+b, and the classification surface equation is denoted by w⋅x+b=0. In order to make all samples in both categories satisfy gx=1, that is, to make the nearest sample to the classification hyperplane of gx=1, it is necessary to normalize the discriminant function. At this point, the normalized classification interval is transformed into 2/w, and the optimization goal of maximizing the interval is transformed into minimizing w (or w2). In order for the classification surface to correctly classify all samples, the classification surface must meet the following conditions:
(3)yiw⋅x+b−1≥0,i=1,2,⋯,n.The classification plane that satisfies Equation (3) and minimizes the value of the optimization target w2 is called the optimal classification hyperplane. The optimal classification hyperplane is determined based on the sample points on H1 and H2 parallel to the optimal classification hyperplane, so these sample points are the support vectors in the support vector machine.The above optimal classification hyperplane solution problem can be transformed into an easily solvable dual problem by introducing Lagrange optimization methods, i.e., under the constraints:(4)∑i=1nyiαi=0αi≥0,i=1,2,⋯,n.Find the maximum value of the following function forαi:
(5)Qα=∑i=1nαi−12∑i,j=1nαiαjyiyjxixj.Letα+ be the optimal solution, then we have
(6)w∗=∑i=1nα∗yαi.It can be seen from Equation (6) that there is an equal relationship between the connected weight vector of the optimal classification hyperplane and the weighted sum of the training sample vectors. The core of the algorithm is to determine the optimal classification hyperplane, that is, to determine the parameters of the classifier function through training samples. To determine the classification hyperplane is essentially to solve a quadratic optimization problem, and the parameters of the classifier are determined by solving the dual problem.This is a quadratic optimization problem under the inequality constraint, and the optimal solution is unique, and only some values of the optimal solution are non-zero, and the sample points corresponding to these non-zero connection weights are the support vectors. The optimal classification decision function obtained according to the above solution process can be expressed by the following equation:(7)fx=sgnw∗⋅x+b∗=sgn∑i=1nαi∗yixi⋅x+b∗.There are two ways to solveb∗, one is by substituting any support vector into Equation (3); the other is by averaging any pair of support vectors in the two types of samples. Since the corresponding connection weights of the sample points that are not support vectors αi are zero, the summation process in Equation (7) is actually only for the support vectors, and there is no need to calculate the sample points of nonsupport vectors.For the case of linear indistinguishability of training samples, some sample points do not meet the conditions of Equation (3), and then a relaxation variable εi≥0 can be added to Condition (3) so that Equation (2) becomes
(8)yiw⋅xi+b−1+εi≥0,i=1,2,⋯,n.Obviously the relaxation variableεi cannot be arbitrarily large; otherwise, any hyperplane would be eligible. Let
(9)Fε=∑i=1nεi.When the value of Equation (9) is the smallest, it means that the number of misclassified samples is the smallest and the classification interval is the largest for the linearly divisible case; for the linearly indivisible case, the following constraints need to be introduced:
(10)w2≤ck.Under the constraints of Conditions (8) and (10), the optimal classification hyperplane for linearly indistinguishable training samples is obtained by finding the minimum value of Equation (9).The original solved problem can be transformed into a new problem of finding the minimum value of the following function, the constraint of which is Equation (8).
(11)ϕw,ε=12w,w+C∑i=1nεi,whereC is the penalty factor, which is a specified constant. Its purpose is to control the penalty level of misclassified samples so that the training model can balance between the proportion of misclassified samples and the complexity of the algorithm and prevent the complexity of the model from increasing.Similar to the solution of the optimal classification hyperplane, this optimization problem is transformed into a quadratic extreme value problem to be solved, and the results are close to Equations (4) to (8) obtained in the linearly separable case, but Condition (5) becomes
(12)0≤αi≤C,i=1,⋯,n.


### 3.2. Convolutional Neural Network-Based Stock Index Prediction Model

Define the input sample length asl, the convolution kernel size as c, and the downsampling reduction as s. The relationship that the above three parameters should satisfy is as follows when the number of convolution layers and the number of downsampling layers is determined to be 2:
(13)l−c+1/s−c+1/s=N.When the number of convolution and downsampling layers in the model is 1, the above three parameters should satisfy the following relationship:(14)l−c+1/s=N.Figure3 shows the range of convolution kernel sizes for different input sample lengths when the network structure contains two layers of convolution.Figure 3
Relationship between input sample length and convolution kernel size.In the scheme designed in this paper, the output unit of the last layer is actually a probability estimate of the input sample. For the above convolutional neural network, it is not meaningful to focus on the output of the hidden layer, but for other classifiers, the output of the hidden layer can be used as features for prediction or classification. The main connotation of the model in the proposed scheme can be summarized by feature extraction and classification. The mapping and extraction of features at different levels is achieved by convolution and downsampling, and the classification (prediction) function is achieved by a single-layer perceptron. Feature engineering has always been a difficulty in machine learning. The main reason is that different data and different problems have different good features. Good features are often not suitable for signal processing. Even the two tasks are also image recognition tasks, because the data contained are different and the corresponding good features are also different.The scheme proposed in this paper can extract the features of the samples accurately and effectively. However, classification or prediction by single layer perceptron using the extracted features is prone to overfitting and falling into local optimum. The perceptron is a generalized linear model. The decision boundary of single-layer neural network is linear whether there is activation function or not. Because the single-layer neural network is linear, even the simple nonlinear XOR function cannot be learned correctly. The simplest idea is to manually add some nonlinear features of other dimensions to improve the nonlinear expression ability of the model. This also reflects the importance of feature engineering to the model. The support vector machine shows good performance in classification and prediction, and it avoids the overfitting problem by introducing relaxation variables. The optimization problem of the support vector machine can be treated as a convex quadratic optimization problem, and the optimal solution obtained is the global optimum. Therefore, this paper combines the advantages of both models and proposes a model that combines the advantages of convolutional neural networks and support vector machines (CNN-SVM).


## 3.1. Convolutional Neural Networks and Support Vector Machines

Due to the huge and diverse characteristics of financial markets, financial time series usually do not have stable statistical characteristics and are highly nonlinear. Financial time series is a kind of time series data, which has strong timeliness and strong dependence on the front and back of the data. It is impossible to adjust the order. They are generally two-dimensional data. Because time series have strong sequence lines, and there are generally dependencies, cycles, and other relationships before and after the data, it is possible to predict future data based on existing data through statistical knowledge. The high intensity of price volatility in financial markets results in nonstationary financial time series. Therefore, the salient features of financial time series are nonlinear and unstable characteristics. This also means that using linear forecasting models can only extract linear relationships in financial time series, but not nonlinear relationships. Therefore, complex nonlinear relational data can only be extracted and analyzed through machine learning models, deep learning models, or nonlinear data models. Combining the advantages of convolutional neural network and support vector machine, this paper innovatively proposes a new solution. The structure of the financial time series forecasting model designed according to the convolutional neural network in this paper is shown in Figure1.Figure 1
convolutional neural network for handwritten character recognition task.The training process of the algorithm model in the scheme proposed in this paper can be divided into the following two main steps:(1)
Forward propagation process. A sample is randomly selected from the training sample setX,YP, where X is the network input and YP is the desired network output. The information of the input X is propagated from the input layer to the output layer through layers of computation, and the actual output of the input X is calculated according to the following equation:(1)OP=Fn⋯F2F1XW1W2⋯Wn.(2)
Backward propagation process. This process is used to perform error back propagation. That is, it calculates the difference between the actual outputOP and the desired output YP:(2)EP=12∑jypj−opj2.SVMs have unique advantages in handling function approximation problems, performing complex tasks such as solving other pattern recognition problems such as function approximation. SVMs use structural risk minimization as a criterion, which allows training the resulting classifier to obtain a globally optimal solution.Figure2 depicts the basic principle of SVM. The two samples in the figure are represented by black circles and white circles, and the curve H represents the optimal classification hyperplane between the two samples. The curves 1H and 2H pass through the sample with the smallest distance to the optimal classification hyperplane in their respective classes. The distance between 1H and 2H is called the classification interval.Figure 2
Schematic diagram of the optimal classification surface.The optimal classification hyperplane is the one that not only classifies the samples of both categories correctly, but also maximizes the classification interval. The classification error rate that can be trained by correctly classifying samples of both categories is 0, i.e., the empirical risk is minimized.Letxi,yi,i=1,⋯,n,x∈Rd,y∈+1,−1 denote the linearly separable sample set, where +1 and − 1 denote the category symbols. The linear discriminant function is denoted by gx=w⋅x+b, and the classification surface equation is denoted by w⋅x+b=0. In order to make all samples in both categories satisfy gx=1, that is, to make the nearest sample to the classification hyperplane of gx=1, it is necessary to normalize the discriminant function. At this point, the normalized classification interval is transformed into 2/w, and the optimization goal of maximizing the interval is transformed into minimizing w (or w2). In order for the classification surface to correctly classify all samples, the classification surface must meet the following conditions:
(3)yiw⋅x+b−1≥0,i=1,2,⋯,n.The classification plane that satisfies Equation (3) and minimizes the value of the optimization target w2 is called the optimal classification hyperplane. The optimal classification hyperplane is determined based on the sample points on H1 and H2 parallel to the optimal classification hyperplane, so these sample points are the support vectors in the support vector machine.The above optimal classification hyperplane solution problem can be transformed into an easily solvable dual problem by introducing Lagrange optimization methods, i.e., under the constraints:(4)∑i=1nyiαi=0αi≥0,i=1,2,⋯,n.Find the maximum value of the following function forαi:
(5)Qα=∑i=1nαi−12∑i,j=1nαiαjyiyjxixj.Letα+ be the optimal solution, then we have
(6)w∗=∑i=1nα∗yαi.It can be seen from Equation (6) that there is an equal relationship between the connected weight vector of the optimal classification hyperplane and the weighted sum of the training sample vectors. The core of the algorithm is to determine the optimal classification hyperplane, that is, to determine the parameters of the classifier function through training samples. To determine the classification hyperplane is essentially to solve a quadratic optimization problem, and the parameters of the classifier are determined by solving the dual problem.This is a quadratic optimization problem under the inequality constraint, and the optimal solution is unique, and only some values of the optimal solution are non-zero, and the sample points corresponding to these non-zero connection weights are the support vectors. The optimal classification decision function obtained according to the above solution process can be expressed by the following equation:(7)fx=sgnw∗⋅x+b∗=sgn∑i=1nαi∗yixi⋅x+b∗.There are two ways to solveb∗, one is by substituting any support vector into Equation (3); the other is by averaging any pair of support vectors in the two types of samples. Since the corresponding connection weights of the sample points that are not support vectors αi are zero, the summation process in Equation (7) is actually only for the support vectors, and there is no need to calculate the sample points of nonsupport vectors.For the case of linear indistinguishability of training samples, some sample points do not meet the conditions of Equation (3), and then a relaxation variable εi≥0 can be added to Condition (3) so that Equation (2) becomes
(8)yiw⋅xi+b−1+εi≥0,i=1,2,⋯,n.Obviously the relaxation variableεi cannot be arbitrarily large; otherwise, any hyperplane would be eligible. Let
(9)Fε=∑i=1nεi.When the value of Equation (9) is the smallest, it means that the number of misclassified samples is the smallest and the classification interval is the largest for the linearly divisible case; for the linearly indivisible case, the following constraints need to be introduced:
(10)w2≤ck.Under the constraints of Conditions (8) and (10), the optimal classification hyperplane for linearly indistinguishable training samples is obtained by finding the minimum value of Equation (9).The original solved problem can be transformed into a new problem of finding the minimum value of the following function, the constraint of which is Equation (8).
(11)ϕw,ε=12w,w+C∑i=1nεi,whereC is the penalty factor, which is a specified constant. Its purpose is to control the penalty level of misclassified samples so that the training model can balance between the proportion of misclassified samples and the complexity of the algorithm and prevent the complexity of the model from increasing.Similar to the solution of the optimal classification hyperplane, this optimization problem is transformed into a quadratic extreme value problem to be solved, and the results are close to Equations (4) to (8) obtained in the linearly separable case, but Condition (5) becomes
(12)0≤αi≤C,i=1,⋯,n.


## 3.2. Convolutional Neural Network-Based Stock Index Prediction Model

Define the input sample length asl, the convolution kernel size as c, and the downsampling reduction as s. The relationship that the above three parameters should satisfy is as follows when the number of convolution layers and the number of downsampling layers is determined to be 2:
(13)l−c+1/s−c+1/s=N.When the number of convolution and downsampling layers in the model is 1, the above three parameters should satisfy the following relationship:(14)l−c+1/s=N.Figure3 shows the range of convolution kernel sizes for different input sample lengths when the network structure contains two layers of convolution.Figure 3
Relationship between input sample length and convolution kernel size.In the scheme designed in this paper, the output unit of the last layer is actually a probability estimate of the input sample. For the above convolutional neural network, it is not meaningful to focus on the output of the hidden layer, but for other classifiers, the output of the hidden layer can be used as features for prediction or classification. The main connotation of the model in the proposed scheme can be summarized by feature extraction and classification. The mapping and extraction of features at different levels is achieved by convolution and downsampling, and the classification (prediction) function is achieved by a single-layer perceptron. Feature engineering has always been a difficulty in machine learning. The main reason is that different data and different problems have different good features. Good features are often not suitable for signal processing. Even the two tasks are also image recognition tasks, because the data contained are different and the corresponding good features are also different.The scheme proposed in this paper can extract the features of the samples accurately and effectively. However, classification or prediction by single layer perceptron using the extracted features is prone to overfitting and falling into local optimum. The perceptron is a generalized linear model. The decision boundary of single-layer neural network is linear whether there is activation function or not. Because the single-layer neural network is linear, even the simple nonlinear XOR function cannot be learned correctly. The simplest idea is to manually add some nonlinear features of other dimensions to improve the nonlinear expression ability of the model. This also reflects the importance of feature engineering to the model. The support vector machine shows good performance in classification and prediction, and it avoids the overfitting problem by introducing relaxation variables. The optimization problem of the support vector machine can be treated as a convex quadratic optimization problem, and the optimal solution obtained is the global optimum. Therefore, this paper combines the advantages of both models and proposes a model that combines the advantages of convolutional neural networks and support vector machines (CNN-SVM).


## 4. Analysis of Simulation Results

In this section, we will study the impact of convolutional neural network related parameters on stock index forecasting results to determine suitable parameters and stock forecasting models. The prediction results use two indicators to judge the quality of the prediction results: the mean square error (MSE) and the correlation coefficient between the predicted financial time series and the actual output series according to the proposed scheme. Time series analysis is a basic technology in quantitative investment. Time series refers to the value sequence of a variable measured in time sequence within a certain period of time. For example, if the variable is the stock price, its change with time is a time series. Similarly, if the variable is the return of stocks, its change with time is also a time series. While discussing the impact of specific parameters on the stock index forecast results, the values of other parameters are fixed.The formula for filtering noise is as follows:(15)mhx=∑t=1TKhx−XtYt∑t=1TKhx−Xt,Khx=1h2πe−x2/2h2.The normalization formula is(16)yt′=yt−minYtmaxYt−minYt.In the simulation experiments in this paper, the cases where the number of convolutional layers and downsampling layers are 1 and 2 are discussed in detail, respectively. According to the length of different input samples, corresponding simulations are also carried out in this paper. For the case where the length of the input samples is divided into 30 and 40, this paper sets 3 and 5 as the corresponding values of the convolution kernel. As can be seen from Figures4 and 5, it is reasonable to set the number of convolutional layers and downsampling layers in the prediction model proposed in this paper to 2. For stock indices, the features extracted by two convolutional layers are more effective. So all stock prediction models in this paper use two convolutional layers and one downsampling layer.Figure 4
The prediction result when the input sample length is 30, and the convolution kernel size is 3.Figure 5
The prediction result when the input sample length is 40, and the convolution kernel size is 5.Considering the limitation of the input sample length on the size of the convolution kernel, 70 is used as the length of the input sample in this experiment, and the two layers of the convolution kernel are 4 and 8, respectively. Next, we ran the prediction comparison experiments for 5 cases with 19, 15, 11, 7, and three kernel sizes and compared the prediction results for the 5 cases. Prediction effect (Figure6) shows the experimental results of the convolutional neural network stock prediction model in the above five cases.Figure 6
Prediction results metrics for different convolution kernel sizes.As mentioned earlier, the stock prediction model designed in this paper uses two convolutional layers and one downsampling layer. On this basis, the number of convolution kernels in the second layer is set to be twice the number of convolution kernels in the first layer. If the number of convolution kernels in the first layer is 4 and the number of convolution kernels in the second layer is 8, then it is represented by (4,8). The prediction experiments are carried out in four cases, and the number of convolution kernels is set to (3, 6), (4, 8), (5, 10), and (6, 12). Figure7 shows the predictions in the four cases comparative results.Figure 7
Prediction results metrics for different number of convolution kernels.This paper selects five main indices to train and test the model. Figures8 and 9 show two metrics of the prediction results of the proposed scheme and the other three comparison schemes on the corresponding datasets. The convolutional neural network stock index forecasting model and the hybrid convolutional neural network-support vector machine forecasting model follow the best trends in the five stock index datasets, and the error sequence for both forecasting models is 0. The four stock index prediction models showed that the best and the worst prediction results of the four stock indexes of HIS, TSEC, DAX, and S&P500 were CNN-SVM, CNN, SVM, and BP network in order. The two forecasting models proposed in this paper are still the best in the forecasting effect of the Nasdaq stock index, and the BP neural network forecasting model is better than the SVM forecasting model. From the correlation coefficient table, the CNN-SVM hybrid prediction model has the best prediction effect on the next trend of all five stock indices, while the CNN prediction model is a hybrid prediction model that predicts the next trend, you can look at the next. According to the above experimental analysis results, the two models proposed in this paper have certain feasibility in stock index forecasting, among which the hybrid forecasting model of convolutional neural network and support vector machine provides the best forecasting effect, only the prediction effect of convolutional neural network is better than that of traditional BP neural network, and the prediction model of support vector machine is supported.Figure 8
Comparison of MSE metrics for different prediction models.Figure 9
Comparison of correlation coefficient indicators of different prediction models.


## 5. Summary and Outlook

The results show that the two prediction models proposed in this paper are still the best prediction models for Nasdaq stock index. BP neural network prediction model is better than support vector machine prediction model. From the correlation coefficient table, it can be seen that CNN SVM hybrid prediction model has the best prediction effect on the next trend of all five stock indexes. CNN prediction model is a hybrid prediction model to predict the next trend. The innovation of this paper lies in the feasibility of the two models in stock index prediction. The hybrid prediction model of convolutional neural network and support vector machine provides the best prediction effect. Only convolution neural network has better prediction effect than traditional BP neural network and support vector machine. However, the research has certain limitations. When building a convolutional neural network prediction model suitable for financial time series, the structural parameters of the model are determined through many experiments. There is no theoretical guidance for the selection of parameter values that affect the financial impact behind the prediction. The impact of the results is unknown. Therefore, further validation is needed to predict the value in the next few days to prove the effectiveness of the model.



---

*Source: 7817264-2022-08-30.xml*