CN114579640A - Financial time sequence prediction system and method based on generating type countermeasure network - Google Patents
Financial time sequence prediction system and method based on generating type countermeasure network Download PDFInfo
- Publication number
- CN114579640A CN114579640A CN202210236749.0A CN202210236749A CN114579640A CN 114579640 A CN114579640 A CN 114579640A CN 202210236749 A CN202210236749 A CN 202210236749A CN 114579640 A CN114579640 A CN 114579640A
- Authority
- CN
- China
- Prior art keywords
- network
- financial
- time
- price
- time series
- Prior art date
- Legal status (The legal status is an assumption and is not a legal conclusion. Google has not performed a legal analysis and makes no representation as to the accuracy of the status listed.)
- Pending
Links
Images
Classifications
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06F—ELECTRIC DIGITAL DATA PROCESSING
- G06F16/00—Information retrieval; Database structures therefor; File system structures therefor
- G06F16/20—Information retrieval; Database structures therefor; File system structures therefor of structured data, e.g. relational data
- G06F16/24—Querying
- G06F16/245—Query processing
- G06F16/2458—Special types of queries, e.g. statistical queries, fuzzy queries or distributed queries
- G06F16/2474—Sequence data queries, e.g. querying versioned data
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/045—Combinations of networks
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/04—Architecture, e.g. interconnection topology
- G06N3/049—Temporal neural networks, e.g. delay elements, oscillating neurons or pulsed inputs
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06N—COMPUTING ARRANGEMENTS BASED ON SPECIFIC COMPUTATIONAL MODELS
- G06N3/00—Computing arrangements based on biological models
- G06N3/02—Neural networks
- G06N3/08—Learning methods
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q10/00—Administration; Management
- G06Q10/04—Forecasting or optimisation specially adapted for administrative or management purposes, e.g. linear programming or "cutting stock problem"
-
- G—PHYSICS
- G06—COMPUTING; CALCULATING OR COUNTING
- G06Q—INFORMATION AND COMMUNICATION TECHNOLOGY [ICT] SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES; SYSTEMS OR METHODS SPECIALLY ADAPTED FOR ADMINISTRATIVE, COMMERCIAL, FINANCIAL, MANAGERIAL OR SUPERVISORY PURPOSES, NOT OTHERWISE PROVIDED FOR
- G06Q40/00—Finance; Insurance; Tax strategies; Processing of corporate or income taxes
Landscapes
- Engineering & Computer Science (AREA)
- Theoretical Computer Science (AREA)
- Physics & Mathematics (AREA)
- General Physics & Mathematics (AREA)
- Business, Economics & Management (AREA)
- General Engineering & Computer Science (AREA)
- Software Systems (AREA)
- Mathematical Physics (AREA)
- Computational Linguistics (AREA)
- Data Mining & Analysis (AREA)
- Evolutionary Computation (AREA)
- Economics (AREA)
- Computing Systems (AREA)
- General Health & Medical Sciences (AREA)
- Biophysics (AREA)
- Biomedical Technology (AREA)
- Artificial Intelligence (AREA)
- Life Sciences & Earth Sciences (AREA)
- Health & Medical Sciences (AREA)
- Strategic Management (AREA)
- Molecular Biology (AREA)
- Marketing (AREA)
- General Business, Economics & Management (AREA)
- Development Economics (AREA)
- Human Resources & Organizations (AREA)
- Game Theory and Decision Science (AREA)
- Technology Law (AREA)
- Fuzzy Systems (AREA)
- Probability & Statistics with Applications (AREA)
- Databases & Information Systems (AREA)
- Finance (AREA)
- Accounting & Taxation (AREA)
- Entrepreneurship & Innovation (AREA)
- Operations Research (AREA)
- Quality & Reliability (AREA)
- Tourism & Hospitality (AREA)
- Management, Administration, Business Operations System, And Electronic Commerce (AREA)
- Financial Or Insurance-Related Operations Such As Payment And Settlement (AREA)
Abstract
The invention discloses a financial time series prediction system and method based on a generative confrontation network, which relate to the field of deep learning and financial time series prediction, and the system comprises: the data set acquisition module is used for constructing a data set sample, and the data set sample is divided into a training set, a verification set and a test set; the data set processing module is used for carrying out normalization processing firstly and then fusing the characteristics of different financial products at the same time to form a multi-financial product characteristic matrix; according to the size of the time steps required by model input, the multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is partitioned into a plurality of data blocks so as to accord with the input form required by the model; the model construction module is used for constructing a financial time series prediction model based on the GAN network; a training module to train the financial time series prediction model based on the GAN network using a training set; and the prediction module is used for evaluating the performance of the model.
Description
Technical Field
The invention relates to the field of deep learning and financial time series prediction, in particular to a financial time series prediction system and method based on a generative confrontation network.
Background
The quantitative investment refers to an investment mode of adopting a quantitative analysis means and sending a trading instruction by a computer program to carry out transaction. The development in overseas has been in the past for decades, with stable investment performance and ever expanding market size and share. At present, with the development of internet technology and the arrival of big data era, domestic quantitative transactions are gradually developed, various quantitative investment funds are established successively, and more traders who originally perform subjective investment based on base plane analysis transfer programmed quantitative technologies to perform transactions through computers.
In the field of quantitative investment, time series analysis is a basic technique. Many quantitative strategies are constructed based on predicting market trends of financial products through time series analysis, so that the prediction result of the trends plays a crucial role in transaction decision. Financial time series data comprises market trends of financial products such as stocks and futures, and accurate prediction of the market trends is a difficult problem in the industry due to characteristics of noise, high complexity, non-stationarity, strong nonlinearity and the like. In recent years, with the high development of artificial intelligence algorithms represented by machine learning and deep learning, many people try to predict market trends by using linear regression, support vector machines, decision trees, integrated models xgboost (extreme Gradient boosting) based on lifting trees, convolution networks, recurrent neural networks and other models, but the prediction accuracy of the models needs to be improved.
The invention provides an intelligent realization method for stock market risk prediction based on deep learning in the Chinese patent application (the patent application number is CN 202010298282.3). The method selects and combines shallow features to form more abstract high feature representation, discovers a deep-level implicit relation of data, and better obtains a composite function by stacking a plurality of layers of neural networks and selecting a Sigmoid activation function.
In the invention patent application "a futures model training and transaction implementation method based on multi-scale self-attention" (patent application number CN202010419707.1), jiangchen boat et al propose a futures market prediction model using attention mechanism, which extracts multi-scale characteristics of financial time series from the model angle through convolution kernels of different scale sizes and mines the correlation between different scale characteristics using attention mechanism to improve the accuracy of futures price trend prediction. The model only considers the market of futures to be predicted, but the market trend of some futures depends on factors of the model, and certain relevance may exist among different financial products, such as the inherent relevance of some varieties of wheat and rice of agricultural product futures.
Accordingly, those skilled in the art have endeavored to develop a new financial time series prediction system and method that considers not only the financial time series itself, but also the correlation between a plurality of associated financial products.
Disclosure of Invention
At present, the accuracy of financial time series prediction in the prior art has a room for improvement, and the market trend considered is generally only limited on a prediction target, and the market trend of financial products related to the prediction target is not considered. In view of the above-mentioned defects in the prior art, the present invention provides a financial time series prediction system and method based on a Generative Adaptive Network (GAN) to improve the accuracy of market prediction.
The invention provides a financial time series prediction system based on a generating type countermeasure network, which is characterized in that the characteristics and the relativity of a plurality of related financial products are captured through a capsule network, in the network training process, the generated data are closer to the real data, a discriminator network continuously improves the capability of distinguishing the generated data from the real data, the two parts of network training process are alternately carried out to finally reach Nash balance, and the discriminator network can not judge whether the input is the real data or the generated prediction data, so that the data generated by the generator network is almost equal to the real data, and a prediction model can better dig out the characteristics which characterize the future change trend in the financial time series.
The invention provides a financial time series prediction system based on a generative countermeasure network, which specifically comprises:
the system comprises a data set acquisition module, a verification module and a test module, wherein the data set acquisition module is used for constructing a data set sample, the data set sample is divided into a training set, a verification set and a test set, the data set sample comprises market trends and price labels of a plurality of financial products which are mutually associated, the market trends comprise historical opening prices, highest prices, lowest prices, closing prices and volume of transaction, and the price labels can be selected from opening prices or closing prices;
the data set processing module is connected with the data set acquisition module, and is used for firstly carrying out normalization processing on the data set samples received from the data set acquisition module and then fusing the characteristics of different financial products at the same moment to form a multi-financial product characteristic matrix; according to the size of the time steps required by model input, the multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is partitioned into a plurality of data blocks so as to accord with the input form required by the model; each data block represents an input sample, and is a time sequence with the length of the set time step size and the element of the time sequence being the characteristic matrix of the multi-element financial product;
the model construction module is connected with the data set processing module and is used for constructing a financial time series prediction model based on a GAN network; the financial time series prediction model based on the GAN network comprises a feature extraction network, a generator network and a discriminator network, wherein the GAN network comprises the generator network and the discriminator network; the feature extraction network comprises a convolution network and a capsule network;
a training module, connected to the model construction module, for training the financial time series prediction model based on the GAN network using the training set in the processed data set samples output by the data set processing module; in the training process, the generated data generated by the generator network is closer to real data, the discriminant network continuously improves the capability of distinguishing the generated data from the real data, the training processes of the generator network and the discriminant network are alternated and finally reach Nash balance, when the loss function of the financial time series prediction model based on the GAN network converges to a certain degree, the generated data generated by the generator network is equal to the real data, so that the financial time series prediction model based on the GAN network can dig out the characteristics representing the future variation trend in the data set sample, different hyper-parameters are tested respectively, and the model with the best evaluation index on the verification set is selected as the final model selection;
and the prediction module is connected with the training module and used for predicting the price market of the financial product on the test set by adopting the model trained by the training module and calculating an evaluation index to evaluate the performance of the model.
Further, in the data set processing module, the multivariate financial product characteristic matrix is represented as Xi∈RN ×DWherein i represents a time, N represents the number of the selected financial products which are mutually associated, and D represents the number of the characteristics of the selected financial products;
the specific form of each data block is (X)T-s,…XT-2,XT-1) Wherein s represents the selected time step number;
the label corresponding to the data block is the price Y at the time TT。
Further, in the feature extraction network of the model building module, firstly, the convolutional network preliminarily extracts features from the multi-financial-product feature matrix, finds correlations between different financial products, and then the capsule network replaces a pooling layer of the convolutional network to automatically extract an optimal feature quantity.
Further, the input of the generator network is the feature quantity extracted by the feature extraction network, and the output is the predicted price of the financial product corresponding to the time TThe generator network is composed of long-time memory gating cycle units.
Further, the discriminator network adopts a convolutional neural network to judge whether the input price sequence reflects a real price rule, and if the input sequence is more real, the output score of the discriminator network is larger; conversely, if the data predicted by the generator network does not have true regularity, the value output by the arbiter network is low.
The invention also provides a financial time series prediction method based on the generative confrontation network, which comprises the following steps:
step 3, constructing a financial time series prediction model based on a GAN network, wherein the financial time series prediction model based on the GAN network comprises a feature extraction network, a generator network and a discriminator network, and the GAN network comprises the generator network and the discriminator network; the feature extraction network comprises a convolution network and a capsule network;
step 4, training the financial time series prediction model based on the GAN network by using the training set in the preprocessed data set sample, and performing verification on the verification set to determine final model selection;
and 5, predicting the trained financial time series prediction model based on the GAN network on the test set, and calculating an evaluation index to evaluate the performance of the model.
Further, the step 2 comprises the following steps:
step 2.1, independently carrying out normalization processing on each characteristic dimension of the data set sample by adopting a Max-Min method, wherein a calculation formula is as follows:
wherein x represents a certain characteristic original value, xminRepresents the minimum value, x, of the feature on the training setmaxRepresents the maximum, x, of the feature over the training set*Represents the normalized result;
step 2.2, fusing the characteristics of different financial products at the same time to form a multi-financial product characteristic matrix Xi∈RN×DWherein i represents a time, N represents the number of the selected related financial products, and D represents the number of the characteristics of the selected financial products;
step 2.3, according to the size of the time steps required by model input, the multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is partitioned into a plurality of data blocks so as to accord with the input form required by the model; each data block represents an input sample, and is a time sequence with the length of the set time step size and the element of the time sequence being the characteristic matrix of the multi-element financial product; the specific form of each data block is (X)T-s,…XT-2,XT-1) Wherein s represents a numberTaking the time step number; the label corresponding to the data block is the price Y at the time TT。
Further, the step 3 comprises the following steps:
step 3.1, firstly, the characteristic matrix X of the multi-element financial product is processed by the convolution networkiExtracting the correlation among different financial products to obtain a multi-channel feature map, wherein the convolution kernels at different time steps on the same layer share the weight;
step 3.2, reconstructing the multi-channel characteristic diagram into a plurality of groups of characteristic vectors Vi∈Rn×dWhere i denotes a time step, n denotes the number of feature vectors extracted by convolutional layers of the convolutional network, d denotes the dimension of the feature vectors, and, specifically,
step 3.3, replacing the pooling layer pair V of the convolution network with the capsule networkiPerforming feature extraction, and automatically extracting an optimal feature vector from the feature vectors through a dynamic routing algorithm; for each time step i, n feature vectors v preliminarily extracted by the convolutional layer at the time step ij(j ═ 1,2, …, n) as inputs to the capsule network, v for each inputjTransforming through a trainable weight matrix to obtain a transformed eigenvector uj:
Step 3.4, initializing each transformed feature vectorSum weight ofFor eachIs correspondingly provided with oneAnd is initialized to 0, pairAll are determined by softmax algorithm
Step 3.6, in order to ensure that the features extracted at each time step i have uniformity, for siPerforming unitization to obtain multiple financial characteristics ei:
Step 3.7, in order to extract the optimal feature vector, the method comprisesTo pairContinuously updating until reaching preset iteration times, and finally obtaining the multi-financial characteristics e of the time step iiThe other time steps adopt the same steps;
step 3.8, using a long-and-short-time memory gating cycle unit as the generator network, and extracting the multivariate financial characteristics e of different time steps from the characteristic extraction networkiAs input to the generator network and outputting the predicted price of the financial product at time T
And 3.9, adopting a one-dimensional convolution network to construct the discriminator network, and adopting a full-connection network to output discrimination scores at the last two layers.
Further, the step 4 comprises the following steps:
step 4.1, the predicted price of the financial product at the T moment output by the generator networkCombined with the actual prices of previous moments into a sequenceAs an input to the discriminator network;
step 4.2, loss function L of the discriminator networkDComprises the following steps:
wherein, YkRepresenting the selected kth actual price time series Representing the kth predicted price sequence(only T)kTime is predicted value), D (Y)k) Represents the aboveJudging scores output by the discriminator network, wherein the larger the value of the judging scores is, the higher the truth is;
step 4.3, solving the loss function L through gradient risingDThe maximum value of (a), the value of the discriminant score output for the kth actual price time series is made as large as possible, the value of the discriminant score output for the kth predicted price time series is made as small as possible, and the discriminant capability of the discriminant network is enhanced;
step 4.4, after each iteration, limiting the weight parameters in the discriminator network to an interval [ -c, + c ], taking c for the weight coefficient greater than c, and taking-c for the weight coefficient smaller than-c, wherein c is a hyper-parameter;
step 4.5 loss function L of the generator networkGComprises the following steps:
the second term in the above equation is a penalty term, and the penalty term is used for enabling the generator network to predict a price which is accurate and conforms to real regularity; g (X)k) Representing the output of the generator network as a sequence of predicted prices for the kth sequence input
Step 4.6, minimizing the loss function L by gradient descentG;
4.7, alternately training the discriminator network and the generator network to Nash balance by adopting the training method of the GAN network in the training process;
step 4.8, respectively testing different hyper-parameters c, selecting the model with the best evaluation index on the verification set as the final model selection, wherein the evaluation index selects Mean Square Error (MSE) and decision coefficient R2:
Wherein, the first and the second end of the pipe are connected with each other,is the predicted price of the financial product at time T, YTIs the actual price, N, corresponding to the time TvalidRepresents a total number of samples of the validation set,indicating label Y on said verification setTThe average value of (a) of (b),the closer the MSE is to 0, R2The closer to 1, the higher the prediction accuracy.
Further, the step 5 comprises the following steps:
step 5.1, selecting the final model to predict on the test set, and storing a prediction result;
step 5.2, calculating MSE and R on the test set2;
Step 5.3, according to MSE and R on the test set2And comprehensively judging whether the final model selection can be used subsequently or not according to the return condition of the prediction result detected by the basic transaction strategy.
The financial time series prediction system and method based on the generative countermeasure network provided by the invention at least have the following technical effects:
1. the conventional method for predicting the financial time series only considers the price market trend of a single financial product generally, and the information considered by a model is not comprehensive enough to cause that the prediction result is not ideal in some cases;
2. in the network training process, the generator network enables the generated data to be closer to the real data, the discriminator network continuously improves the capability of distinguishing the generated data from the real data, the two parts of network training process are alternately performed to finally reach Nash balance, and the discriminator cannot judge whether the input is the real data or the generated prediction data, so that the data generated by the generator is almost equal to the real data, the prediction model can dig out the objective rule of the financial time sequence, and the abnormal prediction result is avoided.
The conception, the specific structure and the technical effects of the present invention will be further described with reference to the accompanying drawings to fully understand the objects, the features and the effects of the present invention.
Drawings
FIG. 1 is a block diagram of a financial time series prediction system based on a generative confrontation network according to a preferred embodiment of the present invention;
FIG. 2 is a financial time series prediction model based on generative confrontation network according to a preferred embodiment of the present invention;
FIG. 3 is a feature extraction network in accordance with a preferred embodiment of the present invention;
FIG. 4 is a discriminator network according to a preferred embodiment of the invention.
Detailed Description
The technical contents of the preferred embodiments of the present invention will be more clearly and easily understood by referring to the drawings attached to the specification. The present invention may be embodied in many different forms of embodiments and the scope of the invention is not limited to the embodiments set forth herein.
As shown in fig. 1, the financial time series prediction system based on the generative countermeasure network provided by the present invention specifically includes:
the system comprises a data set acquisition module, a data set sample construction module and a data set testing module, wherein the data set sample is divided into a training set, a verification set and a testing set, the data set comprises a plurality of mutually related market trends of financial products in recent years and corresponding price labels, the market trends are not merely the market trends of the financial products to be predicted, such as the market future price trends of wheat, and the historical market trends of future products of other agricultural products such as rice and corn can be considered. The selected data characteristics of the financial products comprise opening price, highest price, lowest price, closing price and volume of bargaining, and some technical indexes can be added.
The data set processing module is connected with the data set acquisition module, and is used for firstly carrying out normalization processing on the data set samples received from the data set acquisition module and then fusing the characteristics of different financial products at the same moment to form a multi-financial product characteristic matrix; according to the size of the time steps required by model input, a multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is divided into a plurality of data blocks so as to accord with the input form required by the model; each data block represents an input sample, and is a time sequence with the length of a set time step size and the element of a multi-element financial product characteristic matrix;
the characteristic matrix of the multi-element financial product is represented as Xi∈RN×DWherein i represents the time, N represents the number of the selected financial products which are related with each other, and D represents the number of the characteristics of the selected financial products.
Each data block is of the specific form (X)T-s,…XT-2,XT-1) Wherein s represents the selected time step number; price Y of data block corresponding to label T timeT。
And the model construction module is connected with the data set processing module and is used for constructing a financial time series prediction model based on the GAN network. As shown in fig. 2, the GAN network-based financial time series prediction model includes a feature extraction network, a generator network, and a discriminator network, wherein the GAN network includes the generator network and the discriminator network; the feature extraction network includes a convolution network and a capsule network, as shown in fig. 3, the convolution network has a capability of extracting features for local parts by performing convolution on local convolution operation, and the capsule network automatically extracts features for input through a dynamic routing algorithm.
In the feature extraction network of the model building module, firstly, the convolution network preliminarily extracts features from a multi-element financial product feature matrix, the correlation among different financial products is searched, and then the capsule network replaces the pooling layer of the convolution network to automatically extract the optimal feature quantity. Because the pooling layer may lose a lot of information, but the information of the financial time series is very important, the capsule network can reduce the information loss so as to better mine the characteristics of the financial time series, which characterize the future trend, from the existing information as much as possible.
The input of the generator network is the characteristic quantity extracted by the characteristic extraction network, and the output is the predicted price of the financial product corresponding to the T momentThe generator network consists of Long Short-Term Memory gated cyclic units (LSTM). The LSTM network is a variant of a recurrent neural network, is provided with a forgetting gate, an input gate and an output gate, and has a memory function on sequence data, so that time sequence characteristics can be captured on different time spans, and the accuracy of time sequence prediction is improved.
The discriminator network employs a convolutional neural network, as shown in fig. 4. The part judges whether the input price sequence reflects a real price rule, if the input sequence is more real, the output score of the discriminator network is larger; conversely, if the data predicted by the generator network does not have true regularity, the value output by the arbiter network is low.
The training module is connected with the model construction module and is used for training a financial time sequence prediction model based on the GAN network by using a training set in a processed data set sample output by the data set processing module; in the training process, the generated data generated by the generator network is closer to the real data, the discriminant network continuously improves the capability of distinguishing the generated data from the real data, the training processes of the generator network and the discriminant network are alternately carried out and the Nash balance is finally achieved, when the loss function of the GAN network-based financial time series prediction model converges to a certain degree, the generated data generated by the generator network is equal to the real data, so that the GAN network-based financial time series prediction model can dig out the characteristics representing the future variation trend in a data set sample, different hyper-parameters are respectively tested, and the model with the best evaluation index on a verification set is selected as the final model selection;
and the prediction module is connected with the training module and used for predicting the price market of the financial product on a test set by adopting the model trained by the training module and calculating an evaluation index to evaluate the performance of the model.
In order to more clearly introduce the technical scheme of the invention, the forecast future price trend is taken as an example, and the technical scheme is as follows:
firstly, a data sample is constructed through a data set acquisition module, and then other varieties which are related to the future trend market are selected according to the future varieties to be predicted. The opening price, closing price, highest price, lowest price, volume of finished goods, average price in a certain period of time and price change rate are selected as characteristics (other technical indexes can also be added). And after the time range is determined, dividing the training set, the verification set and the test set according to the set time range in time sequence to complete the construction of the data set sample.
And then, carrying out data preprocessing on a data set sample generated by the data set acquisition module through the data set processing module, firstly carrying out normalization processing on the data set, then fusing the normalized characteristics of different varieties of futures, and further, cutting and partitioning the fused characteristic matrix on a time dimension according to the size of time steps required by model input so as to meet the input form required by the model.
And then, completing the construction of the model through a model construction module, inputting the data obtained from a data set acquisition module into the model, and starting the training of the model through a training module, specifically, in order to enable the generative confrontation network to be stably trained, adopting a Wassertein generative confrontation network (WGAN), and adopting Earth-mover (EM) distance in the WGAN to replace the JS divergence of the traditional generative confrontation network to measure the difference between the two probability distributions.
And finally, obtaining a prediction result of the model on the test set by the trained model through a prediction module, and finally finishing model evaluation.
The invention provides a financial time series prediction method based on a generative countermeasure network, which comprises the following steps:
step 3, constructing a financial time series prediction model based on the GAN network, wherein the financial time series prediction model based on the GAN network comprises a feature extraction network, a generator network and a discriminator network, and the GAN network comprises the generator network and the discriminator network; the characteristic extraction network comprises a convolution network and a capsule network;
step 4, training a financial time series prediction model based on the GAN network by using a training set in the preprocessed data set sample, and verifying on a verification set to determine final model selection;
and 5, predicting the trained financial time sequence prediction model based on the GAN network on a test set, and calculating an evaluation index to evaluate the performance of the model.
The step 1 comprises the following steps:
step 1.1, obtaining a main power contract of the futures to be predicted in a selected time range, wherein the main power contract is a contract with the largest daily transaction amount;
and step 1.2, aiming at the futures to be predicted, selecting other futures which are related to the futures trend market, such as predicting the wheat price trend, wherein the historical market of futures of other agricultural products such as rice, corn and the like can be considered. Selecting a master force contract for each futures variety as well;
step 1.3, selecting opening price, closing price, highest price, lowest price, volume of bargain, average price in a certain period of time and price change rate as characteristics;
and 1.4, dividing the training set, the verification set and the test set according to the time sequence.
The step 2 comprises the following steps:
step 2.1, independently carrying out normalization processing on each characteristic dimension of the data set sample by adopting a Max-Min method, wherein the calculation formula is as follows:
wherein x represents a certain characteristic original value, xmibRepresents the minimum, x, of the feature on the training setmaxRepresents the maximum, x, of the feature on the training set*Represents the normalized result;
step 2.2, fusing the characteristics of different futures products at the same time to form a multi-element futures characteristic matrix Xi∈RN×DWherein i represents a time, N represents the number of the selected related futures items, and D represents the number of the characteristics of the selected futures items;
step 2.3, according to the size of the time steps required by model input, the multi-element futures characteristic matrix is cut and partitioned on the time dimension, and the multi-element futures characteristic matrix is partitioned into a plurality of data blocks so as to meet the input form required by the model; each data block represents an input sample, and is a time sequence with the length of a set time step size and the elements of a multi-element futures characteristic matrix; each data block is of the specific form (X)T-s,…XT-2,XT-1) Wherein s represents the selected time step number; price Y of data block corresponding to label T timeT。
The step 3 comprises the following steps:
step 3.1, firstly, the multivariate futures are processed by the convolution networkFeature matrix XiExtracting the correlation among different futures varieties to obtain a multi-channel characteristic diagram, wherein the convolution kernels of the same layer at different time steps share weights;
step 3.2, reconstructing the multi-channel characteristic diagram into a plurality of groups of characteristic vectors Vi∈Rn×dWhere i denotes a time step, n denotes the number of feature vectors extracted by the convolutional layer of the convolutional network, d denotes the dimension of the feature vector, and, specifically,
step 3.3, adopting capsule network to replace the pooling layer pair V of the convolution networkiPerforming feature extraction, and automatically extracting an optimal feature vector from the feature vectors through a dynamic routing algorithm; for each time step i, n eigenvectors v preliminarily extracted by the convolutional layer at the time step ij(j ═ 1,2, …, n) as inputs to the capsule network, v for each inputjTransforming through a trainable weight matrix to obtain a transformed eigenvector uj:
Step 3.4, initialize each transformed feature vectorSum weight ofFor eachIs correspondingly provided with oneAnd is initialized to 0, pairAll are determined by softmax algorithm
Step 3.6, in order to ensure that the features extracted at each time step i have uniformity, for siPerforming unitized processing to obtain multiple futures characteristics ei:
Step 3.7, in order to extract the optimal feature vector, the method comprisesTo pairContinuously updating until reaching preset iteration times to finally obtain the multi-element futures characteristics e of the time step iiThe same steps are adopted in other time steps;
step 3.8, using the long-time memory gating cycle unit as a generator network, and extracting the multi-element futures characteristics e of different time steps from the characteristic extraction networkiAs input to the generator network, and outputs the predicted price of the futures at time T
And 3.9, adopting a one-dimensional convolution network to construct a discriminator network, and adopting a full-connection network to output discrimination scores at the last two layers.
Step 4 comprises the following steps:
step 4.1, the predicted price of the futures at the T moment output by the generator networkCombined with the actual prices of previous moments into a sequenceAs an input to the arbiter network;
step 4.2, loss function L of discriminator networkDComprises the following steps:
wherein Y iskRepresenting the selected kth actual price time series Representing the kth predicted price sequence(only T)kTime is predicted value), D (Y)k) The judgment score output by the network of the judger is represented, and the larger the value of the judgment score is, the higher the truth is;
step 4.3, solving the loss function L through gradient ascentDThe maximum value of (4) is that the value of the discriminant score output to the kth actual price time sequence is as large as possible, the value of the discriminant score output to the kth predicted price time sequence is as small as possible, and the discriminant capability of the discriminant network is enhanced;
step 4.4, after each iteration, limiting the weight parameters in the discriminator network to an interval [ -c, + c ], taking c for the weight coefficient greater than c, and taking-c for the weight coefficient smaller than-c, wherein c is a hyper-parameter;
step 4.5 loss function L of generator networkGComprises the following steps:
the second term in the above formula is a penalty term, and the penalty term has the function of enabling the generator network to predict the price which is accurate and accords with the real regularity; g (X)k) The output of the representation generator network is the predicted price sequence for the kth sequence input
Step 4.6, minimizing the loss function L by gradient descentG;
Step 4.7, alternately training the discriminator network and the generator network to Nash balance by adopting a GAN network training method in the training process;
step 4.8, respectively testing different hyper-parameters C, selecting the model with the best evaluation index on the verification set as the final model selection, and selecting the mean square error MSE and the decision coefficient R for the evaluation index2:
Wherein the content of the first and second substances,is the predicted price of the futures at time T,YTIs the actual price, N, corresponding to the time TvalidRepresenting the total number of samples of the validation set,indicating label Y on verification setTThe average value of (a) of (b),the closer the MSE is to 0, R2The closer to 1, the higher the prediction accuracy.
The step 5 comprises the following steps:
step 5.1, selecting the final model to predict on a test set, and storing a prediction result;
step 5.2, computing MSE and R on the test set2;
Step 5.3, according to MSE and R on the test set2And comprehensively judging whether the final model selection can be used subsequently or not according to the return condition of the prediction result detected by the basic transaction strategy.
The financial time series prediction system and method based on the generative confrontation network, provided by the invention, consider the influence of a plurality of associated financial product market trend on the price trend of a target financial product, and enable the model to consider more comprehensive information, so that the model has higher accuracy on trend prediction. The capsule network is used for replacing a pooling layer in the feature extraction network, information loss is reduced, the feature quantity with more characteristic performance is extracted through a dynamic routing algorithm, and the relevance of the selected financial product features and market trend and the relevance among different financial products are better mined. The GAN network is adopted as a main framework, and the generator network and the discriminator network are alternately trained to Nash balance, so that the prediction result of the generator network conforms to an objective rule, abnormal prediction values are avoided, and meanwhile, the prediction accuracy is improved.
The foregoing detailed description of the preferred embodiments of the invention has been presented. It should be understood that numerous modifications and variations could be devised by those skilled in the art in light of the present teachings without departing from the inventive concepts. Therefore, the technical solutions available to those skilled in the art through logic analysis, reasoning and limited experiments based on the prior art according to the concept of the present invention should be within the scope of protection defined by the claims.
Claims (10)
1. A financial time series prediction system based on a generative confrontation network, comprising:
the system comprises a data set acquisition module, a data set analysis module and a data set analysis module, wherein the data set acquisition module is used for constructing a data set sample, the data set sample is divided into a training set, a verification set and a test set, the data set sample comprises market trend and price tags of a plurality of financial products which are mutually associated, the market trend comprises historical opening price, highest price, lowest price, closing price and volume of transaction, and the price tags can be selected from the opening price or the closing price;
the data set processing module is connected with the data set acquisition module, and is used for firstly carrying out normalization processing on the data set samples received from the data set acquisition module and then fusing the characteristics of different financial products at the same moment to form a multi-financial product characteristic matrix; according to the size of the time steps required by model input, the multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is partitioned into a plurality of data blocks so as to accord with the input form required by the model; each data block represents an input sample, and is a time sequence with the length of the set time step size and the element of the time sequence being the characteristic matrix of the multi-element financial product;
the model construction module is connected with the data set processing module and is used for constructing a financial time series prediction model based on a GAN network; the financial time series prediction model based on the GAN network comprises a feature extraction network, a generator network and a discriminator network, wherein the GAN network comprises the generator network and the discriminator network; the feature extraction network comprises a convolution network and a capsule network;
a training module, connected to the model construction module, for training the financial time series prediction model based on the GAN network using the training set in the processed data set samples output by the data set processing module; in the training process, the generated data generated by the generator network is closer to real data, the discriminant network continuously improves the capability of distinguishing the generated data from the real data, the training processes of the generator network and the discriminant network are alternated and finally reach Nash balance, when the loss function of the financial time series prediction model based on the GAN network converges to a certain degree, the generated data generated by the generator network is equal to the real data, so that the financial time series prediction model based on the GAN network can dig out the characteristics representing the future variation trend in the data set sample, different hyper-parameters are tested respectively, and the model with the best evaluation index on the verification set is selected as the final model selection;
and the prediction module is connected with the training module and used for predicting the price market of the financial product on the test set by adopting the model trained by the training module and calculating an evaluation index to evaluate the performance of the model.
2. The generative opposing network-based financial time series prediction system as claimed in claim 1, wherein the multivariate financial product characteristics matrix is represented as X in the data set processing modulei∈RN×DWherein i represents a time, N represents the number of the selected financial products which are mutually associated, and D represents the number of the characteristics of the selected financial products;
the specific form of each data block is (X)T-s,…XT-2,XT-1) Wherein s represents the selected time step number;
the label corresponding to the data block is the price Y at the time TT。
3. The system of claim 1, wherein in the feature extraction network of the model building module, the convolutional network initially extracts features from the multi-financial product feature matrix, finds correlations between different financial products, and then replaces the pooling layer of the convolutional network with the capsule network to automatically extract optimal features.
5. The system of claim 3, wherein the discriminator network employs a convolutional neural network to determine whether the input price sequence reflects true price rules, and if the input sequence is more true, the output score of the discriminator network is larger; conversely, if the data predicted by the generator network has no true regularity, the value output by the arbiter network is very low.
6. A financial time series prediction method based on a generative confrontation network, which is characterized by comprising the following steps:
step 1, constructing a data set sample, and dividing the data set sample into a training set, a verification set and a test set;
step 2, preprocessing the data set sample;
step 3, constructing a financial time series prediction model based on a GAN network, wherein the financial time series prediction model based on the GAN network comprises a feature extraction network, a generator network and a discriminator network, and the GAN network comprises the generator network and the discriminator network; the feature extraction network comprises a convolution network and a capsule network;
step 4, training the financial time series prediction model based on the GAN network by using the training set in the preprocessed data set sample, and performing verification on the verification set to determine final model selection;
and 5, predicting the trained financial time series prediction model based on the GAN network on the test set, and calculating an evaluation index to evaluate the performance of the model.
7. The financial time series prediction method based on generative countermeasure network as set forth in claim 6, wherein the step 2 comprises the steps of:
step 2.1, independently carrying out normalization processing on each characteristic dimension of the data set sample by adopting a Max-Min method, wherein a calculation formula is as follows:
wherein x represents a certain characteristic original value, xminRepresents the minimum value, x, of the feature on the training setmaxRepresents the maximum, x, of the feature over the training set*Represents the normalized result;
step 2.2, fusing the characteristics of different financial products at the same time to form a multi-financial product characteristic matrix Xi∈RN×DWherein i represents a time, N represents the number of the selected related financial products, and D represents the number of the characteristics of the selected financial products;
step 2.3, according to the size of the time steps required by model input, the multi-element financial product characteristic matrix is cut and partitioned on the time dimension, and the multi-element financial product characteristic matrix is partitioned into a plurality of data blocks so as to accord with the input form required by the model; each of the data blocks representsAn input sample which is a time sequence with the length of the set time step size and the element of the multi-element financial product characteristic matrix; the specific form of each data block is (X)T-s,…XT-2,XT-1) Wherein s represents the selected time step number; the label corresponding to the data block is the price Y at the time TT。
8. The financial time series prediction method based on generative countermeasure network as set forth in claim 7, wherein the step 3 comprises the steps of:
step 3.1, firstly, the characteristic matrix X of the multi-element financial product is processed by the convolution networkiExtracting the correlation among different financial products to obtain a multi-channel feature map, wherein the convolution kernels at different time steps on the same layer share the weight;
step 3.2, reconstructing the multi-channel characteristic diagram into a plurality of groups of characteristic vectors Vi∈Rn×dWhere i denotes a time step, n denotes the number of feature vectors extracted by convolutional layers of the convolutional network, d denotes the dimension of the feature vectors, and, specifically,
step 3.3, replacing the pooling layer pair V of the convolution network with the capsule networkiPerforming feature extraction, and automatically extracting an optimal feature vector from the feature vectors through a dynamic routing algorithm; for each time step i, n feature vectors v preliminarily extracted by the convolutional layer at the time step ij(j ═ 1,2, …, n) as inputs to the capsule network, v for each inputjTransforming through a trainable weight matrix to obtain a transformed eigenvector uj:
Step 3.4, initialize each said transformationThe latter feature vectorSum weight ofFor eachIs correspondingly provided with oneAnd is initialized to 0, pairUsing softmax algorithm to find all
Step 3.6, in order to ensure that the features extracted at each time step i have uniformity, for siProcessing the units to obtain multiple financial characteristics ei:
Step 3.7, in order to extract the optimal feature vector, the method comprisesTo pairContinuously updating until reaching preset iteration times, and finally obtaining the multi-financial characteristics e of the time step iiThe other time steps adopt the same steps;
step 3.8, using a long-and-short-time memory gating cycle unit as the generator network, and extracting the multivariate financial characteristics e of different time steps from the characteristic extraction networkiAs input to the generator network and outputting the predicted price of the financial product at time T
And 3.9, adopting a one-dimensional convolution network to construct the discriminator network, and adopting a full-connection network to output discrimination scores at the last two layers.
9. The method for predicting financial time series based on generative countermeasure network as claimed in claim 8, wherein the step 4 comprises the steps of:
step 4.1, predicting the price of the financial product at the T moment output by the generator networkCombined with the actual prices of previous moments into a sequenceAs an input to the discriminator network;
step 4.2, loss function L of the discriminator networkDComprises the following steps:
wherein, YkRepresenting the selected kth actual price time series Representing the kth predicted price sequence(only T)kTime is predicted value), D (Y)k) Representing a discrimination score output by the discriminator network, wherein the larger the value of the discrimination score is, the higher the truth degree is;
step 4.3, solving the loss function L through gradient risingDThe maximum value of (a), the value of the discriminant score output for the kth actual price time series is made as large as possible, the value of the discriminant score output for the kth predicted price time series is made as small as possible, and the discriminant capability of the discriminant network is enhanced;
step 4.4, after each iteration, limiting the weight parameters in the discriminator network to an interval [ -c, + c ], taking c for the weight coefficient greater than c, and taking-c for the weight coefficient smaller than-c, wherein c is a hyper-parameter;
step 4.5 loss function L of the generator networkGComprises the following steps:
the second term in the above equation is a penalty term, and the penalty term is used for enabling the generator network to predict a price which is accurate and conforms to real regularity; g (X)k) Representing the output of the generator network, is the predicted price for the kth sequence inputSequence of
Step 4.6, minimizing the loss function L by gradient descentG;
4.7, alternately training the discriminator network and the generator network to Nash balance by adopting the training method of the GAN network in the training process;
step 4.8, respectively testing different hyper-parameters c, selecting the model with the best evaluation index on the verification set as the final model selection, wherein the evaluation index selects Mean Square Error (MSE) and decision coefficient R2:
Wherein the content of the first and second substances,is the predicted price of the financial product at time T, YTIs the actual price, N, corresponding to the time TvalidRepresents a total number of samples of the validation set,indicating label Y on said verification setTThe average value of (a) of (b),the closer the MSE is to 0, R2The closer to 1, the higher the prediction accuracy.
10. The method for predicting financial time series based on generative countermeasure network as claimed in claim 9, wherein the step 5 comprises the steps of:
step 5.1, selecting the final model to predict on the test set, and storing a prediction result;
step 5.2, calculating MSE and R on the test set2;
Step 5.3, according to MSE and R on the test set2And comprehensively judging whether the final model selection can be used subsequently or not according to the return condition of the prediction result detected by the basic transaction strategy.
Priority Applications (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210236749.0A CN114579640A (en) | 2022-03-10 | 2022-03-10 | Financial time sequence prediction system and method based on generating type countermeasure network |
Applications Claiming Priority (1)
Application Number | Priority Date | Filing Date | Title |
---|---|---|---|
CN202210236749.0A CN114579640A (en) | 2022-03-10 | 2022-03-10 | Financial time sequence prediction system and method based on generating type countermeasure network |
Publications (1)
Publication Number | Publication Date |
---|---|
CN114579640A true CN114579640A (en) | 2022-06-03 |
Family
ID=81779670
Family Applications (1)
Application Number | Title | Priority Date | Filing Date |
---|---|---|---|
CN202210236749.0A Pending CN114579640A (en) | 2022-03-10 | 2022-03-10 | Financial time sequence prediction system and method based on generating type countermeasure network |
Country Status (1)
Country | Link |
---|---|
CN (1) | CN114579640A (en) |
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115759206A (en) * | 2022-09-05 | 2023-03-07 | 同济大学 | Unsupervised learning method based on quantification and generation confrontation network |
WO2024065954A1 (en) * | 2022-09-28 | 2024-04-04 | 电子科技大学长三角研究院(湖州) | Short-time prediction method and system for occupancy rate of parking spaces in parking lot, device and terminal |
-
2022
- 2022-03-10 CN CN202210236749.0A patent/CN114579640A/en active Pending
Cited By (2)
Publication number | Priority date | Publication date | Assignee | Title |
---|---|---|---|---|
CN115759206A (en) * | 2022-09-05 | 2023-03-07 | 同济大学 | Unsupervised learning method based on quantification and generation confrontation network |
WO2024065954A1 (en) * | 2022-09-28 | 2024-04-04 | 电子科技大学长三角研究院(湖州) | Short-time prediction method and system for occupancy rate of parking spaces in parking lot, device and terminal |
Similar Documents
Publication | Publication Date | Title |
---|---|---|
CN111737474B (en) | Method and device for training business model and determining text classification category | |
CN109255506B (en) | Internet financial user loan overdue prediction method based on big data | |
CN111126482B (en) | Remote sensing image automatic classification method based on multi-classifier cascade model | |
WO2021143396A1 (en) | Method and apparatus for carrying out classification prediction by using text classification model | |
CN110956273A (en) | Credit scoring method and system integrating multiple machine learning models | |
CN108021930B (en) | Self-adaptive multi-view image classification method and system | |
CN114579640A (en) | Financial time sequence prediction system and method based on generating type countermeasure network | |
CN111881722B (en) | Cross-age face recognition method, system, device and storage medium | |
CN110413775A (en) | A kind of data label classification method, device, terminal and storage medium | |
KR20020030744A (en) | Enhancing knowledge discovery from multiple data sets using multiple support vector machines | |
EP4322031A1 (en) | Recommendation method, recommendation model training method, and related product | |
CN111768000A (en) | Industrial process data modeling method for online adaptive fine-tuning deep learning | |
CN111914728A (en) | Hyperspectral remote sensing image semi-supervised classification method and device and storage medium | |
CN112633386A (en) | SACVAEGAN-based hyperspectral image classification method | |
CN113269647A (en) | Graph-based transaction abnormity associated user detection method | |
KR20220059120A (en) | System for modeling automatically of machine learning with hyper-parameter optimization and method thereof | |
CN111695024A (en) | Object evaluation value prediction method and system, and recommendation method and system | |
CN109102021A (en) | The mutual polishing multicore k- mean cluster machine learning method of core under deletion condition | |
CN112529684A (en) | Customer credit assessment method and system based on FWA _ DBN | |
CN116956228A (en) | Text mining method for technical transaction platform | |
CN115936773A (en) | Internet financial black product identification method and system | |
CN115423091A (en) | Conditional antagonistic neural network training method, scene generation method and system | |
Xiong et al. | L-RBF: A customer churn prediction model based on lasso+ RBF | |
CN113935413A (en) | Distribution network wave recording file waveform identification method based on convolutional neural network | |
Zha et al. | A hierarchical reinforcement learning framework for stock selection and portfolio |
Legal Events
Date | Code | Title | Description |
---|---|---|---|
PB01 | Publication | ||
PB01 | Publication | ||
SE01 | Entry into force of request for substantive examination | ||
SE01 | Entry into force of request for substantive examination |