Covariance matrix prediction method based on neural network

By using neural networks to predict the RCOV matrix in the Chinese stock market, the problems of characterizing high-dimensional asset dependencies, ensuring positive definiteness, and capturing spatiotemporal correlations were solved, improving the accuracy and stability of portfolio optimization and adapting to the trading characteristics of the Chinese stock market.

CN121280137APending Publication Date: 2026-01-06SHANGHAI UNIV OF ENG SCI
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202511452565.8
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-10-12
Publication Date
2026-01-06

AI Technical Summary

Technical Problem

Existing RCOV matrix prediction models struggle to characterize complex asset dependencies in high-dimensional scenarios, lack sufficient positive definiteness of the covariance matrix, have weak spatiotemporal correlation capture capabilities, and are not adequately adapted to the trading hours and data characteristics of the Chinese stock market, resulting in insufficient accuracy and stability in portfolio optimization.

Method used

A neural network-based covariance matrix prediction method is adopted. The neural network is constructed using 5-minute high-frequency data from the Chinese stock market. Combined with ConvBiLSTM and Gramian positive definiteness protection techniques, the RCOV matrix is ​​predicted to ensure positive definiteness and capture of spatiotemporal correlation, thus adapting to the trading characteristics of the Chinese stock market.

Benefits of technology

It achieves high-dimensional adaptability, positive definiteness guarantee, and spatiotemporal correlation capture, improving the accuracy and stability of portfolio optimization and reducing the complexity and computational cost of live applications.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN121280137A_ABST
    Figure CN121280137A_ABST
Patent Text Reader

Abstract

The invention discloses a covariance matrix prediction method based on a neural network, and relates to the crossing field of financial engineering and deep learning. The method comprises the following steps: firstly, collecting five-minute-level high-frequency data of a Chinese stock market, screening and filling, then calculating a realized covariance (RCOV) matrix, and then preprocessing through square root transformation and Cholesky decomposition; thirdly, constructing a 3D input tensor and a label, and dividing and standardizing a time sequence data set; then, a CM-ConvBiLSTM model containing a coding layer (ConvBiLSTM + CNN) and a generation layer is built, and training is carried out through Huber loss and an Adam optimizer; and finally, carrying out inverse preprocessing to obtain a positive definite prediction RCOV matrix which is used for constructing investment portfolios such as global minimum variance and monthly rebalance. According to the method, the problems of high-dimensional adaptation, positive qualitative guarantee and the like are solved, the investment portfolio optimization precision and stability are improved, and the method adapts to Chinese stock market characteristics.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the interdisciplinary field of financial engineering and deep learning, specifically to a method for predicting covariance matrices based on neural networks. Background Technology

[0002] In modern finance, Markowitz's mean-variance theory is the core framework for portfolio optimization, and accurate estimation of the stock return covariance matrix is ​​a crucial prerequisite for its implementation. The covariance matrix not only determines the accuracy of portfolio risk assessment but also directly affects the solution for optimal weights. With the increased availability of high-frequency trading data, the "realized covariance (RCOV) matrix" calculated based on intraday high-frequency data has become the mainstream tool replacing traditional low-frequency covariance estimation, as it can more accurately capture the volatility correlations between assets.

[0003] However, existing RCOV matrix prediction and application solutions have the following core pain points:

[0004] The curse of dimensionality and limitations of structural assumptions: Traditional statistical models (such as the conditional autoregressive Wishart model and matrix factor analysis (MFA) model) require strong assumptions about the distribution or dynamic structure of the RCOV matrix (such as following a Wishart distribution or being driven by low-dimensional factors). For example, the MFA model simplifies calculations by projecting a high-dimensional RCOV matrix onto a low-dimensional factor space, but the projection dimension is usually only 3-10, making it difficult to characterize the complex dependencies between high-dimensional assets (such as the constituent stocks of the CSI 300); moreover, the number of model parameters increases quadratically with the asset dimension, making it difficult to achieve consistent estimation in high-dimensional scenarios (such as 300 stocks).

[0005] The positive definiteness of the covariance matrix is ​​insufficient: the RCOV matrix must satisfy the symmetric positive definite property to be used for portfolio optimization (otherwise, the weight inverse matrix cannot be solved). Existing methods such as matrix logarithmic transformation and square root transformation can partially alleviate this problem, but under extreme market volatility (such as the 2015 A-share stock market crash and the 2020 COVID-19 pandemic), the prediction results may still be non-positive definite, causing portfolio optimization to fail.

[0006] Weak ability to capture spatiotemporal correlations: The stock RCOV matrix simultaneously possesses both "dynamic characteristics in the time dimension" (such as volatility clustering effects) and "local characteristics in the spatial dimension" (such as stronger correlations in the volatility of stocks within the same industry). Traditional models (such as vector autoregression (VAR) models) struggle to capture both types of correlations simultaneously, while simple convolutional neural networks (CNNs) or recurrent neural networks (RNNs) can only focus on a single dimension, resulting in limited prediction accuracy.

[0007] Insufficient market adaptability for portfolio applications: Existing covariance prediction models are mostly built based on overseas market data, which are not fully adapted to the trading hours (such as 9:30-11:30 am and 1:00-3:00 pm) and data characteristics (such as high missing rate of high-frequency data) of the Chinese stock market. Direct application can easily lead to prediction bias. In addition, some models rely too much on complex multi-factor risk adjustment, which increases the complexity and computational cost of live application.

[0008] In recent years, deep learning technology has demonstrated advantages in feature extraction and complex mapping modeling: Convolutional Bidirectional Long Short-Term Memory (ConvBiLSTM) models can simultaneously capture spatiotemporal bidirectional correlations, Graph Attention Networks (GAT) can characterize cross-sectional relationships between assets, and the Gramian regularization method can ensure matrix positive definiteness. Based on this, this invention proposes a neural network covariance prediction method that integrates the above technologies and is designed for 5-minute high-frequency data in the Chinese stock market. This method addresses the pain points of existing technologies and improves the accuracy and stability of portfolio optimization. Summary of the Invention

[0009] This invention aims to provide a covariance matrix prediction method based on neural networks. It constructs a neural network using 5-minute high-frequency data from the Chinese stock market to accurately predict the RCOV matrix and applies it to portfolio optimization to achieve a balance between risk control and returns. This addresses the shortcomings of existing methods in terms of high-dimensional adaptability, positive definiteness guarantee, spatiotemporal correlation capture, and market adaptability.

[0010] To achieve the above objectives, the present invention provides the following technical solution:

[0011] A method for predicting the covariance matrix based on a neural network includes the following steps:

[0012] A. High-frequency stock data acquisition and preprocessing:

[0013] This step extracts the effective RCOV matrix from the original high-frequency data of the Chinese stock market. Data cleaning and dual transformations ensure the positive definiteness and data fit of the subsequent prediction matrix. The specific steps are as follows:

[0014] A1. High-frequency data acquisition and filtering:

[0015] A11. Data source: Collect 5-minute high-frequency trading data of the target stock set. The data comes from the Ruisi Database and covers the stock set including the constituent stocks of the SSE 50 Index, CSI 100 Index, or CSI 300 Index.

[0016] A12. Data Dimensions and Trading Hours: Transaction price (accurate to two decimal places for each transaction), transaction volume (in shares), and transaction timestamp (accurate to the second, format "YYYY-MM-DD HH:MM:SS") every 5-minute intervals; trading hours are limited to 9:30-11:30 AM and 1:00-3:00 PM, with 48 valid 5-minute intervals per day (9:30-9:35 AM to 2:55-3:00 PM).

[0017] A13. Screening Rules: Calculate the daily data missing rate (missing rate = number of missing 5-minute intervals for a single stock on that day / 48). If the data missing rate for a single stock reaches 25% (i.e., missing 12 or more 5-minute intervals), then all data for that trading day will be removed. Stock Screening: Remove stocks with an average daily trading record of less than 100 records during the observation period (average daily trading record = total number of 5-minute level data records for a single stock on valid trading days during the observation period / number of valid trading days) to ensure data integrity. Missing Value Imputation: For trading days with less than 25% missing data, use the closing price of the previous 5-minute time interval as the closing price of the missing time interval and calculate the 5-minute logarithmic return.

[0018] A2, RCOV matrix calculation:

[0019] Based on filtered and imputed 5-minute high-frequency data, the daily RCOV matrix is ​​calculated using the realized volatility method. ( The transaction date number. The target number of shares. for (symmetric matrix), the specific steps are as follows:

[0020] A21, 5-minute logarithmic return calculation: for a single stock Calculate the number of days within the day Logarithmic returns at 5-minute intervals ,in For stocks No. Closing price at 5-minute intervals ( , (corresponding to the closing price of the previous trading day);

[0021] A22. Covariance calculation has been implemented for stocks: and The covariance has been calculated on the same day. Of these, 48 represent the number of valid 5-minute intervals per day;

[0022] A23, RCOV Matrix Construction: Integrating the realized covariances of all stock pairs to form a daily... RCOV matrix Ensure matrix symmetry (i.e.) The diagonal elements represent the realized variance of a single stock.

[0023] A3: RCOV matrix preprocessing:

[0024] Through square root transformation and Cholesky decomposition Preprocessing is performed to ensure the positive definiteness of the subsequent prediction matrix and to compress the data range. The specific steps are as follows:

[0025] A31. Square root transform: spectral decomposition ,in for Orthogonal eigenvector matrix (satisfying) , for (1-dimensional identity matrix) It is a diagonal eigenvalue matrix, and (because (For positive definite matrices); eigenvalue square root matrix construction: Construct ,in ,make sure A diagonal matrix with positive diagonal elements; calculation of the square root transformation matrix: The matrix is ​​still a symmetric positive definite matrix, and the data range is relatively large. Compression (reducing the influence of extreme eigenvalues);

[0026] A32, Cholesky decomposition: [The following is a partial translation of the original text, but the full text is incomplete Perform Cholesky decomposition ,in for A lower triangular matrix that satisfies the following lower triangular structure: ( ); diagonal elements are positive: ( Decomposition and calculation: Solving using recursive formulas Element, diagonal element Off-diagonal elements of the lower triangle ( );

[0027] A33. Preprocessing matrix definition: ... Defined as a preprocessed lower triangular matrix Only storage is required. The lower triangular elements (total) (Number of data points) to reduce data redundancy, while ensuring that subsequent inverse transformations can recover positive definite matrices;

[0028] B. Model training data construction:

[0029] The preprocessed lower triangular matrix is ​​transformed into a 3D tensor that can be input into a neural network, ensuring the temporal order and structure of the data. The specific steps are as follows:

[0030] B1. Setting the Time Window and Tensor Dimensions:

[0031] B11. Time window length: The time window length m is determined based on the performance of the validation set. Usually, m=20 (that is, using the preprocessed data of the previous 20 trading days to predict the data of the next day).

[0032] B12. Input Tensor Dimension: The input tensor dimension is... The first dimension is the time step (20 trading days), and the second and third dimensions are the rows and columns of the lower triangular matrix. ), tensor elements are The complete matrix (including the zero-padded upper triangular part, ensuring uniform dimensions).

[0033] B13, 3D Input Tensor Construction: For each trading day t ( Extract the preprocessed lower triangular matrix of the first m trading days. Stacked in chronological order to form a 3D input tensor (Semicolons indicate stacking along the time dimension).

[0034] B14. Tag Data Matching: Using the preprocessed lower triangular matrix of the (t+1)th trading day as input tensor The labels, i.e., the model needs to learn "m consecutive" Matrix → t+1 The mapping relationship of the matrix.

[0035] B2: Dataset partitioning:

[0036] B21. Splitting ratio: All data are split into three groups: 70% (training set), 10% (validation set), and 20% (test set). Sample pairs;

[0037] B22. Division Method: Strictly follow the chronological order (without disrupting the timeline), assuming a total of T valid trading days within the observation period ( Then: Training set: from arrive ,common One sample; validation set: from arrive ,common One sample; Test set: from arrive ,common One sample;

[0038] B23. Data Standardization: The 3D tensors of the training set are standardized element-wise, using the following formula: ,in The mean of all tensor elements in the training set, The standard deviation of all tensor elements in the training set; the validation and test sets use the standard deviation of the training set. and Standardize to prevent data leaks.

[0039] C. Neural Network Model Construction and Training:

[0040] This step constructs an end-to-end neural network (named CM-ConvBiLSTM), which integrates ConvBiLSTM, CNN, and Gramian positive definiteness guarantee techniques to achieve spatiotemporal bidirectional correlation extraction and accurate prediction of the RCOV matrix. The specific structure and training strategy are as follows:

[0041] C1: Overall Network Architecture Design

[0042] C11. Architecture Composition: The model consists of an encoding layer (feature extraction module), a generation layer (prediction output module), and a pooling-free layer (to avoid spatial feature loss). Zero-padding is used during training to ensure that the input and output dimensions of each layer are consistent (input is...). The output dimensions of each intermediate layer are maintained. The output of the generation layer is The data flow is as follows: 3D input tensor → encoding layer (ConvBiLSTM layer → CNN layer) → generator layer → prediction lower triangular matrix. ;

[0043] C12. Detailed design of the coding layer: The coding layer consists of one ConvBiLSTM layer and at least one CNN layer, which are used to capture spatiotemporal bidirectional correlation and enhance local structural features, respectively.

[0044] ConvBiLSTM layers (spatiotemporal bidirectional feature capture) are defined as follows: Input: 3D normalized tensor (dimension) Convolution kernel parameters: adjusted according to the asset dimension d; kernel size: taken when d=50 (SSE 50). d=100 (CSI 100) or (CSI 300) Time-based Number of cores: 4 when d=50, 16 when d=100 or d=300; Step size: Zero padding: padding size (like Core filling 1, Kernel padding 2), ensuring the output dimension matches the input; Bidirectional structure: includes a forward ConvLSTM and a backward ConvLSTM, capturing dynamic features from the "past→future" and "future→past" directions of the time series respectively, and the final output is a concatenation of bidirectional features (dimension). , (Number of nuclei in one direction); Gating mechanism: Input gate, forget gate, output gate, and cell state calculation all use convolution operations. with pointwise product The forward and backward gating parameters are trained independently; the activation function is a Leaky ReLU followed by the output hidden state, as shown in the formula. This solves the gradient vanishing problem while preserving negative feature information.

[0045] CNN Layers (Local Structure Enhancement): Number of stacks: Adjusted according to d; 1 layer for d=50, 2 layers for d=100, 3 layers for d=300; Kernel parameters: Kernel size is uniform. Number of cores: 8 for d=50, 16-32 for d=100 (16 in the first layer, 32 in the second layer), 16-32 for d=300 (16 in the first two layers, 32 in the third layer); stride and padding are the same as in ConvBiLSTM layers to ensure output dimensionality. ( (Number of kernels in the current layer); Activation function: Leaky ReLU is applied to the output of each CNN layer to achieve non-linear feature mapping and enhance the model's ability to fit complex relationships.

[0046] C13. Detailed Design of the Generation Layer: The generation layer is used to output a prediction matrix that meets the requirements of a lower triangular structure and positive definiteness. It is divided into a basic generation layer and a positive definite enhanced generation layer.

[0047] Basic generation layer: Input: Output feature map of the last layer of the encoding layer (dimension) , (Number of cores in the last layer of the coding layer).

[0048] Convolution kernel parameters: When kernel size d=50, take... When d=100 or d=300, take The number of cores is 1, ensuring that the output dimension is... The stride and padding are the same in the coding layer.

[0049] Activation function: Linear activation ( To avoid nonlinear transformations disrupting the lower triangular matrix structure; Inverse normalization: the normalized form of the output predicted lower triangular matrix. Reverse standardization Restore the original scale.

[0050] Positive definite enhancement generation layer (Gramian matrix output):

[0051] Applicable scenarios: When it is necessary to further ensure that the RCOV matrix is ​​positively timed under extreme market conditions;

[0052] Number of output neurons: One, before Each is an auxiliary matrix. The real part, after One is the imaginary part;

[0053] Auxiliary matrix construction: ( (where the imaginary unit is used)

[0054] Calculation of the regularized Gramian matrix: ,in for The conjugate transpose of . To minimize the regularization parameter, ensure Strictly positive definite;

[0055] Lower triangular matrix extraction: Performing Cholesky decomposition yields... ( (This is the decomposed lower triangular matrix).

[0056] C2. Model training strategy:

[0057] C21. Loss Function Design (Huber Loss, Outlier Resistance): Let... (Predicting elements of the lower triangular matrix) (Label elements of the lower triangular matrix), only calculate the loss for the lower triangular elements: ;

[0058] in (Total number of elements in the lower triangle) The threshold is set at 800 (800 when d=50, 2400 when d=100, and 12000 when d=300), and is determined by the performance of the validation set.

[0059] C22. Optimization Algorithm (Adam Optimizer): Parameter settings: Initial learning rate: when d=50, take... When d=100 or d=300, take Weight decay: To suppress overfitting; momentum parameter: (First-order momentum). (Second-order momentum); To avoid the denominator being zero; Learning rate scheduling: cosine annealing scheduling is used, with the learning rate adjusted according to the time interval in each round. Adjustment( (where t is the initial learning rate, t is the current round, and T is the maximum number of rounds).

[0060] C23. Regularization and Training Constraints: L1 Regularization: Adding an L1 regularization term to all convolutional kernel weights. , The regularization coefficient is taken as (when d=50). When d=100, take When d=300, take Batch size: 128 when d=50 or d=100, 64 when d=300; Training device: GPU (such as Tesla V100 SXM2, 32GB memory) is used to accelerate computation; Training termination condition: Root mean square error (RMSE) and mean absolute error (MAE) of the validation set are calculated in each round. If the RMSE of the validation set does not decrease for 5 consecutive rounds (the decrease is <1e-5), then training is stopped and the model weights with the best performance on the validation set are saved.

[0061] D. Covariance matrix prediction:

[0062] The trained CM-ConvBiLSTM model outputs the predicted RCOV matrix. The core of this process is the inverse of preprocessing, which ensures that the recovered matrix is ​​positive definite and conforms to the original scale. The specific process is as follows:

[0063] D1: Predicting Input Preparation:

[0064] D11. Data Extraction and Preprocessing: Extract the trading day to be predicted (denoted as...). RCOV matrix of the previous m trading days For each ( arrive Perform the preprocessing in step S3 (square root transformation, Cholesky decomposition) to obtain the lower triangular matrix. ;

[0065] D12. Construction and Normalization of 3D Input Tensors: Forming 3D Input Tensors by Stacking Lower Triangular Matrices (dimension) ), using the training set and Standardize to obtain ;

[0066] D2. Model Prediction and Matrix Recovery:

[0067] D21, Model Prediction: [The following text appears to be incomplete and requires further context:] Input the trained CM-ConvBiLSTM model (with the optimal weights from the validation set), and output the normalized form of the predicted lower triangular matrix. ;

[0068] D22. Inverse Standardization and Correction: After inverse standardization Restore the original scale; if There are non-diagonal elements, using Correct the settings to ensure that the diagonal elements are positive.

[0069] D3: Inverse preprocessing (recovering the positive definite RCOV matrix):

[0070] D31, Inverse operation of Cholesky decomposition: Calculation ,in The transpose of the matrix; because It is a lower triangle and its diagonal element is positive. It is a symmetric positive definite matrix;

[0071] D32. Inverse operation of square root transformation: Calculation , obtained the The prediction for the past few trading days has achieved the covariance matrix. ;

[0072] D33. Positive Determinism Verification: Calculate All eigenvalues, ensuring the minimum eigenvalue. Verify that the matrix is ​​positive definite;

[0073] E. Portfolio optimization applications:

[0074] Based on the predicted RCOV matrix By combining Markowitz mean-variance theory to construct an optimized portfolio, risk control and return balance are achieved directly through matrix positive definiteness and optimization algorithms. The specific process is as follows:

[0075] E1: Construction of Global Minimum Variance (GMV) Combination:

[0076] E11. Optimization Objective: Minimize portfolio volatility ,in Let be the stock weight vector, with the following constraints: ( for (a vector of all 1s).

[0077] E12. Solve for the optimal weights using the Lagrange multiplier method. The formula is:

[0078]

[0079] in To predict the inverse matrix of the RCOV matrix (because...) Positive definite, inverse matrix exists); matrix inversion is performed using Cholesky decomposition (first decompose...). Then solve and ,get ), to improve computational stability;

[0080] E13, Weight Normalization: If numerical errors lead to... ,pass Correction.

[0081] E2, Construction of Global Minimum Variance (GMV+) Combination with No Short Selling Constraints

[0082] E21. Constraints: Add a no-short-selling constraint to the GMV portfolio target. ( ), suitable for investment scenarios with regulatory restrictions or risk aversion;

[0083] E22, Optimizing Problem Construction:

[0084] The solution is obtained by combining convex optimization tools (such as CVXPY) with the interior point method.

[0085] E23. Sector Weighting Adjustment: If there are stocks with a weight of zero, the weight of a single sector can be limited to no more than 20% to ensure diversified sector allocation.

[0086] E3, Mean-Variance Optimization Combination Construction

[0087] E31. Optimization Objective and Constraints: Maximize the expected return of the portfolio. The expected stock return vector is calculated using the annualized average daily return over the past 12 months. The constraint is that the portfolio volatility must not exceed the target level. Typically, the volatility of the market index during the observation period is taken as 1.2 times; the total weight is 1. No short selling restrictions: ;

[0088] E32. Optimization Solution: Construct a quadratic programming problem, use the efficient set algorithm to solve it, and output the optimal return weight under the target risk.

[0089] E4: Portfolio Performance Evaluation and Rebalancing

[0090] E41. Performance Evaluation Metrics: Risk Metrics: Realized Volatility (Annualized), Maximum drawdown ( ); Return metrics: Annualized rate of return ( ), Sharpe ratio ( (The risk-free rate is taken as the yield of 10-year Chinese government bonds).

[0091] E42. Rebalancing strategy: At the end of each month, based on the latest predicted RCOV matrix (predicting the beginning of the next month from the end of the month). Adjust the weights;

[0092] E43. Transaction cost control: Set a weight adjustment threshold (no more than 5% per adjustment) to avoid excessive costs caused by high-frequency trading (transaction costs include commissions and slippage, estimated at 0.1% per transaction).

[0093] The beneficial effects of this invention are:

[0094] Strong adaptability to high dimensions: The number of parameters of the CM-ConvBiLSTM model increases linearly with d, and it can stably handle the scenario of CSI 300 constituent stocks with d=300. On the CSI 100 dataset with d=100, the prediction RMSE is lower than that of the traditional CNN model MFA model.

[0095] Positive definiteness is absolutely guaranteed: Through preprocessing of "square root transformation + Cholesky decomposition" and optional Gramian generation layer, the positive definiteness of the predicted RCOV matrix reaches 100%;

[0096] Accurate capture of spatiotemporal bidirectional correlation: The bidirectional structure of ConvBiLSTM can simultaneously capture the temporal dynamics of past-future and future-past. Combined with the local structure extraction capability of CNN, the prediction MAE on the CSI 100 dataset is lower than that of the single ConvLSTM model.

[0097] High market adaptability: The data processing flow is designed specifically for the trading hours (48 five-minute intervals) and data gap characteristics of the Chinese stock market. It directly predicts based on the RCOV matrix without relying on multi-factor adjustments, resulting in low complexity and high computational efficiency in real-world applications. Attached Figure Description

[0098] Figure 1 : Schematic diagram of the CM-ConvBiLSTM model architecture;

[0099] Figure 2 Performance of CM-ConvBiLSTM in covariance prediction of the CSI 100 Index (2010-2024);

[0100] Figure 3 GMV portfolio volatility comparison chart;

[0101] Figure 4 The extent of improvement of each risk model compared to the market;

[0102] Figure 5 : Parameter model adaptation table;

[0103] Figure 6 : Flowchart of the technical solution of this invention. Detailed Implementation

[0104] To make the above-mentioned objectives, features, and advantages of the present invention more apparent and understandable, the specific embodiments of the present invention will be described in detail below with reference to examples. The following content is merely an example and illustration of the concept of the present invention. Those skilled in the art can make various modifications or additions to the described specific embodiments or use similar methods to replace them, as long as they do not deviate from the concept of the invention, they should all fall within the protection scope of the present invention.

[0105] Taking the constituent stocks of the CSI 100 Index (d=100) as an example, the specific implementation steps of this invention are explained in detail:

[0106] A. High-frequency stock data acquisition and preprocessing:

[0107] A1. High-frequency data acquisition and filtering:

[0108] Data source: 5-minute high-frequency trading data from the Ruisi database, spanning from January 1, 2010 to December 31, 2024, totaling 3680 trading days; the target stock set consists of CSI 100 Index constituent stocks, with an initial sample of 100 stocks.

[0109] Trading hours and data dimensions: Trading hours are 9:30-11:30 AM and 1:00-3:00 PM, with 48 valid 5-minute intervals per day; data dimensions include transaction price (unit: yuan, rounded to two decimal places), trading volume (unit: shares), and transaction timestamp (format: "YYYY-MM-DD HH:MM:SS").

[0110] Screening rules: Calculate the missing data rate for each stock daily. If the missing rate is ≥25% (i.e., missing ≥12 5-minute intervals), the data for that trading day is removed. A total of 3220 valid trading days are retained. Stock screening: Stocks with fewer than 100 daily trading records during the observation period are removed, leaving 100 stocks. Missing value imputation: For trading days with a missing rate <25%, the closing price of the previous 5-minute interval is used to imput the missing data. For example, if a stock has no trading between 9:40 and 9:45, the closing price between 9:35 and 9:40 is used as the closing price for that interval.

[0111] A2. RCOV Matrix Calculation: 5-minute logarithmic return calculation: for a single stock. Calculate the first Logarithmic returns at 5-minute intervals ( ),in The closing price of the previous trading day; covariance calculation has been implemented: for stocks and Covariance was achieved on that day. ;

[0112] RCOV matrix construction: forming daily Symmetric matrix The diagonal elements represent the realized variance of a single stock.

[0113] A3: RCOV matrix preprocessing: square root transform: spectral decomposition ,in for Orthogonal eigenvector matrix, ( );structure ;calculate Cholesky decomposition: for Execution decomposition This yields the lower triangular matrix. .

[0114] B. Model training data construction:

[0115] B1. Time Window and Tensor Dimension Setting: The optimal window length m=20 was determined by testing m=10, 15, 20, and 25 on the validation set; Input tensor dimension: for each trading day... ( ), stacking the previous 20 trading days ,form 3D input tensor ; tag as ;

[0116] B2: Dataset partitioning:

[0117] Splitting ratio: All data are divided into three groups: 70% (training set), 10% (validation set), and 20% (test set). Sample pairs;

[0118] Division method: Strictly follow the chronological order (without disrupting the timeline), assuming a total of T valid trading days within the observation period ( Then: Training set: from arrive ,common One sample; validation set: from arrive ,common One sample; Test set: from arrive ,common One sample;

[0119] Training set: From 20 to A total of $2254-20+1=2235$ samples; validation set: From 2255 to A total of 2576 - 2255 + 1 = 322 samples; Test set: From 2577 to 3220-1=3219, there are a total of 3219-2577+1=643 samples;

[0120] Data standardization: Calculate the mean of the tensor elements in the training set. Standard deviation Perform on all tensors .

[0121] C. Neural Network Model Construction and Training:

[0122] Overall network architecture design:

[0123] A 4-layer CM-ConvBiLSTM model is used: ConvBiLSTM layer: convolutional kernel Number of elements: 16 (8 forward + 8 backward), zero-padding 2, Leaky ReLU activation; CNN layers (2 layers): Layer 1 Core, 16, zero-fill 1; second layer Cores: 32, zero-filling: 1; Generation layer: One kernel, linear activation; training parameters: loss function: Huber loss. Optimizer: Initial learning rate Weight decay , , Regularization: L1 regularization coefficient Training configuration: batch size 128, GPU (Tesla V100) training, early stopping strategy (stop if the RMSE on the validation set does not decrease for 5 consecutive rounds);

[0124] Model training strategy: Training process: Training rounds: 92 rounds (the validation set RMSE did not decrease for 5 consecutive rounds after round 92); Loss convergence: Initial round (round 1): training loss 228.3, validation RMSE 40.5; Intermediate round (round 50): training loss 42.8, validation RMSE 17.6; Optimal round (round 92): training loss 29.5, validation RMSE 14.2; Model saving: Save the model weights from round 92.

[0125] D. Covariance matrix prediction

[0126] Prediction input preparation: For each day to be predicted in the test set Extract the previous 20 trading days Preprocessing yields , build Tensor and standardize;

[0127] Model prediction and matrix recovery:

[0128] Input model to obtain Reverse standardization Correct 8 non-diagonal elements (set as follows) );calculate , ;

[0129] Positive definiteness verification: The range of the smallest eigenvalue of the prediction matrix is All satisfy The positive definiteness rate is 100%.

[0130] E. Portfolio Optimization Applications

[0131] GMV Combination Construction: Weight Calculation: The inverse of Cholesky decomposition was used; performance test (test period 2018-2024): annualized return 11.5%, annualized volatility 10.8%, Sharpe ratio 1.6 (risk-free rate 2.5%), maximum drawdown 16.8% (lower than the CSI 100 index 21.2%).

[0132] Rebalancing and cost control: Weights are adjusted at the end of each month, with a single transaction cost of 0.07%, an annualized turnover rate of 195%, and a Sharpe ratio of 1.56 after deducting costs.

[0133] Figure 1 : CM-ConvBiLSTM model architecture diagram: This diagram illustrates the end-to-end architecture of the CM-ConvBiLSTM model of this invention, showing the data flow of "input → encoding → generation → prediction";

[0134] Figure 2 The covariance prediction performance of CM-ConvBiLSTM on the CSI 100 Index (2010-2024) shows that during the 2015 stock market crash, the peak RMSE of CM-ConvBiLSTM was significantly lower than that of traditional methods. The structural advantage of adapting to extreme fluctuations in A-shares continued to be reflected in events such as the 2020 pandemic and the 2016 circuit breaker. After the full implementation of the registration system in 2023, the model error showed a significant downward trend, reflecting its adaptability to the new market environment.

[0135] Figure 3 The GMV portfolio volatility comparison chart shows that CM-ConvBiLSTM is 18.2% higher than the traditional model, GMV portfolio volatility is 11.6%, and GMV+ portfolio volatility is 12.3%, all lower than the traditional model and the market benchmark. The red border in the chart marks this model as the best in each indicator.

[0136] Figure 4 The improvement of various risk models compared to the market shows that the CM-ConvBiLSTM model of this invention has an improvement of 66.4%, which is 37.0% higher than the traditional CNN model and 12.0% higher than the BC-GARCH model, intuitively demonstrating its technical advantages in risk prediction and portfolio optimization.

[0137] Figure 5 Parameter Model Adaptation Table: Presents the adaptation scheme of model parameters to the target stock set (asset dimension d). The table columns include "Target Stock Set", "Asset Dimension d", "Number of Network Layers", "ConvBiLSTM Parameters (Kernel Size / Number)", "CNN Parameters (Number of Layers / Number of Kernels)", "Generation Layer Kernel Size", "Batch Size", "Regularization Coefficient", and "Huber Threshold".

[0138] Figure 6 The flowchart of the technical solution of this invention includes five main technical modules.

Claims

1. A neural network-based covariance matrix prediction method, characterized by, Comprising the following steps: A. Stock high-frequency data collection and preprocessing: A1. High-frequency data collection and screening: A11. Data source: collect 5-minute-level high-frequency trading data of the target stock set, the data is from the Rices database, and the stock set covers the constituent stocks of the Shanghai 50 Index, the constituent stocks of the Zhongzheng 100 Index, or the constituent stocks of the Shanghai-Shenzhen 300 Index; A12. Data dimensions and trading time period: every 5-minute interval of transaction price, transaction volume, and transaction timestamp; the trading time is limited to 9:30-11:30 am and 13:00-15:00 pm, and there are 48 valid 5-minute intervals per day; A13. Screening rules: calculate the daily data missing rate, missing rate = number of missing 5-minute intervals of a single stock on a day / 48, if the data missing rate of a single stock reaches 25%, the data of the whole trading day is excluded; Stock screening: exclude stocks with less than 100 daily transaction records during the observation period to ensure data integrity; Missing value filling: for trading days with less than 25% data missing, use the closing price of the previous 5-minute period as the closing price of the missing period to calculate the 5-minute log return; A2. RCOV matrix calculation: A21, 5-minute log return calculation: for individual stocks , compute the log returns for each of the 5-minute intervals within a day , where is the closing price for the stock at the 5-minute interval A22. Covariance calculation realized: for stocks With , compute daily realized covariance where 48 is the number of daily effective 5-minute intervals; A23. RCOV matrix construction: integrate realized covariances of all stock pairs to form a daily RCOV matrix , ensuring matrix symmetry, diagonal elements are realized variances of individual stocks; A3: RCOV matrix preprocessing: square root transformation and Cholesky decomposition; B. Model training data construction; C. Neural network model construction and training; D. Covariance matrix prediction.

2. The neural network-based covariance matrix prediction method of claim 1, wherein, The square root transformation procedure described in step A3 is: spectral decomposition where is an orthogonal eigenvector matrix, is a diagonal eigenvalue matrix, and ; Eigenvalue square root matrix construction: construct where , ensure is a diagonal matrix with positive diagonal elements; square root transformation matrix calculation: The matrix is still a symmetric positive definite matrix, and the data range is compression. 3.The neural-network-based covariance matrix prediction method of claim 1, wherein, The Cholesky decomposition procedure described in step A3 is: Perform Cholesky decomposition where is a lower triangular matrix satisfying: lower triangular structure: ( ); positive diagonal elements: ( ) decomposition calculation: solve the elements by recursive formula , diagonal elements , lower triangular off-diagonal elements ( ).

4. The neural network-based covariance matrix prediction method of claim 1, wherein, The model training data construction in step B comprises the following steps: B1. Time window and tensor dimension setting: B11. Time window length: determine the time window length m based on the performance of the validation set, usually m = 20; B12, input tensor dimensions: input tensor dimensions are where the first dimension is the time step, the second and third dimensions are the row, column of the lower triangular matrix, and the tensor element is the full matrix; B13, 3D input tensor construction: for each trading day t, extract the pre-processed lower triangular matrix of the previous m trading days , stack in chronological order to form a 3D input tensor ; B14, label data matching: with the pre-processed lower triangular matrix of the t+1th trading day as the input tensor of the label, i.e. the model needs to learn the mapping relationship of "m consecutive matrices → the t+1th matrix"; B2: Data set division: B21, the proportion of division: according to the proportion of training set 70%, validation set 10%, test set 20% to divide all sample pairs; B22. Division method: strictly follow the time sequence order; B23. Data standardization: element-wise standardization of the 3D tensors of the training set, formula where is the mean of all tensor elements of the training set, is the standard deviation of all tensor elements of the training set; the validation and test sets are standardized using the and of the training set to avoid data leakage.

5. The neural network-based covariance matrix prediction method of claim 1, wherein, The neural network model construction and training in step C comprises the following steps: C1: Network overall architecture design: C11, architecture composition: the model is divided into an encoding layer and a generation layer, without a pooling layer, and zero padding is used in training to ensure that the input and output dimensions of each layer are consistent; the data flow direction is: 3D input tensor→encoding layer→generation layer→predicted lower triangular matrix ; C12. Detailed design of the encoding layer: the encoding layer contains 1 ConvBiLSTM layer and at least 1 CNN layer, which are respectively used to capture the spatio-temporal correlation and strengthen the local structure features; C13. Detailed design of the generation layer: the generation layer is used to output the predicted matrix that meets the requirements of lower triangular structure and positive definiteness, and is divided into a basic generation layer and a positive definite enhancement generation layer: C2. Model training strategy: C21. Loss function design: Let , , loss of only the lower triangular elements is calculated: wherein , is a threshold value determined by the validation set performance; C22. Optimization Algorithm: Parameter settings: Initial learning rate: when d=50, take... When d=100 or d=300, take Weight decay: To suppress overfitting; momentum parameter: , ; To avoid the denominator being zero; Learning rate scheduling: cosine annealing scheduling is used, with the learning rate adjusted according to the time interval in each round. Adjustment; C23, Regularization and training constraints: L1 regularization: add L1 regularization term to all convolution kernel weights , is the regularization coefficient; batch size: 128 when d = 50 or d = 100, and 64 when d = 300; training device: GPU acceleration calculation is adopted; training termination condition: the root mean square error and the mean absolute error of the validation set are calculated every round, if the validation set RMSE does not decrease for 5 consecutive rounds, the training is stopped, and the model weight with the optimal validation set performance is saved.

6. The neural-network-based covariance matrix prediction method of claim 1, wherein, The covariance matrix prediction in step D, Comprises the following steps: D1: Prediction input preparation: D11, data extraction and preprocessing: taking the RCOV matrix of the m trading days before the predicted trading day ; for each performing the preprocessing of step S3 to obtain a lower triangular matrix ; D12, 3D input tensor construction and standardization: stack lower triangular matrix to form 3D input tensor , standardization is performed using the training set and to obtain ; D2. Model prediction and matrix recovery: D21, model prediction: input the trained CM-ConvBiLSTM model, output the normalized form of the lower triangular matrix input the trained CM-ConvBiLSTM model, output the normalized form of the lower triangular matrix ; D22, inverse normalization and correction: inverse normalized restore original scale; if non-positive diagonal elements exist, use correction, ensure positive diagonal elements; D3: Inverse preprocessing: D31, Cholesky factorization inverse operation: compute where is the transpose of is lower triangular with positive diagonal elements, is symmetric positive definite. D32, inverse operation of square root transformation: calculate , to obtain the predicted realized covariance matrix of the first transaction day D33, positive definiteness verification: compute all eigenvalues of , ensure the smallest eigenvalue , verify that the matrix is positive definite.