Risk intelligent assessment and asset allocation optimization method for quant trading

CN122798537APending Publication Date: 2026-09-22SICHUAN UNIV
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202610873819.1
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2026-06-17
Publication Date
2026-09-22

AI Technical Summary

Technical Problem

[0007]因此,本发明的目的是提供面向量化交易的风险智能评估与资产配置优化方法,通过对现有的量化交易的风险评估与资产配置方法进行改进,能够解决上述提出现有技术中现有的量化交易的风险评估与资产配置方法的不足之处在于,仅使用单一行情数据,缺少资金流、市场微观结构、基本面、舆情等多源信息,特征覆盖不全,风险预判不准,风险指标多为静态固定值,无法根据市场变化自适应调整,极端行情下风控容易失效的问题

Benefits of technology

[0027]1、本发明中,通过Transformer自注意力机制实现并行化全局时序建模,从根本上消除长序列中的梯度衰减与信息遗忘,精准捕捉资产波动在宏观周期尺度上的超长程关联性,使得风险识别更早、更灵敏;通过HMM对市场隐含状态进行无监督概率建模,以状态转移概率动态识别市场风格切换,避免固定阈值逻辑的滞后性,自适应权重平滑过渡,适配各种市场状态,极端行情更安全,通过风险等级自动生成梯度约束,使得风险越高约束越严,从源头控制仓位与回撤。

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN122798537A_ABST
    Figure CN122798537A_ABST
Patent Text Reader

Abstract

This invention belongs to the field of quantitative trading technology, specifically a method for intelligent risk assessment and asset allocation optimization in quantitative trading. This optimization method includes the following steps: Step 1, collecting multi-source heterogeneous data required for quantitative trading; Step 4, automatically generating corresponding dynamic constraints based on different risk levels; Step 5, using the maximization of expected portfolio returns and minimization of overall risk as dual optimization objectives; Step 7, establishing a real-time closed-loop risk control and iteration mechanism. The beneficial effects of this invention are: fundamentally eliminating gradient decay and information forgetting in long sequences, accurately capturing the ultra-long-range correlation of asset fluctuations on a macro-cycle scale, making risk identification earlier and more sensitive, adapting to weight smooth transitions, adapting to various market conditions, making extreme market conditions safer, and automatically generating gradient constraints through risk levels, making the constraints stricter the higher the risk, controlling position size and drawdown from the source.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of quantitative trading technology, specifically to a method for intelligent risk assessment and asset allocation optimization in quantitative trading. Background Technology

[0002] Quantitative trading refers to a modern investment approach that uses mathematical models, data statistics, and artificial intelligence algorithms to analyze multi-dimensional data such as market conditions, capital flows, and fundamentals, and automatically completes trading decisions, order execution, and risk control. It is characterized by strong discipline, fast execution speed, and wide coverage.

[0003] Risk assessment and asset allocation in quantitative trading are the core components of a quantitative investment system for controlling drawdowns, ensuring returns, and maintaining stable operation. Risk assessment uses data and algorithms to calculate and warn of potential risks such as market volatility, liquidity, concentration, and model failure in real time. Asset allocation automatically optimizes the holding weights of different assets based on risk levels and return objectives. The combination of these two approaches ensures that risks are measurable, controllable, and bearable, and pursues stable returns under risk constraints. This is a key guarantee for the long-term live operation of quantitative strategies.

[0004] However, existing quantitative trading risk assessment and asset allocation methods are inadequate in that they rely solely on single market data, lacking multi-source information such as capital flows, market microstructure, fundamentals, and public opinion, resulting in incomplete feature coverage and inaccurate risk prediction. Transaction cost constraints are mostly given in the form of fixed proportions or static upper limits, not linked to the depth of the live order book, failing to reflect the amplified slippage and market shock caused by a sudden drop in liquidity under extreme market conditions, and the optimization results carry the risk of "paper wealth." The interpretability of the model is limited to simple feature importance ranking, lacking rigorous quantitative attribution of the marginal contribution of each factor in a single decision, and does not meet the regulatory audit requirements for algorithm transparency.

[0005] To this end, we propose a method for intelligent risk assessment and asset allocation optimization for quantitative trading. Summary of the Invention

[0006] In view of the problems existing in the above and / or existing methods for risk intelligent assessment and asset allocation optimization for quantitative trading, this invention is proposed.

[0007] Therefore, the purpose of this invention is to provide a method for intelligent risk assessment and asset allocation optimization in quantitative trading. By improving existing methods for risk assessment and asset allocation in quantitative trading, this invention addresses the shortcomings of existing methods, such as using only single market data, lacking multi-source information including capital flow, market microstructure, fundamentals, and public opinion, having incomplete feature coverage, inaccurate risk prediction, and using mostly static fixed values ​​for risk indicators that cannot adaptively adjust to market changes, leading to risk control failure under extreme market conditions.

[0008] To address the aforementioned technical problems, according to one aspect of the present invention, the present invention provides the following technical solution:

[0009] A risk intelligent assessment and asset allocation optimization method for quantitative trading, which includes the following steps:

[0010] Step 1: Collect multi-source heterogeneous data required for quantitative trading. This data includes market data, fund flow data, market microstructure data, fundamental data, and public opinion data. The collected raw data undergoes missing value imputation, noise filtering, time alignment, numerical normalization, and outlier removal to obtain a standardized, usable dataset. From this standardized dataset, short-term, medium-term, and long-term time-series features, as well as microstructure features such as order book, volatility, and bid-ask spread, are extracted. These features are then filtered and cross-fused to form a high-dimensional feature vector for model input. Simultaneously, Level-2 order book snapshots are maintained in real-time to provide a liquidity depth data foundation for subsequent dynamic slippage and market impact cost modeling.

[0011] Step 2: Construct a Transformer time series risk prediction model based on a multi-head self-attention mechanism. The high-dimensional feature vector obtained in Step 1 is superimposed with the sine-cosine position code and then input into the model for training and prediction. The self-attention layer directly models the dependency relationship between any position in the sequence in a parallel manner, and outputs the volatility value, future drawdown probability, and extreme market risk probability for each asset.

[0012] Step 3: Based on the prediction results of Step 2, conduct dynamic multidimensional risk intelligent assessment, and simultaneously calculate dynamic VaR value, dynamic CVaR value, liquidity risk value, model drift risk value, and asset concentration risk value; construct a market state unsupervised identification module based on Hidden Markov Model (HMM), take multidimensional market observation sequence as input, and infer the posterior probability distribution of the current implicit state (bull market, bear market, sideways market) through forward-backward algorithm, dynamically adjust the adaptive weighting weights of the five types of risks based on the state probability, obtain a comprehensive risk score, and divide the risk into three levels: low, medium, and high according to the score;

[0013] Step 4: Automatically generate corresponding dynamic constraints based on different risk levels. The dynamic transaction cost tolerance limit is linked to the current market order book depth. The higher the risk level, the stricter the constraints. The dynamic constraints include the dynamic maximum drawdown threshold, single asset holding limit, industry concentration limit, dynamic turnover rate limit, and dynamic transaction cost tolerance limit. Different constraint parameters are used for different risk levels. The higher the risk level, the stricter the constraints.

[0014] Step 5: With the dual optimization objectives of maximizing the expected return of the asset portfolio and minimizing the overall risk, multiple constraints are added, including a total weight of 1, a single asset weight greater than or equal to 0, a maximum drawdown not exceeding a threshold, a turnover rate not exceeding a threshold, and transaction costs not exceeding a threshold. The calculation of transaction costs is based on a dynamic slippage model of order book depth and a market impact cost model. The deviation between the expected average transaction price and the actual order price of a single transaction is quantified as a function of the order volume at each price level, so that the constraints are truly linked to the current market micro-liquidity. The non-dominated sorting genetic algorithm with an elitist strategy, namely the NSGA-II algorithm, is used to solve the problem to obtain the Pareto optimal weighted portfolio of asset allocation that meets the constraints.

[0015] Step 6: Perform backtesting and verification on the optimal weight combination obtained in Step 5 (where the transaction cost of each simulated transaction is recalculated based on the historical order book replay data at the corresponding time of the trading day to ensure that the backtesting returns are consistent with the live trading logic), stress testing, and overfitting detection. If the verification fails, the features or model parameters are automatically corrected, and the process returns to Step 4 to re-execute constraint generation and configuration optimization. If the verification passes, proceed to the next step.

[0016] Step 7: Establish a real-time closed-loop risk control and iteration mechanism to continuously monitor the comprehensive risk score obtained in Step 3. When the score exceeds the dynamically set risk control threshold, perform weight reduction, position reduction, empty position, or hedging operations according to the mild, moderate, and severe exceedance levels, respectively. After controlling the risk, re-collect data and update the model parameters and HMM state transition matrix at fixed intervals to complete the adaptive iteration of the entire method. Finally, output the optimal asset allocation weight, various risk indicators, and a fully quantitative and interpretable attribution report based on SHAP values ​​to accurately capture the long-term correlation of asset volatility, making risk identification earlier and more sensitive.

[0017] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the three types of time series features in step one—short-cycle, medium-cycle, and long-cycle—correspond to high-frequency features of 1 minute to 5 minutes, medium-frequency features of 15 minutes to 1 hour, and low-frequency features of 4 hours to daily lines, respectively. Short-cycle features are used to capture instantaneous fluctuations and abnormal shocks, medium-cycle features are used to identify trend strength and reversal signals, and long-cycle features are used to judge the overall market structure and style. The three types of features are combined through feature splicing, cross-feature generation, and weighted fusion to form a unified vector, which is then superimposed with sine-cosine position encoding and used as the input of the Transformer model, so that the model has both high-frequency sensitivity and low-frequency stability.

[0018] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the Transformer time-series risk prediction model based on a multi-head self-attention mechanism described in step two consists of an input embedding layer, N stacked Transformer encoder blocks, and an output prediction head; each Transformer encoder block includes: a multi-head self-attention sublayer—mapping the input to the Query, Key, and Value spaces through h different linear projections, calculating the attention weights of each head in parallel, and concatenating the output; a feedforward fully connected sublayer—two fully connected networks plus the GELU activation function; each All sub-layers employ residual connections and layer normalization; the self-attention mechanism calculates the attention weights between any two time steps in the sequence, allowing each output position to directly access all positions in the entire input sequence, with the information transmission path length always being O(1), fundamentally eliminating the gradient decay and long-distance information forgetting problems caused by recursive propagation in traditional LSTM; the multi-head attention is computed in parallel through h different projection spaces, enabling the model to simultaneously focus on different types of time-dependent patterns such as short-term shocks, medium-term trends, and long-term cycles; the model output includes future volatility predictions, the probability of maximum drawdown within a range, and the probability of extreme market risks, achieving multi-dimensional and forward-looking risk prediction.

[0019] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the unsupervised market state identification module based on Hidden Markov Model (HMM) in step three treats the actual market operating state as an unobservable latent variable, and models the latent state as three discrete states—bull market, bear market, and sideways market; multidimensional observable market indicator sequences are used as observation variables; model parameters include initial state distribution π, state transition matrix A, and emission probability matrix B, which are unsupervised estimated on historical data using the Baum-Welch algorithm; during online operation, the posterior probability of each latent state at the current moment is recursively calculated using a forward-backward algorithm, and the state corresponding to the maximum posterior probability is used as the determination result of the current market state; when the market is in a state transition period, i.e., the maximum posterior probability is lower than a preset threshold, the risk weight is adjusted by a soft fusion method of weighted average of each state weight according to the posterior probability, so as to achieve a smooth weight transition and avoid the lag and frequent jumps of traditional fixed threshold logic at style switching points.

[0020] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the dynamic constraints in step four employ a gradient constraint strategy based on three risk levels: low, medium, and high. The low-risk level adopts a lenient constraint, allowing for higher positions and higher turnover rates; the medium-risk level adopts a standard constraint to maintain a balance between returns and risks; and the high-risk level adopts a strict constraint, forcibly reducing the upper limit of single assets, reducing total positions, and strictly controlling costs. The constraint parameters are adjusted linearly in real time with the risk score, rather than being fixed thresholds, thus achieving precise synchronization between risk and constraints.

[0021] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the NSGA-II algorithm in step five introduces an elite retention strategy and an adaptive crossover mutation mechanism to accelerate convergence and avoid local optima, outputting multiple Pareto optimal solutions corresponding to three allocation styles: aggressive, balanced, and robust. The algorithm simultaneously satisfies six hard constraints: a weight sum of 1, non-negative single asset, maximum drawdown threshold, upper limit of industry concentration, upper limit of turnover rate, and upper limit of transaction cost. The transaction cost used in the NSGA-II algorithm is the sum of dynamic slippage cost based on order book depth and market impact cost based on the Almgren-Chriss framework. Slippage cost is calculated by consuming the weighted average price of each order in the Level-2 order book. Impact cost is decomposed into an instantaneous impact term (proportional to the square root of the order volume) and a permanent impact term (proportional to the order volume). The parameters are calibrated through regression of historical trading data, so that the feasibility of live trading is considered in the generation stage of the allocation scheme.

[0022] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the backtesting verification, stress testing, and overfitting detection in step six adopt a three-stage joint judgment standard. The backtesting verification is used to verify the historical returns, Sharpe ratio, and maximum drawdown stability over multiple periods. The stress testing is used to simulate extreme scenarios such as crashes, liquidity shortages, and consecutive limit-up / limit-down days. The overfitting detection is judged by the difference between in-sample and out-of-sample returns. The allocation scheme is allowed to take effect only if all three indicators meet the criteria. If any one of them fails to meet the criteria, it is deemed invalid.

[0023] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the automatic correction parameters in step six include six key parameters: feature screening threshold, number of Transformer encoder layers, number of attention heads, model learning rate, risk weighting coefficient, and optimization algorithm population size. The correction rule is to adjust the parameters corresponding to the items that fail the verification in a targeted manner, without blindly modifying the global parameters. After the correction is completed, the system directly jumps to step four to regenerate constraints and optimize, forming an automatic error correction-iterative optimization closed loop, thereby improving the reliability of the solution.

[0024] As a preferred embodiment of the intelligent risk assessment and asset allocation optimization method for quantitative trading described in this invention, the real-time closed-loop risk control and iteration mechanism in step seven supports automatic updates at three levels: daily, weekly, and monthly. The daily level is used for rapid risk response and rebalancing, the weekly level is used for adjusting allocation weights, and the monthly level is used for comprehensive model retraining. When the comprehensive risk score triggers the threshold, it is executed in stages: mild → weight reduction, moderate → position reduction, and severe → empty position or hedging, so as to achieve early detection, early control, and early resolution of risks.

[0025] As a preferred embodiment of the risk intelligent assessment and asset allocation optimization method for quantitative trading described in this invention, the fully quantitative interpretable attribution report based on SHAP values ​​described in step seven is based on the Shapley value in cooperative game theory. Each risk prediction is considered as the result of a cooperative game involving multiple input factors. The Shapley value of each factor is defined as the weighted average of its marginal contribution to the prediction result when added to all possible factor subsets, possessing three strict mathematical properties: additivity, consistency, and missingness. The report includes three parts: feature SHAP value ranking—showing the strength and direction of the marginal impact of each factor; positive SHAP values ​​increase risk, while negative SHAP values ​​decrease risk; risk source attribution distribution—decomposing the risk score according to SHAP to market conditions / capital flows / microstructure / fundamentals / public opinion; and return contribution decomposition—quantifying the marginal contribution of each asset and factor to the portfolio's return and risk. The report can be directly used for strategy review, compliance audit, regulatory reporting, and as a basis for manual intervention, transforming the quantitative model from a black box to a white box.

[0026] Compared with the prior art, the beneficial effects achieved by the present invention are:

[0027] 1. In this invention, parallel global temporal modeling is achieved through the Transformer self-attention mechanism, which fundamentally eliminates gradient decay and information forgetting in long sequences, accurately captures the ultra-long-range correlation of asset fluctuations on a macro-cycle scale, and makes risk identification earlier and more sensitive. Unsupervised probabilistic modeling of the market's implicit state is performed through HMM, and market style switching is dynamically identified by state transition probability, avoiding the lag of fixed threshold logic, adaptive weight smooth transition, adapting to various market states, and making extreme market conditions safer. Gradient constraints are automatically generated through risk level, so that the higher the risk, the stricter the constraint, controlling position and drawdown from the source.

[0028] 2. In this invention, the NSGA-II dual-objective optimization with an elite strategy achieves a better balance between returns and risks, allowing for direct implementation of the configuration scheme. A triple verification mechanism eliminates overfitting and unstable schemes, making live trading more reliable. Automatic parameter correction and closed-loop iteration ensure the strategy's long-term effectiveness without frequent manual intervention. By using a dynamic slippage model based on order book depth and a market impact cost model, transaction cost constraints are linked to live liquidity depth, eliminating "paper wealth" caused by liquidity depletion in extreme market conditions. The configuration scheme is executable in live trading.

[0029] 3. In this invention, through tiered risk control, positions can be quickly reduced and hedged when risks occur, significantly reducing drawdowns. Through full-quantitative attribution analysis based on SHAP values, and based on the Shapley value principle of cooperative game theory, the marginal contribution of each factor—market conditions, capital flow, microstructure, fundamentals, and public opinion—to a single risk decision is accurately quantified. This transforms the model from a black box into an auditable and traceable white box, meeting the needs of review, compliance, and regulation. Through full-process automation and strong versatility, this quantitative trading risk intelligent assessment and asset allocation optimization method is applicable to multiple categories of quantitative trading. Attached Figure Description

[0030] Figure 1 This is a schematic diagram of the optimization method of the present invention;

[0031] Figure 2 This is a schematic diagram of feature fusion according to the present invention;

[0032] Figure 3 This is a schematic diagram of the Transformer self-attention risk prediction method of the present invention;

[0033] Figure 4 This is a schematic diagram illustrating the dynamic slip point and impact cost constraints of the present invention;

[0034] Figure 5This is a schematic diagram of the dual optimization objectives of the present invention. Detailed Implementation

[0035] To make the objectives, technical solutions, and advantages of the present invention clearer, the embodiments of the present invention will be described in further detail below with reference to the accompanying drawings.

[0036] This invention provides a method for intelligent risk assessment and asset allocation optimization in quantitative trading. It features parallel global time series modeling through the Transformer self-attention mechanism, fundamentally eliminating gradient decay and information forgetting in long sequences, accurately capturing the ultra-long-range correlation of asset fluctuations on a macro-cycle scale, and enabling earlier and more sensitive risk identification. It uses HMM to perform unsupervised probabilistic modeling of the market's implicit state, dynamically identifying market style switching with state transition probabilities, avoiding the lag of fixed threshold logic, and adaptively smoothing weight transitions to adapt to various market conditions, making it safer in extreme market conditions. It also automatically generates gradient constraints through risk levels, making the constraints stricter as the risk increases, thus controlling position size and drawdown from the source.

[0037] Please see Figure 1-5 A risk intelligent assessment and asset allocation optimization method for quantitative trading, which includes the following steps:

[0038] Step 1: Collect multi-source heterogeneous data required for quantitative trading. This data includes market data, fund flow data, market microstructure data, fundamental data, and public opinion data. The collected raw data undergoes missing value imputation, noise filtering, time alignment, numerical normalization, and outlier removal to obtain a standardized, usable dataset. From this standardized dataset, short-term, medium-term, and long-term time-series features, as well as microstructure features such as order book, volatility, and bid-ask spreads, are extracted. These features are then filtered and cross-fused to form a high-dimensional feature vector for model input. Simultaneously, Level-2 order book snapshots are maintained in real-time to provide a liquidity depth data foundation for subsequent dynamic slippage and market impact cost modeling. Step 2: Construct a Transformer time-series risk prediction model based on a long-only self-attention mechanism. The high-dimensional feature vector obtained in Step 1 will be used to... The feature vector and sine-cosine positional encoding are superimposed and input into the model for training and prediction. The dependency relationship between any position in the sequence is directly modeled in a parallel manner through a self-attention layer, and the volatility value, future drawdown probability, and extreme market risk probability are output for each asset. Step 3: Based on the prediction results of step 2, dynamic multidimensional risk intelligent assessment is performed, and dynamic VaR value, dynamic CVaR value, liquidity risk value, model drift risk value, and asset concentration risk value are calculated. An unsupervised market state identification module based on Hidden Markov Model (HMM) is constructed. Taking the multidimensional market observation sequence as input, the forward-backward algorithm is used to infer the posterior probability distribution of the current hidden state (bull market, bear market, sideways market). The adaptive weighting weights of the five types of risks are dynamically adjusted based on the state probability to obtain a comprehensive risk score and classify the risk into three levels: low, medium, and high.

[0039] Step 4: Automatically generate corresponding dynamic constraints based on different risk levels. The dynamic transaction cost tolerance limit is linked to the current market order book depth; the higher the risk level, the stricter the constraints. Dynamic constraints include the dynamic maximum drawdown threshold, single asset holding limit, industry concentration limit, dynamic turnover rate limit, and dynamic transaction cost tolerance limit. Different constraint parameters are used for different risk levels, with higher risk levels resulting in stricter constraints. Step 5: With the dual optimization objectives of maximizing the expected return of the asset portfolio and minimizing the overall risk, multiple constraints are added, including a total weight of 1, a single asset weight greater than or equal to 0, maximum drawdown not exceeding the threshold, turnover rate not exceeding the threshold, and transaction costs not exceeding the threshold. The calculation of transaction costs is based on the dynamic slippage model of order book depth and the market impact cost model. The deviation between the expected average transaction price and the actual order price of a single transaction is quantified as a function of the order volume at each price level, making the constraints truly linked to the current market micro-liquidity. The non-dominated sorting genetic algorithm with an elitist strategy, i.e., the NSGA-II algorithm, is used to solve the problem, obtaining the Pareto optimal weighted combination of asset allocation that satisfies the constraints.

[0040] Step Six: Perform backtesting and verification on the optimal weight combination obtained in Step Five (where the transaction cost of each simulated transaction is recalculated based on the historical order book replay data at the corresponding time of the trading day to re-calculate slippage and impact costs, ensuring that the backtesting returns are consistent with the live trading logic), stress testing, and overfitting detection. If the verification fails, automatically correct the features or model parameters and return to Step Four to re-execute constraint generation and configuration optimization. If the verification passes, proceed to the next step. Step Seven: Establish a real-time closed-loop risk control and iteration mechanism to continuously monitor the comprehensive risk score obtained in Step Three. When the score exceeds the dynamically set risk control threshold, execute weight reduction, position reduction, empty position, or hedging operations according to the mild, moderate, and severe exceedance levels, respectively. After controlling the risk, re-collect data and update the model parameters and HMM state transition matrix at fixed intervals to complete the adaptive transformation of the entire method. The process iterates and ultimately outputs optimal asset allocation weights, various risk indicators, and a fully quantifiable and explainable attribution report based on SHAP values. This accurately captures the long-range correlations of asset volatility, enabling earlier and more sensitive risk identification. Parallel global time-series modeling is achieved through the Transformer self-attention mechanism, fundamentally eliminating gradient decay and information forgetting in long sequences. This accurately captures the long-range correlations of asset volatility on a macro-cycle scale, making risk identification earlier and more sensitive. Unsupervised probabilistic modeling of the market's implicit state is performed using HMM, dynamically identifying market style switching based on state transition probabilities. This avoids the lag of fixed threshold logic, allows for smooth transitions in adaptive weights, adapts to various market conditions, and is safer in extreme market conditions. Gradient constraints are automatically generated based on risk levels, making the constraints stricter as the risk increases, controlling position size and drawdowns from the source.

[0041] In step one, the three types of time-series features—short-term, medium-term, and long-term—correspond to high-frequency features (1-5 minutes), medium-frequency features (15-1 hour), and low-frequency features (4-hour to daily), respectively. Short-term features capture instantaneous fluctuations and abnormal shocks, medium-term features identify trend strength and reversal signals, and long-term features determine the overall market structure and style. These three types of features are combined through feature concatenation, cross-feature generation, and weighted fusion to form a unified vector, which is then superimposed with sine-cosine positional encoding and used as input to the Transformer model, enabling the model to possess both high-frequency sensitivity and low-frequency stability. Step two involves a Transformer model based on a long-term self-attention mechanism. The ER time-series risk prediction model consists of an input embedding layer, N stacked Transformer encoder blocks, and an output prediction head. Each Transformer encoder block includes: a multi-head self-attention sublayer—mapping the input to the Query, Key, and Value spaces through h different linear projections, calculating the attention weights of each head in parallel, and concatenating the output; a feedforward fully connected sublayer—two fully connected networks with the GELU activation function; each sublayer employs residual connections and layer normalization; the self-attention mechanism calculates the attention weights between any two time steps in the sequence, allowing each output position to directly access all positions in the entire input sequence, facilitating information transfer. The path length is always O(1), fundamentally eliminating the gradient decay and long-distance information forgetting problems caused by recursive propagation in traditional LSTM; the bullish attention is computed in parallel through h groups of different projection spaces, enabling the model to simultaneously focus on different types of time-dependent patterns such as short-term shocks, medium-term trends, and long-term cycles; the model output includes future volatility prediction, maximum drawdown probability within the range, and extreme market risk probability, achieving multi-dimensional and forward-looking risk prediction; the unsupervised market state identification module based on the Hidden Markov Model (HMM) in step three treats the actual market operating state as an unobservable latent variable, and models the latent state as three discrete states—bull market, bear market, and oscillation. The model uses a series of multidimensional observable market indicators as observed variables. Model parameters include the initial state distribution π, the state transition matrix A, and the emission probability matrix B, which are estimated unsupervised on historical data using the Baum-Welch algorithm. During online execution, the posterior probability of each hidden state at the current moment is recursively calculated using a forward-backward algorithm, and the state corresponding to the maximum posterior probability is used as the determination of the current market state. When the market is in a state transition period, i.e., the maximum posterior probability is lower than a preset threshold, a soft fusion method is adopted to adjust the risk weights by weighting each state weight according to the posterior probability, achieving a smooth weight transition and avoiding the lag and frequent jumps at style switching points in traditional fixed-threshold logic.

[0042] In step four, dynamic constraints are applied using a gradient constraint strategy across low, medium, and high risk levels. Low-risk levels employ lenient constraints, allowing for higher position sizes and turnover rates; medium-risk levels use standard constraints to maintain a balance between return and risk; and high-risk levels use strict constraints, forcibly reducing the upper limit of single assets, decreasing total position size, and strictly controlling costs. The constraint parameters adjust linearly in real-time with the risk score, rather than using fixed thresholds, achieving precise synchronization between risk and constraints. In step five, the NSGA-II algorithm introduces an elite retention strategy and an adaptive crossover mutation mechanism to accelerate convergence and avoid local optima, outputting multiple Pareto optimal solutions corresponding to aggressive, balanced, and robust allocation strategies. The algorithm simultaneously satisfies six hard constraints: a weight sum of 1, non-negative single asset, maximum drawdown threshold, upper limit of industry concentration, upper limit of turnover rate, and upper limit of transaction cost. The transaction cost used in the NSGA-II algorithm is the sum of dynamic slippage cost based on order book depth and market impact cost based on the Almgren-Chriss framework. Slippage cost is calculated by consuming the weighted average price of each order in the Level-2 order book. Impact cost is decomposed into instantaneous impact (proportional to the square root of the order volume) and permanent impact (proportional to the order volume). The parameters are calibrated through regression of historical transaction data, so that the configuration scheme considers the feasibility of live trading during the generation stage.

[0043] Step six employs a three-stage joint judgment standard for backtesting, stress testing, and overfitting detection. Backtesting verifies historical returns over multiple periods, Sharpe ratio, and maximum drawdown stability. Stress testing simulates extreme scenarios such as market crashes, liquidity shortages, and consecutive limit-up / limit-down days. Overfitting detection judges performance based on the difference between in-sample and out-of-sample returns. The configuration scheme is only allowed to take effect if all three indicators meet the criteria simultaneously; failure to meet any one indicator renders the scheme invalid. Step six also involves automatic parameter correction, including six key parameters: feature selection threshold, number of Transformer encoder layers, number of attention heads, model learning rate, risk weighting coefficient, and optimization algorithm population size. The correction rule is to adjust the parameters corresponding to those that fail the verification in a targeted manner, avoiding blind global modifications. After correction, the process jumps directly to step four to regenerate constraints and optimize, forming an automatic error correction-iterative optimization closed loop to improve the reliability of the scheme.

[0044] Step seven features a real-time closed-loop risk control and iteration mechanism that supports automatic updates at three levels: daily, weekly, and monthly. Daily updates are used for rapid risk response and rebalancing; weekly updates are used to adjust allocation weights; and monthly updates are used for comprehensive model retraining. When the comprehensive risk score triggers a threshold, it is executed in stages: mild (weight reduction), moderate (position reduction), and severe (empty position or hedging), achieving early risk detection, control, and resolution. The fully quantifiable and interpretable attribution report based on SHAP values ​​in Step seven is based on the Shapley value in cooperative game theory—treating each risk prediction as the result of a cooperative game involving multiple input factors, with the Shapley value of each factor defined as that factor. The weighted average of the marginal contributions to the prediction results when all possible factor subsets are included possesses three strict mathematical properties: additivity, consistency, and missingness. The report consists of three parts: feature SHAP value ranking—showing the strength and direction of the marginal impact of each factor, with positive SHAP values ​​increasing risk and negative SHAP values ​​decreasing risk; risk source attribution distribution—decomposing the risk score according to SHAP to market conditions / capital flows / microstructure / fundamentals / public opinion; and return contribution decomposition—quantifying the marginal contribution of each asset and factor to the portfolio's return and risk. The report can be directly used for strategy review, compliance review, regulatory reporting, and as a basis for manual intervention, transforming the quantitative model from a black box to a white box.

[0045] The workflow of this invention is as follows: First, five types of multi-source heterogeneous data are collected: market data, capital flow data, market microstructure data, fundamental data, and public opinion data. The original data is then subjected to missing value imputation, noise filtering, time alignment, normalization, and outlier removal to form a standardized dataset. Then, time-series features of short, medium, and long periods, as well as microstructure features such as order book, volatility, and bid-ask spread, are extracted from the dataset. Through screening and cross-fusion, a high-dimensional feature vector is formed to provide high-quality input for subsequent models.

[0046] A Transformer time-series risk prediction model based on a multi-head self-attention mechanism is constructed. The high-dimensional feature vector and position encoding are superimposed and input into the model for training and prediction, and the output asset volatility, drawdown probability, and extreme risk probability are obtained. The self-attention mechanism directly models the dependency of arbitrary time steps by parallelizing the global receptive field, which fundamentally overcomes the gradient decay caused by recursive propagation in LSTM, accurately captures the ultra-long-range correlation of asset volatility, and realizes forward-looking risk judgment.

[0047] Dynamic multidimensional risk assessment is conducted, calculating dynamic VaR, CVaR, liquidity risk, model drift risk, and concentration risk. The posterior probability of the hidden state in the market is inferred through HMM. Based on the state probability, the adaptive weighting of the five types of risks is dynamically adjusted, and a comprehensive risk score is obtained by weighting and classifying them into three levels: low, medium, and high, so as to achieve accurate quantification and hierarchical management of overall risk.

[0048] Dynamic constraints are automatically generated based on the risk level. The higher the risk, the stricter the constraints on maximum drawdown, single asset holding, industry concentration, turnover rate, and transaction costs, so that the constraints are matched with market risks in real time, and the strategy risks are controlled from the source.

[0049] With the dual objectives of maximizing returns and minimizing risks, and combined with multiple constraints, the transaction costs are calculated in real time based on a dynamic slippage model and a market impact cost model with order book depth. The NSGA-II algorithm is used to solve the problem, obtain the Pareto optimal asset allocation weights, and output multiple risk preference schemes to meet different usage needs.

[0050] The optimal weights are backtested, stress-tested, and overfitted. If they fail, the features or model parameters are automatically corrected, and the process returns to step four for re-optimization. Only after passing the tests can the process proceed to the execution stage, ensuring that the solution is robust and does not overfit.

[0051] Establish real-time closed-loop risk control, continuously monitor the comprehensive risk score, and if it exceeds the threshold, implement weight reduction, position reduction, empty position or hedging according to the level; automatically update data and models on daily, weekly and monthly cycles to complete adaptive iteration; finally output the optimal configuration weight, risk indicators and a fully quantitative and explainable attribution report based on SHAP value, to realize an explainable, traceable and continuously optimizeable quantitative trading risk assessment and asset allocation system.

[0052] Although the present invention has been described above with reference to embodiments, various modifications can be made and components can be replaced with equivalents without departing from the scope of the invention. In particular, as long as there is no structural conflict, the features in the disclosed embodiments can be combined with each other in any manner. The lack of an exhaustive description of these combinations in this specification is merely for the sake of brevity and resource conservation. Therefore, the present invention is not limited to the specific embodiments disclosed herein, but includes all technical solutions falling within the scope of the claims.

Claims

1. A method for intelligent risk assessment and asset allocation optimization in quantitative trading, characterized in that: The optimization method includes the following steps: Step 1: Collect multi-source heterogeneous data required for quantitative trading. This data includes market data, fund flow data, market microstructure data, fundamental data, and public opinion data. The collected raw data undergoes missing value imputation, noise filtering, time alignment, numerical normalization, and outlier removal to obtain a standardized, usable dataset. From this standardized dataset, short-term, medium-term, and long-term time-series features, as well as microstructure features such as order book, volatility, and bid-ask spread, are extracted. These features are then filtered and cross-fused to form a high-dimensional feature vector for model input. Simultaneously, Level-2 order book snapshots are maintained in real-time to provide a liquidity depth data foundation for subsequent dynamic slippage and market impact cost modeling. Step 2: Construct a Transformer time series risk prediction model based on a multi-head self-attention mechanism. The high-dimensional feature vector obtained in Step 1 is superimposed with the sine-cosine position code and then input into the model for training and prediction. The self-attention layer directly models the dependency relationship between any position in the sequence in a parallel manner, and outputs the volatility value, future drawdown probability, and extreme market risk probability for each asset. Step 3: Based on the prediction results of Step 2, conduct dynamic multidimensional risk intelligent assessment, and simultaneously calculate dynamic VaR value, dynamic CVaR value, liquidity risk value, model drift risk value, and asset concentration risk value; construct a market state unsupervised identification module based on Hidden Markov Model (HMM), take multidimensional market observation sequence as input, and infer the posterior probability distribution of the current implicit state (bull market, bear market, sideways market) through forward-backward algorithm, dynamically adjust the adaptive weighting weights of the five types of risks based on the state probability, obtain a comprehensive risk score, and divide the risk into three levels: low, medium, and high according to the score; Step 4: Automatically generate corresponding dynamic constraints based on different risk levels. The dynamic transaction cost tolerance limit is linked to the current market order book depth. The higher the risk level, the stricter the constraints. The dynamic constraints include the dynamic maximum drawdown threshold, single asset holding limit, industry concentration limit, dynamic turnover rate limit, and dynamic transaction cost tolerance limit. Different constraint parameters are used for different risk levels. The higher the risk level, the stricter the constraints. Step 5: With the dual optimization objectives of maximizing the expected return of the asset portfolio and minimizing the overall risk, multiple constraints are added, including a total weight of 1, a single asset weight greater than or equal to 0, a maximum drawdown not exceeding a threshold, a turnover rate not exceeding a threshold, and transaction costs not exceeding a threshold. The calculation of transaction costs is based on a dynamic slippage model of order book depth and a market impact cost model. The deviation between the expected average transaction price and the actual order price of a single transaction is quantified as a function of the order volume at each price level, so that the constraints are truly linked to the current market micro-liquidity. The non-dominated sorting genetic algorithm with an elitist strategy, namely the NSGA-II algorithm, is used to solve the problem to obtain the Pareto optimal weighted portfolio of asset allocation that meets the constraints. Step 6: Perform backtesting and verification on the optimal weight combination obtained in Step 5 (where the transaction cost of each simulated transaction is recalculated based on the historical order book replay data at the corresponding time of the trading day to ensure that the backtesting returns are consistent with the live trading logic), stress testing, and overfitting detection. If the verification fails, the features or model parameters are automatically corrected, and the process returns to Step 4 to re-execute constraint generation and configuration optimization. If the verification passes, proceed to the next step. Step 7: Establish a real-time closed-loop risk control and iteration mechanism to continuously monitor the comprehensive risk score obtained in Step 3. When the score exceeds the dynamically set risk control threshold, perform weight reduction, position reduction, empty position, or hedging operations according to the mild, moderate, and severe exceedance levels, respectively. After controlling the risk, re-collect data and update the model parameters and HMM state transition matrix at fixed intervals to complete the adaptive iteration of the entire method. Finally, output the optimal asset allocation weight, various risk indicators, and a fully quantitative and interpretable attribution report based on SHAP values ​​to accurately capture the long-term correlation of asset volatility, making risk identification earlier and more sensitive.

2. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 1, characterized in that, The three types of time series features mentioned in Step 1—short-cycle, medium-cycle, and long-cycle—correspond to high-frequency features of 1 minute to 5 minutes, medium-frequency features of 15 minutes to 1 hour, and low-frequency features of 4 hours to daily charts, respectively. Short-cycle features are used to capture instantaneous fluctuations and abnormal shocks, medium-cycle features are used to identify trend strength and reversal signals, and long-cycle features are used to judge the overall market structure and style. The three types of features are combined through feature splicing, cross-feature generation, and weighted fusion to form a unified vector, which is then superimposed with sine-cosine position encoding and used as the input to the Transformer model, enabling the model to have both high-frequency sensitivity and low-frequency stability.

3. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 2, characterized in that, The Transformer time series risk prediction model based on the multi-head self-attention mechanism described in step two consists of an input embedding layer, N stacked Transformer encoder blocks, and an output prediction head. Each Transformer encoder block includes: a multi-head self-attention sublayer that maps the input to the Query, Key, and Value spaces through h different linear projections, calculates the attention weights of each head in parallel, and concatenates the output; a feedforward fully connected sublayer that consists of two fully connected networks with the GELU activation function; each sublayer uses residual connections and layer normalization; the self-attention mechanism calculates the attention weights between any two time steps in the sequence, allowing each output position to directly access all positions in the entire input sequence, with the information transmission path length always being O(1), fundamentally eliminating the gradient decay and long-distance information forgetting problems caused by recursive propagation in traditional LSTM; the multi-head attention is calculated in parallel through h different projection spaces, allowing the model to simultaneously focus on different types of time-dependent patterns such as short-term shocks, medium-term trends, and long-term cycles; the model output includes future volatility prediction, the probability of maximum drawdown in the interval, and the probability of extreme market risks, achieving multi-dimensional and forward-looking risk prediction.

4. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 3, characterized in that, The unsupervised market state identification module based on Hidden Markov Model (HMM) described in step three treats the actual market operating state as an implicit variable that cannot be directly observed, and models the implicit state as three discrete states—bull market, bear market, and sideways market. The multidimensional observable market indicator sequence is used as the observed variable; the model parameters include the initial state distribution π, the state transition matrix A and the emission probability matrix B, which are estimated unsupervised on historical data using the Baum-Welch algorithm; during online operation, the posterior probability of each hidden state at the current time is calculated recursively using the forward-backward algorithm, and the state corresponding to the maximum posterior probability is used as the determination result of the current market state. When the market is in a state transition period, i.e. the maximum posterior probability is lower than the preset threshold, the risk weight is adjusted by a soft fusion method that weights each state weight according to the posterior probability, so as to achieve a smooth transition of weights and avoid the lag and frequent jumps of the traditional fixed threshold logic at the style switching point.

5. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 4, characterized in that, The dynamic constraints described in step four employ a gradient constraint strategy based on three risk levels: low, medium, and high. The low-risk level uses lenient constraints, allowing for higher positions and higher turnover rates; the medium-risk level uses standard constraints to maintain a balance between returns and risks; and the high-risk level uses strict constraints, forcibly reducing the upper limit of single assets, reducing total positions, and strictly controlling costs. The constraint parameters are adjusted linearly in real time according to the risk score, rather than using fixed thresholds, to achieve precise synchronization between risk and constraints.

6. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 5, characterized in that, The NSGA-II algorithm described in step five introduces an elite retention strategy and an adaptive crossover mutation mechanism to accelerate convergence and avoid local optima. It outputs multiple Pareto optimal solutions, corresponding to three configuration styles: aggressive, balanced, and robust. The algorithm simultaneously satisfies six hard constraints: a weight sum of 1, non-negative single asset, maximum drawdown threshold, upper limit of industry concentration, upper limit of turnover rate, and upper limit of transaction cost. The transaction cost used in the NSGA-II algorithm is the sum of dynamic slippage cost based on order book depth and market impact cost based on the Almgren-Chriss framework. Slippage cost is calculated by consuming the weighted average price of each order in the Level-2 order book. Impact cost is decomposed into an instantaneous impact term (proportional to the square root of the order volume) and a permanent impact term (proportional to the order volume). The parameters are calibrated through regression analysis using historical transaction data, ensuring that the configuration scheme considers the feasibility of live trading during the generation stage.

7. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 6, characterized in that, The backtesting verification, stress testing, and overfitting detection described in step six adopt a three-stage joint judgment standard. Backtesting verification is used to verify the historical returns over multiple periods, Sharpe ratio, and maximum drawdown stability. Stress testing is used to simulate extreme scenarios such as crashes, liquidity shortages, and consecutive limit-up / limit-down days. Overfitting detection is judged by the difference between in-sample and out-of-sample returns. The configuration plan is allowed to take effect only if all three indicators meet the criteria. If any one of them fails to meet the criteria, it is deemed invalid.

8. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 7, characterized in that, The automatic parameter correction mentioned in step six The key parameters include six categories: feature selection threshold, number of Transformer encoder layers, number of attention heads, model learning rate, risk weighting coefficient, and optimization algorithm population size. The correction rule is to adjust the parameters corresponding to the items that fail the verification in a targeted manner, rather than blindly modifying them globally. After the correction is completed, proceed directly to step four to regenerate constraints and optimize, forming an automatic error correction-iterative optimization closed loop to improve the reliability of the solution.

9. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 8, characterized in that, The real-time closed-loop risk control and iteration mechanism described in step seven supports automatic updates at three levels: daily, weekly, and monthly. The daily level is used for rapid risk response and rebalancing, the weekly level is used for adjusting configuration weights, and the monthly level is used for comprehensive model retraining. When the comprehensive risk score triggers the threshold, it is executed in stages: mild → weight reduction, moderate → position reduction, and severe → empty position or hedging, so as to achieve early detection, early control, and early resolution of risks.

10. The method for intelligent risk assessment and asset allocation optimization for quantitative trading according to claim 9, characterized in that, The fully quantified interpretable attribution report based on SHAP values ​​described in step seven is based on the Shapley value in cooperative game theory. Each risk prediction is considered as the result of a cooperative game involving multiple input factors. The Shapley value of each factor is defined as the weighted average of its marginal contribution to the prediction result when added to all possible subsets of factors. It possesses three strict mathematical properties: additivity, consistency, and missing value. The report consists of three parts: feature SHAP value ranking—showing the strength and direction of the marginal influence of each factor; positive SHAP values ​​increase risk, while negative SHAP values ​​decrease risk. Risk source attribution distribution - risk score is decomposed into market / fund flow / microstructure / fundamentals / public opinion by SHAP; Return contribution breakdown – quantifying the marginal contribution of each asset and factor to portfolio returns and risks. The report can be directly used for strategy review, compliance review, regulatory filing, and as a basis for manual intervention, transforming the quantitative model from a black box to a white box.