Real-time quantitative risk transaction method and device, computer equipment and storage medium
By using pre-trained risk prediction models and strategy generators in the DeFi ecosystem, highly adaptable and transparent trading strategies are generated, solving the problem of increased costs caused by MEV when users execute trades and achieving controllable risk management.
Patent Information
- Application Number
- CN202511894300.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-12-16
- Publication Date
- 2026-01-16
AI Technical Summary
In the decentralized finance (DeFi) ecosystem, users face increased transaction costs due to maximum value extraction (MEV) when executing transactions because of information asymmetry and technological disadvantages. Existing defense strategies lack adaptability and transparency.
By inputting user-defined trading parameters and real-time feature vectors from multi-source data into a pre-trained risk prediction model, risk probabilities and predicted loss amounts are generated. Under the constraint of an acceptable value extraction cap, multiple candidate strategies are generated, and the expected residual maximum value extraction and expected net profit of each strategy are calculated, thereby selecting the target strategy to execute the trade.
It effectively avoids the increase in transaction costs, quantifies risk preferences by setting an acceptable value extraction cap for users, realizes a dynamically adaptable target strategy, transforms uncontrollable MEV risk into a controllable variable, and improves the transparency and adaptability of transactions.
Smart Images

Figure CN121352804A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to trading methods, apparatus, computer equipment, and storage media for real-time quantification of risk. Background Technology
[0002] In the decentralized finance (DeFi) ecosystem, ordinary users face increased transaction costs due to "Maximal Extractable Value (MEV)" when executing swaps because of information asymmetry and technological disadvantages. Sandwich attacks are the most common type of MEV attack.
[0003] To address this technical challenge, the current solution involves users setting up their wallets' networks with specific RPC endpoints to send their transactions directly to one or more "searcher-builder" networks, instead of a public mempool. These builders promise not to perform pre-running or sandwich attacks on transactions and to package them discreetly onto the blockchain. The drawbacks of this solution are: it essentially "hides" transactions, is a single defense strategy lacking adaptability, and, being a black-box operation, lacks transparency.
[0004] There is currently no effective solution to the problems of simplistic strategies, lack of adaptability and transparency in related technologies. Summary of the Invention
[0005] This embodiment provides a trading method, apparatus, computer equipment, and storage medium for real-time quantification of risk, in order to address the problems of limited strategies, lack of adaptability, and lack of transparency in related technologies.
[0006] Firstly, this embodiment provides a trading method for real-time quantification of risk, including:
[0007] The user-defined transaction parameters and the real-time feature vectors of the constructed multi-source data are input into a pre-trained risk prediction model to obtain the risk probability and the predicted loss amount. The transaction parameters include the acceptable value extraction cap and transaction information. The pre-trained risk prediction model is pre-trained under the acceptable value extraction cap as a decision constraint.
[0008] When the predicted loss amount is greater than the acceptable value extraction limit, multiple candidate strategies are generated, and the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy are calculated; and under the constraint of the predicted loss amount, a target strategy is selected from the candidate strategies.
[0009] Based on the transaction information, the user's transaction is executed according to the target strategy.
[0010] In some embodiments, the method further includes:
[0011] Constructing real-time feature vectors from multi-source data includes:
[0012] Real-time acquisition of multi-source data; the multi-source data includes on-chain data and CEX data;
[0013] Feature extraction is performed on the multi-source data to obtain multiple sub-features;
[0014] The multiple sub-features are combined into the real-time feature vector.
[0015] In some of these embodiments, multiple of the sub-features are transaction-specific features, on-chain liquidity pool features, mempool microstructure features, and CEX-DEX features.
[0016] In some embodiments, the method further includes:
[0017] The original risk prediction model is trained to obtain a pre-trained risk prediction model, which includes:
[0018] The target variables of historical multi-source data are labeled to obtain training labels; the target variables include whether the data was subjected to a sandwich attack and the actual maximum value extraction loss amount.
[0019] Extract multiple sub-features corresponding to the transaction information to be predicted to obtain a predicted feature vector;
[0020] Using historical multi-source data with the training labels as the training set, and whether or not a sandwich attack has been performed as the target variable, the MEV risk probability classifier in the original risk prediction model is trained to obtain a pre-trained MEV risk probability classifier; the pre-trained MEV risk probability classifier outputs the risk probability.
[0021] Using historical multi-source data with training labels indicating sandwich attacks as the training set, and the actual maximum value loss amount as the target variable, the PMEV loss regressor in the original risk prediction model is trained to obtain a pre-trained PMEV loss regressor; the pre-trained PMEV loss regressor outputs the predicted loss amount.
[0022] In some embodiments, the method further includes:
[0023] The risk prediction model is periodically trained based on the execution results generated from the user's transactions.
[0024] In some embodiments, when the predicted loss amount exceeds the acceptable value extraction limit, multiple candidate strategies are generated, and the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy are calculated; and under the constraint of the predicted loss amount, a target strategy is selected from the candidate strategies, including:
[0025] The strategy generator in the engine is invoked to compare the predicted loss amount with the acceptable value extraction limit. When the predicted loss amount is greater than the acceptable value extraction limit, multiple candidate strategies are generated based on preset parameters.
[0026] The cost-benefit simulator in the engine is invoked to predict the simulation results of each candidate strategy under the current market conditions; the simulation results include the expected residual maximum value extraction, the expected gas cost, and the expected failure probability;
[0027] The decision optimizer in the engine is invoked to calculate the expected net return of each candidate strategy after risk adjustment, based on the simulation results of each candidate strategy, under the constraint of the user's predicted loss amount, so as to select the target strategy from the candidate strategies.
[0028] In some of these embodiments, the candidate strategies include a first strategy of adaptive slippage adjustment, a second strategy of order splitting, a third strategy of trading channel switching, and a fourth strategy that combines one or more strategies.
[0029] Secondly, this embodiment provides a trading device for real-time quantification of risk, including: a prediction module, a screening module, and an execution module;
[0030] The prediction module is used to input the user-set transaction parameters and the real-time feature vectors of the constructed multi-source data into the pre-trained risk prediction model to obtain the risk probability and the predicted loss amount; the transaction parameters include the acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model is pre-trained under the acceptable value extraction upper limit as a decision constraint;
[0031] The filtering module is used to generate multiple candidate strategies when the predicted loss amount is greater than the acceptable value extraction limit, calculate the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy, and select the target strategy from the candidate strategies under the constraint of the predicted loss amount.
[0032] The execution module is used to execute the user's transaction according to the target strategy based on the transaction information.
[0033] Thirdly, this embodiment provides a computer device, including a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein the processor executes the computer program to implement the real-time quantification risk trading method described in the first aspect above.
[0034] Fourthly, this embodiment provides a storage medium storing a computer program that, when executed by a processor, implements the real-time risk quantification trading method described in the first aspect above.
[0035] Compared with related technologies, the real-time risk quantification trading method, apparatus, computer equipment, and storage medium provided in this embodiment obtain the risk probability and predicted loss amount by inputting user-set trading parameters and real-time feature vectors of constructed multi-source data into a pre-trained risk prediction model. The trading parameters include the acceptable value extraction cap and trading information. When the predicted loss amount exceeds the acceptable value extraction cap, multiple candidate strategies are generated, and the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy are calculated. Under the constraint of the predicted loss amount, a target strategy is selected from the candidate strategies. Based on the trading information, the user's transaction is executed according to the target strategy. This solves the problems of single strategy, lack of adaptability and transparency in related technologies. The user's risk preference is quantified by the acceptable value extraction cap set by the user. Based on this, it is input into the pre-trained risk prediction model to predict the loss amount in advance. Finally, by combining the two transparent parameters of the acceptable value extraction cap and the predicted loss amount, a dynamically adaptive target strategy is automatically generated and executed. This transforms uncontrollable MEV risk into a controllable variable, thereby effectively avoiding the increase in transaction costs.
[0036] Details of one or more embodiments of this application are set forth in the following drawings and description to make other features, objects and advantages of this application more readily apparent. Attached Figure Description
[0037] The accompanying drawings, which are included to provide a further understanding of this application and form part of this application, illustrate exemplary embodiments and are used to explain this application, but do not constitute an undue limitation of this application. In the drawings:
[0038] Figure 1 This is a hardware structure block diagram of a terminal device for a real-time quantification risk trading method provided in an embodiment of this application;
[0039] Figure 2 This is a flowchart of a real-time risk quantification trading method provided in an embodiment of this application;
[0040] Figure 3 This is a flowchart for generating real-time feature vectors;
[0041] Figure 4 This is a flowchart of the training of a risk prediction module provided in an embodiment of this application;
[0042] Figure 5 This is a flowchart illustrating the target selection strategy of the invocation engine provided in one embodiment of this application;
[0043] Figure 6 This is a structural block diagram of a real-time quantification risk trading device provided in an embodiment of this application.
[0044] In the diagram: 102, processor; 104, memory; 106, transmission device; 108, input / output device; 210, prediction module; 220, filtering module; 230, execution module. Detailed Implementation
[0045] To better understand the purpose, technical solution, and advantages of this application, the application is described and illustrated below in conjunction with the accompanying drawings and embodiments.
[0046] Unless otherwise defined, the technical or scientific terms used in this application shall have the general meaning understood by a person skilled in the art to which this application pertains. Words such as “a,” “an,” “an,” “the,” “the,” and “these” used in this application do not indicate quantitative limitation and may be singular or plural. The terms “comprising,” “including,” “having,” and any variations thereof used in this application are intended to cover non-exclusive inclusion; for example, a process, method, system, product, or device that comprises a series of steps or modules (units) is not limited to the listed steps or modules (units) but may include steps or modules (units) not listed, or may include other steps or modules (units) inherent to these processes, methods, products, or devices. Words such as “connected,” “linked,” and “coupled” used in this application are not limited to physical or mechanical connections but may include electrical connections, whether direct or indirect. “Multiple” used in this application refers to two or more. “And / or” describes the relationship between related objects, indicating that three relationships may exist, for example, “A and / or B” can represent: A alone, A and B simultaneously, and B alone. Normally, the character " / " indicates that the objects before and after it are in an "or" relationship. The terms "first," "second," "third," etc., used in this application are merely to distinguish similar objects and do not represent a specific order of objects.
[0047] The method embodiments provided in this example can be executed on a terminal, computer, or similar computing device. For example, it can run on a terminal. Figure 1This is a hardware structure block diagram of the terminal for the real-time quantitative risk trading method in this embodiment. (As shown...) Figure 1 As shown, a terminal may include one or more ( Figure 1 Only one is shown in the diagram. A processor 102 and a memory 104 for storing data are also included. The processor 102 may be, but is not limited to, a microprocessor (MCU) or a programmable logic device (FPGA). The terminal may also include a transmission device 106 for communication functions and an input / output device 108. Those skilled in the art will understand that… Figure 1 The structure shown is for illustrative purposes only and does not limit the structure of the terminal described above. For example, the terminal may also include components that are more advanced than those described above. Figure 1 The more or fewer components shown, or having the same Figure 1 The different configurations shown are illustrated.
[0048] The memory 104 can be used to store computer programs, such as application software programs and modules, like the computer program corresponding to the real-time quantitative risk trading method in this embodiment. The processor 102 executes various functional applications and data processing by running the computer programs stored in the memory 104, thereby implementing the aforementioned method. The memory 104 may include high-speed random access memory and may also include non-volatile memory, such as one or more magnetic storage devices, flash memory, or other non-volatile solid-state memory. In some instances, the memory 104 may further include memory remotely located relative to the processor 102, and these remote memories can be connected to the terminal via a network. Examples of such networks include, but are not limited to, the Internet, corporate intranets, local area networks, mobile communication networks, and combinations thereof.
[0049] The transmission device 106 is used to receive or send data via a network. This network includes a wireless network provided by the terminal's communication provider. In one example, the transmission device 106 includes a Network Interface Controller (NIC), which can connect to other network devices via a base station to communicate with the Internet. In another example, the transmission device 106 can be a Radio Frequency (RF) module used for wireless communication with the Internet.
[0050] This embodiment provides a trading method for real-time risk quantification. Figure 2 This is a flowchart of the real-time quantitative risk trading method in this embodiment, such as... Figure 2 As shown, the process includes the following steps:
[0051] Step S210: Input the user-set transaction parameters and the real-time feature vector of the constructed multi-source data into the pre-trained risk prediction model to obtain the risk probability and the predicted loss amount; the transaction parameters include the acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model is pre-trained under the decision constraint of the acceptable value extraction upper limit;
[0052] Step S220: When the predicted loss amount is greater than the acceptable value extraction limit, generate multiple candidate strategies based on preset parameters, calculate the expected residual maximum value extraction and expected net profit for each candidate strategy, and select the target strategy from the candidate strategies under the constraint of the predicted loss amount.
[0053] Step S230: Based on the transaction information, execute the user's transaction according to the target strategy.
[0054] Specifically, transaction parameters can be considered as pre-set by the user; for example, the user inputs transaction parameters on relevant interfaces (such as the wallet plugin interface or the relevant app interface). Transaction parameters include the acceptable value extraction limit and transaction information; among which, transaction information refers to the user's transaction intention, which is the basic transaction information; for example, "exchange 10 of held digital currency for e-CNY," etc. Digital currency can be WETH, etc. e-CNY can also be USDC, etc. The acceptable value extraction limit (AEV RISK Cap) refers to the maximum value loss that the user can tolerate due to MEV. For example, if a user sets the acceptable value extraction limit to ¥20, it means "to successfully complete this transaction of 10 held digital currency, I am willing to bear a potential MEV loss of up to ¥20. If the predicted loss exceeds the potential MEV loss of ¥20, stronger protective measures, warnings, or stopping the transaction should be taken." Thus, the user's risk preference can be quantified by setting the acceptable value extraction limit; thereby transforming the abstract MEV risk into a specific parameter that the user can understand, set, and control.
[0055] Multi-source data refers to data from multiple data sources (blockchain, centralized exchanges, etc.). This multi-source data is collected in real time and processed to construct a real-time feature vector. The real-time feature vector can be considered as a data table of various sub-feature sets related to the current transaction from the multi-source data.
[0056] The pre-trained risk prediction model is trained under the acceptable value extraction cap as a decision constraint, and it outputs the risk probability and predicted loss amount. Using the acceptable value extraction cap as a decision constraint in model training not only represents a breakthrough in human-computer interaction but also provides a clear and quantifiable decision constraint for model training. Without the acceptable value extraction cap parameter, the pre-trained risk prediction model is merely a risk indicator; with it, it becomes a true decision-making and execution agent. The risk probability (MEV Risk Score) is a probability value between 0 and 1, representing the probability that the transaction is susceptible to a sandwich attack. The predicted loss amount is an actual monetary amount, indicating the expected loss if a sandwich attack is launched. For example, the predicted loss amount is ¥55. Before the actual transaction occurs, a quantifiable risk report (the risk probability and predicted loss amount output by the risk prediction model) is provided to the user. Users no longer blindly trust a service but can clearly understand the data in the decision-making process.
[0057] When the predicted loss exceeds the acceptable value extraction cap, it means that directly executing the transaction would exceed the user's maximum tolerable value loss due to MEV (Mean Value Expiration). Therefore, it is necessary to regenerate the optimal target strategy to reduce the loss amount caused by the transaction, thereby ensuring that the predicted loss is less than or equal to the acceptable value extraction cap. Specifically, multiple candidate strategies are generated, each with estimated costs and protection effects. The expected residual maximum value extraction and expected net profit for each candidate strategy can be calculated. Then, using the predicted loss amount as a constraint, a dynamically adaptable target strategy is selected from the candidate strategies to execute the user's transaction based on the transaction information. This transforms uncontrollable MEV risk into a controllable variable, effectively preventing transaction costs from being driven up.
[0058] The proposed solution involves users setting their wallets' networks to specific RPC endpoints, allowing them to send transactions directly to one or more "searcher-builder" networks instead of a public mempool. These builders promise not to perform pre-processing or sandwich attacks on transactions and package them discreetly onto the blockchain. The drawbacks of this approach are that it essentially "hides" transactions, relying on a single defense strategy and lacking adaptability; and because it operates as a black box, it lacks transparency. In this embodiment, the user's risk preference is quantified by setting an acceptable value extraction cap, thus transforming the abstract MEV risk into a concrete parameter that the user can understand, set, and control. This parameter represents a breakthrough in human-computer interaction and provides explicit, quantifiable decision constraints for model training. The pre-trained risk prediction model, trained under the acceptable value extraction cap as a decision constraint, outputs risk probabilities and predicted loss amounts, making it a true decision-making and execution agent. Among them, by using the constraint of predicting the amount of loss, a dynamically adaptable target strategy is selected from the candidate strategies to execute the user's transaction based on the transaction information. This can transform uncontrollable MEV risk into a controllable variable and effectively avoid the increase in transaction costs.
[0059] Furthermore, this method embodiment can be integrated into an execution layer, considered as an execution layer solution, and can be integrated with any DEX or DeFi protocol as a wallet plugin, SDK, or API service. It does not change the underlying trading venue, but rather optimizes the process of "how to get to" the trading venue.
[0060] The steps described above are explained in detail below:
[0061] It should be noted that in some embodiments, after the risk prediction model outputs the predicted loss amount, the predicted loss amount can be compared with the acceptable value extraction limit. If the predicted loss amount is less than or equal to the acceptable value extraction limit, it means that direct transaction also meets the user's expectations. Therefore, the transaction is completed directly according to the default transaction strategy, without executing steps S220 and S230. It can be considered that steps S220 and S230 will only be executed when the predicted loss amount is greater than the acceptable value extraction limit.
[0062] In some of these embodiments, such as Figure 3 As shown, the real-time quantification of risk trading method also includes the following steps:
[0063] Constructing real-time feature vectors from multi-source data includes:
[0064] Step S310: Collect multi-source data in real time; multi-source data includes on-chain data and CEX data;
[0065] Step S320: Extract features from the multi-source data to obtain multiple sub-features;
[0066] Step S330: Combine multiple sub-features into a real-time feature vector.
[0067] In this embodiment, the real-time feature vector is constructed based on multi-source data acquired in real time, through feature extraction and combination of the multi-source data, to ensure the reliability of the real-time feature vector. Specifically, the implementation is as follows:
[0068] First, a data acquisition module continuously collects multi-source data from multiple data sources for seven consecutive days. This multi-source data includes on-chain data and CEX data. On-chain data includes: Mempool: monitoring pending transactions, analyzing transaction flow, gas price competition, and suspicious MEV bot behavior patterns; On-chain state: the target liquidity pool's reserves (LiquidityDepth), trading volume, digital resource prices, historical volatility, etc.; Block data: gas usage of recent blocks and block builder information. CEX data includes: real-time order book depth and latest transaction prices from major centralized exchanges. This is used to identify arbitrage opportunities between DEXs and CEXs, which are a crucial driver of MEVs.
[0069] Next, feature extraction is performed on the multi-source data to obtain multiple sub-features; these sub-features include, but are not limited to, transaction characteristics, on-chain liquidity pool characteristics, mempool microstructure characteristics, and CEX-DEX characteristics. Finally, these multiple sub-features are combined into a real-time feature vector.
[0070] This embodiment enables the construction of feature vectors from raw multi-source data into machine learning models, improving transaction efficiency and organically combining it with transaction efficiency costs to further control transaction costs.
[0071] In other embodiments, preprocessing such as data cleaning can be performed on multi-source data before feature extraction to further improve the reliability of real-time feature vectors.
[0072] In some of these embodiments, such as Figure 4 As shown, the real-time quantification of risk trading method also includes the following steps:
[0073] The original risk prediction model is trained to obtain a pre-trained risk prediction model, which includes:
[0074] Step S410: Label the target variables of historical multi-source data to obtain training labels; the target variables include whether it was attacked by a sandwich attack and the actual maximum value extraction loss amount;
[0075] Step S420: Extract multiple sub-features corresponding to the transaction information to be predicted to obtain the prediction feature vector;
[0076] Step S430: Using historical multi-source data with training labels as the training set and whether or not a sandwich attack has been committed as the target variable, train the MEV risk probability classifier in the original risk prediction model to obtain a pre-trained MEV risk probability classifier; the pre-trained MEV risk probability classifier outputs the risk probability.
[0077] Step S440: Using historical multi-source data with training labels that have been subjected to sandwich attacks as the training set, and the actual maximum value loss amount as the target variable, train the PMEV loss regressor in the original risk prediction model to obtain a pre-trained PMEV loss regressor; the pre-trained PMEV loss regressor outputs the predicted loss amount.
[0078] Specifically, the original risk prediction model can include one or more machine learning models for time series analysis; the machine learning models can be gradient boosting tree models such as XGBoost, deep neural networks such as LSTM, etc., and there are no restrictions on this.
[0079] The following example uses a risk prediction model with two XGBoost structural sub-models to illustrate training:
[0080] I. Data Preparation and Definition of Target Variable:
[0081] 1. Historical multi-source data includes historical on-chain data and historical CEX data: For historical on-chain data: acquire and parse the full node historical block data of the target chain (Ethereum, Solana, etc.); it includes complete blocks and DEX transaction (DEX Swa transaction) information from the past 6-12 months. For historical CEX data: acquire the real-time order book depth and latest transaction price of major centralized exchanges from the past 6-12 months.
[0082] 2. Automated Labeling of Target Variables: For each historical DEX transaction, two target variables are labeled: whether it was subjected to a sandwich attack (is_sandwiched) and the actual maximum value extraction loss amount (actual_mev_loss). These target variables guide the optimized training of the two XGBoost sub-models, endowing the risk prediction model with the ability to perceive risk and predict losses in advance.
[0083] The specific annotation process is as follows: a) Transaction Traversal: Traverse every DEX transaction (Tx_User) in the historical block. b) Context Scanning: Scan the DEX transactions within the same block, as well as the DEX transactions immediately before and after them. c) Attack Pattern Identification: Find transaction pairs (T_bot_front, T_bot_back) that match the following patterns: T_bot_front is executed before Tx_User, and T_bot_back is executed after Tx_User. The initiator of T_bot_front and T_bot_back is the same address (MEV bot address). The transaction path of T_bot_front is the same as or opposite to that of T_user (e.g., WETH->E-CNY), causing the price to slide in a direction unfavorable to Tx_User. The transaction path of T_bot_back is opposite to that of T_bot_front (e.g., E-CNY->WETH), partially restoring the price and generating profit for the bot. d) Profit Calculation: Accurately calculate the net profit (minus gas fees) generated by the bot address from executing the transaction pair (T_bot_front, T_bot_back). e. Generate tags: If a profitable attack pattern is found, then mark the DEX transaction (T_user) as: is_sandwiched=1 (yes), actual_mev_loss=robot net profit (amount); otherwise, mark the DEX transaction (T_user) as: is_sandwiched=0 (no), actual_mev_loss=0.
[0084] This annotation process completes the annotation of historical on-chain data in massive multi-source data to generate high-quality training labels, providing a reliable data foundation for subsequent model training.
[0085] II. Training of the risk prediction model based on XGBoost's "market snapshot":
[0086] The market state just before each transaction occurs is considered a static "snapshot," and predictions are made based on the characteristics of this snapshot.
[0087] 1. Feature Engineering: For each transaction to be predicted, extract the following sub-features from the historical multi-source data at the time of submission.
[0088] a. Transaction Characteristics: 11. `trade_amount_usd`: The value of the transaction. 12. `trade_direction`: The direction of the transaction (0 or 1, e.g., WETH->E-CNY (WETH to E-CNY) is 0, E-CNY->WETH is 1). 13. `gas_price / max_fee_per_gas`: The gas price set by the user. 14. `slippage_tolerance`: The slippage tolerance set by the user. 15. `token_volatility_24h`: The 24-hour price volatility of the non-stablecoin in the trading pair.
[0089] b. On-chain liquidity pool characteristics: 21. pool_liquidity_usd: The total value of the target liquidity pool. 22. trade_to_liquidity_ratio: trade_amount_usd / pool_liquidity_usd, measuring the price impact of a transaction on the pool. 23. pool_volume_1h / 24h: The pool's transaction volume over the past 1 hour / 24 hours. 24. pool_tx_count_last_10_blocks: The number of transactions in this pool in the last 10 blocks.
[0090] c. Mempool Microstructure Characteristics: 31. `mempool_pending_tx_count`: The total number of pending transactions in this pool. 32. `mempool_gas_price_p25, p50, p75`: The 25th, 50th, and 75th percentiles of the gas prices of all transactions in the Mempool, reflecting network congestion and gas competition. 33. `competing_tx_volume`: The total amount of pending transactions in the Mempool that are in the same or opposite direction to the user's transaction. 34. `potential_bot_tx_count`: The number of potential MEV bot transactions identified in the Mempool through pattern recognition (e.g., high gas, contract calls without access lists).
[0091] d. CEX-DEX Features: 41. dex_cex_price_spread: The percentage difference between the current price of the target DEX pool and the median price of the order book of a mainstream CEX (such as Binance). 42. ex_orderbook_depth_1pct: The total amount of buy and sell orders within 1% of the median price on the CEX order book, reflecting the achievable capacity of the arbitrage opportunity.
[0092] 2. Model building and training:
[0093] Two independent XGBoost models (MEV risk probability classifier and PMEV loss regressor) are constructed as risk prediction models.
[0094] The first XGBoost model: MEV Risk Score Classifier.
[0095] Target variable: whether it has been sandwiched (is_sandwiched) (0 or 1).
[0096] Model type: XGB Classifier.
[0097] Model training: The MEV risk probability classifier is trained using historical multi-source data with training labels as the training set to obtain a pre-trained MEV risk probability classifier. The optimization objective during the training process is the preset log loss function (logloss) or AUC (Area Under the ROC Curve).
[0098] Model output: Risk probability MEV Risk Score (probability between 0 and 1).
[0099] The second XGBoost model: Predicted MEV Regressor (PMEV Loss Regressor).
[0100] Target variable: Actual_mev_loss, representing the actual maximum value loss.
[0101] Model type: XGBRegressor.
[0102] Model training: Training is performed using only historical multi-source data of the training labels subjected to sandwich attacks (is_sandwiched=1), because only the magnitude of the loss at the time of the attack is of concern. The actual maximum value extraction loss amount (actual_mev_loss) of the target variable is less than the acceptable value extraction cap (AEV RISK Cap) as a decision constraint. The optimization objective is the root mean square error (rmse).
[0103] Model output: Predicted loss amount PMEV_raw.
[0104] Based on this, the risk prediction model can be considered to have completed training; the XGBoost model has a fast response speed and can be deployed as the main model for real-time inference. For example, the pre-trained risk prediction model can be deployed on a low-latency inference server and made available to the front end via API, ensuring that the prediction result is returned the instant the user submits a transaction.
[0105] Specifically, when a user submits transaction parameters, all the above sub-features are immediately collected to form a real-time feature vector; the real-time feature vector is input into a pre-trained MEV risk probability classifier to obtain the risk probability MEV Risk Score (probability from 0 to 1); the real-time feature vector is input into a pre-trained PMEV loss regressor to obtain the predicted loss amount PMEV_raw.
[0106] The final output of the risk prediction model is PMEV, which is MEV Risk Score × PMEV_raw. This output combines the probability of an attack occurring with the potential loss after it occurs, resulting in a more robust expected loss value, making the pre-trained risk prediction model a true decision-making and execution agent.
[0107] In some embodiments, the real-time risk quantification trading method further includes the following steps:
[0108] Based on the execution results generated by the user's transactions, the pre-trained risk prediction model is trained periodically.
[0109] Specifically, the deployed risk prediction model can be learned online / retrained periodically.
[0110] For example: After each transaction is executed, the actual execution result is obtained. The labeling algorithm continues to run, labeling new transactions. These newly labeled data are then added to the training set, and the risk prediction model undergoes periodic (e.g., daily or weekly) incremental training or complete retraining to adapt to changing market patterns and MEV bot strategies.
[0111] In some of these embodiments, such as Figure 5 As shown, in step S220, when the predicted loss amount exceeds the acceptable value extraction limit, multiple candidate strategies are generated, and the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy are calculated. Under the constraint of the predicted loss amount, the target strategy is selected from the candidate strategies, including the following steps:
[0112] Step S221: Call the strategy generator in the engine, compare the predicted loss amount with the acceptable value extraction limit, and generate multiple candidate strategies based on preset parameters when the predicted loss amount is greater than the acceptable value extraction limit.
[0113] Step S222: Invoke the cost-benefit simulator in the engine to predict the simulation results of each candidate strategy under the current market conditions; the simulation results include the expected residual maximum value extraction, the expected gas cost, and the expected failure probability;
[0114] Step S223: Invoke the decision optimizer in the engine, and under the constraint of the user's predicted loss amount, calculate the expected net return of each candidate strategy after risk adjustment based on the simulation results of each candidate strategy, so as to select the target strategy from the candidate strategies.
[0115] In this embodiment, the above process can be implemented by calling an engine; while in other embodiments, it can be implemented using a combination algorithm or other methods. The following explanation uses an engine-based implementation as an example:
[0116] The core of the engine is a model-based cost-benefit analysis system. Instead of simply selecting a strategy, it quantifies and simulates each possible strategy, predicts its multi-dimensional results (MEV loss, Gas cost, failure risk), and makes the optimal decision based on a unified utility function (expected net benefit) to determine the target strategy.
[0117] The engine consists of three core components:
[0118] Strategy Generator: A rule-based and heuristic algorithm-based module used to compare the predicted loss amount with the acceptable value extraction limit. When the predicted loss amount is greater than the acceptable value extraction limit, it generates multiple candidate strategies based on preset parameters. The candidate strategies are a finite but representative set of candidate strategies, including the first strategy of adaptive slippage adjustment, the second strategy of order splitting, the third strategy of trading channel switching, and the fourth strategy of combining one or more strategies.
[0119] Cost-Benefit Simulator: It can contain a series of mathematical models to predict the simulation results of each candidate strategy under the current market conditions; the simulation results include the expected residual maximum value extraction (Residual PMEV), expected gas cost, and expected failure probability (P_failure); the current market conditions refer to a static "snapshot" of the market state at the moment the current transaction occurs, which can be determined by multi-source data at the moment the current transaction occurs.
[0120] Decision Optimizer: Under the constraint of the user's predicted loss amount, it calculates the expected net return of each candidate strategy after risk adjustment based on the simulation results of each candidate strategy, so as to select the target strategy from the candidate strategies.
[0121] The following is a detailed implementation process of the engine from receiving input to outputting the final target strategy:
[0122] The inputs are: PMEV_initial: the initial MEV loss predicted by the risk prediction model (e.g., ¥55); AEV_Cap: the acceptable value extraction cap in the user-defined trading parameters (e.g., ¥20); Trade_Details: the trading information in the user-defined trading parameters {trading amount, trading pair, original slippage}; Network_State: determined by real-time multi-source data {current on-chain network state, base gas fee, priority fee of the target pool for the suggested trade, liquidity of the target pool, 5-minute volatility}.
[0123] S1, Initial Risk Assessment:
[0124] The system compares the predicted loss amount with the acceptable value extraction limit. If the predicted loss amount is less than or equal to the acceptable value extraction limit, no further steps are required; the user's transaction is executed directly based on the transaction information to complete the transaction with maximum efficiency. If the predicted loss amount exceeds the acceptable value extraction limit, the system proceeds to step S2.
[0125] S2, Candidate Strategy Generation:
[0126] When PMEV_initial > AEV_Cap, the policy generator is started, creating a set of candidate policies. This set of candidate policies is not unlimited, but rather a combination based on preset parameters. The preset parameters are:
[0127] 1. S_default: {type: 'public', slippage: original_slippage};
[0128] 2. S_slippage_tight: {type: 'public', slippage: 0.1%};
[0129] 3. S_slippage_moderate: {type: 'public', slippage: 0.2%};
[0130] 4. S_split_3: {type: 'public', slippage: original_slippage, split_count: 3} / / Split 3 orders;
[0131] 5. S_split_5: {type: 'public', slippage: original_slippage, split_count: 5} / / Split 5 orders;
[0132] 6. S_private_rpc: {type: 'private_rpc', provider: 'Flashbots Protect'};
[0133] 7. S_hybrid_split_private: {type: 'private_rpc', provider: 'FlashbotsProtect', split_count: 5}.
[0134] S3: Cost-Effectiveness Simulation: This is the core of the engine. For each candidate strategy, three key metrics are calculated: Expected Residual Maximum Value Extraction (Residual_PMEV), Expected Gas Cost (Gas_Cost), and Expected Failure Probability (P_failure).
[0135] 3.1, Simulating the first strategy of adaptive slippage adjustment (adaptive slippage adjustment):
[0136] Residual_PMEV(S_slippage): Slippage directly limits the upper limit of price push. Therefore, the residual MEV is subject to this hard constraint. Calculated as follows:
[0137] ;
[0138] Example: Transaction amount 10,000, slippage 0.11. Even if the original PMEV is 55, the maximum MEV loss under this strategy is limited to 55, and the minimum MEV loss under this strategy is limited to 10.
[0139] P_failure(S_slippage): The probability of a trade failing is directly related to the slippage setting and market volatility. This probability can be estimated using a lookup table: P_failure = f(volatility, new_slippage). Here, f is trained based on historical data, taking the current 5-minute digital resource price volatility and the set slippage as input, and outputting a failure probability between 0 and 1. Higher volatility and lower slippage result in a higher P_failure.
[0140] Gas_Cost(S_slippage): On success, the cost is the same as the default transaction. On failure, the user will still have to pay gas.
[0141] 3.2, The second strategy for simulated order splitting (intelligent order splitting):
[0142] Residual_PMEV(S_split): The core of splitting the attack is to increase the attacker's cost and reduce their profit, thereby causing them to abandon the attack. The calculation is as follows:
[0143] ;
[0144] This is the estimated gas cost (approximately 2 × Network_State.Base_Gas_Fee × 100,000 Gwei) for the bot to execute one "pre-processing + post-processing" transaction. If Profit_per_Chunk <= 0: The attack is unprofitable, and the bot will likely abandon it. Residual_PMEV = 0. Else: The attack is still profitable. Residual_PMEV = PMEV_initial (conservative estimate).
[0145] Gas_Cost(S_split): Gas cost increases linearly. Gas_Cost = S_split.split_count × Estimated_Gas_per_Tx.
[0146] P_failure(S_split): Individual small orders have an extremely low failure rate (p_chunk_fail) due to their small price impact. However, the success of the overall transaction depends on the success of all sub-orders. P_success=(1-p_chunk_fail)^S_split.split_count P_failure=1-P_success.
[0147] 3.3, The third strategy for switching simulated trading channels (switching trading channels):
[0148] Residual_PMEV(S_private_rpc): Privacy channels are designed to eliminate sandwich attacks. Theoretically, Residual_PMEV = 0. In practice, a leakage factor can be introduced, such as 0.01 (1%), representing an extremely low probability of malicious behavior by the builder or channel failure. Residual_PMEV = PMEV_initial × leakage_factor.
[0149] Gas_Cost(S_private_rpc): Essentially the same as public trading.
[0150] P_failure(S_private_rpc): The failure rate depends primarily on the historical stability and network latency of the privacy RPC provider. This can be a configurable parameter based on historical statistics. For example: P_failure_flashbots=0.005.
[0151] 3.4, Simulate a fourth strategy that combines one or more strategies; this is achieved by combining steps 3.1 to 3.3 above, and will not be described again.
[0152] The above strategy can be considered as real-time generated and highly customized for individual transactions and the current market environment. When the market is volatile and liquidity is poor, order splitting and privacy channels may be chosen; when the market is stable and MEV risk is low, direct public transmission may be chosen to pursue the fastest speed and lowest gas.
[0153] S4: Decision Optimization
[0154] Once the {Residual_PMEV, Gas_Cost, P_failure} triples for each policy S are obtained, the decision optimizer is started.
[0155] 4.1 The implementation logic of constraint filtering is as follows:
[0156] Eligible_Strategies=[
[0157] For each strategy S:
[0158] If S.Residual_PMEV<=AEV_Cap:
[0159] Add S to Eligible_Strategies.
[0160] This process filters out candidate strategies that meet the constraints.
[0161] 4.2 Calculate the risk-adjusted expected net return for each candidate strategy: For each candidate strategy that meets the constraints, calculate its final expected value. The calculation formula considers the cost of failure, and its expression is:
[0162] Expected_Fill_Value=Trade_Details.Trade_Amount_E-CNY-S.Residual_PMEV;
[0163] Cost_on_Success = S.Gas_Cost;
[0164] Cost_on_Failure = S.Gas_Cost (For simple transactions, the gas costs for failure and success are similar);
[0165] .
[0166] 4.3 The final implementation logic chosen is as follows:
[0167] If Eligible_Strategies is empty: / / No strategy meets the user's risk preference.
[0168]
[0169] Else:
[0170] Optimal_Strategy=argmax(Expected_Net_Outcome(S)for S in Eligible_Strategies)
[0171] Return Optimal_Strategy.
[0172] This process selects the optimal policy from the candidate policies as the target policy.
[0173] In related technologies, RPC endpoints are only responsible for transmitting transactions and do not help users optimize transaction parameters (such as slippage and splitting). However, the optimization strategy adopted in this embodiment not only considers how to avoid losses, but also weighs costs (Gas, latency) and benefits among multiple strategies to find the globally optimal solution for users.
[0174] Assuming a transaction amount of 100,000; PMEV=55; AEV Cap=20; Gas_Cost=10, an example is shown in Table 1.
[0175] Table 1
[0176]
[0177] In some embodiments, based on transaction information, the user's transaction is executed according to the target strategy. Specifically, according to the target strategy selected by the engine, the corresponding transaction (or transaction sequence) is automatically constructed and signed, and then sent to the designated channel (public Mempool or privacy RPC) to complete the transaction.
[0178] In other embodiments, if the predicted loss amount is less than or equal to the acceptable value extraction limit, then according to the default policy, the corresponding transaction (or transaction sequence) is automatically constructed and signed, and then sent to the designated channel (public Mempool or privacy RPC) to complete the transaction.
[0179] After a transaction is completed, the actual execution results (final transaction price, gas cost, and success status) are recorded. These results are then used to continuously retrain the risk prediction model, thus forming a self-updating and improving closed loop.
[0180] Specifically, the above-described method embodiment is a closed-loop system that tightly couples prediction, decision-making, execution, and feedback. It can generate and evaluate candidate strategies in the strategy space in real time based on a dynamically changing input (multi-source data from the real-time market) and a user-defined static constraint (AEV RISKCap), and autonomously select the optimal solution from them. This "perception-decision-action" intelligent agent design paradigm is groundbreaking in the field of DeFi transaction execution.
[0181] It should be noted that the steps shown in the above process or in the flowchart of the accompanying figures can be executed in a computer system such as a set of computer-executable instructions, and although a logical order is shown in the flowchart, in some cases the steps shown or described may be executed in a different order than that shown here.
[0182] This embodiment also provides a trading device for real-time risk quantification, which is used to implement the above embodiments and preferred embodiments; details already described will not be repeated. The terms "module," "unit," "subunit," etc., used below refer to combinations of software and / or hardware that perform predetermined functions. Although the device described in the following embodiments is preferably implemented in software, hardware implementation, or a combination of software and hardware, is also possible and contemplated.
[0183] Figure 6 This is a structural block diagram of the real-time quantitative risk trading device in this embodiment, as shown below. Figure 6 As shown, the device includes: a prediction module 210, a filtering module 220, and an execution module 230;
[0184] The prediction module 210 is used to input the user-set transaction parameters and the real-time feature vectors of the constructed multi-source data into the pre-trained risk prediction model to obtain the risk probability and the predicted loss amount; the transaction parameters include the acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model is pre-trained under the decision constraint of the acceptable value extraction upper limit;
[0185] The screening module 220 is used to generate multiple candidate strategies when the predicted loss amount is greater than the acceptable value extraction limit, calculate the expected residual maximum value extraction and expected net profit corresponding to each candidate strategy, and select the target strategy from the candidate strategies under the constraint of the predicted loss amount.
[0186] Execution module 230 is used to execute the user's transactions according to the target strategy based on transaction information.
[0187] The aforementioned device addresses the issues of simplistic strategies, lack of adaptability, and transparency in related technologies. It quantifies a user's risk preference by setting an acceptable value extraction cap. Based on this, the data is input into a pre-trained risk prediction model to predict potential losses. Finally, by combining the acceptable value extraction cap and the predicted loss amount—two transparent parameters—a dynamically adaptive target strategy is automatically generated and executed. This transforms uncontrollable MEV risk into a controllable variable, effectively mitigating the increase in transaction costs.
[0188] In some embodiments, the trading device for real-time quantification of risk further includes: a construction module;
[0189] The building module is used to construct real-time feature vectors from multi-source data, and it includes:
[0190] Real-time acquisition of multi-source data; multi-source data includes on-chain data and CEX data;
[0191] Feature extraction is performed on multi-source data to obtain multiple sub-features;
[0192] Multiple sub-features are combined into a real-time feature vector.
[0193] In some embodiments, multiple sub-features include transaction characteristics, on-chain liquidity pool characteristics, mempool microstructure characteristics, and CEX-DEX characteristics.
[0194] In some embodiments, the trading device for real-time quantification of risk further includes: a pre-training module;
[0195] The pre-training module is used to train the original risk prediction model to obtain a pre-trained risk prediction model, which includes:
[0196] Label the target variables in historical multi-source data to obtain training labels; the target variables include whether the sandwich attack occurred and the actual maximum value extraction loss amount.
[0197] Extract multiple sub-features corresponding to the transaction information to be predicted to obtain a predicted feature vector;
[0198] Using historical multi-source data with training labels as the training set, and whether or not the system has been subjected to a sandwich attack as the target variable, the MEV risk probability classifier in the risk prediction model is trained to obtain a pre-trained MEV risk probability classifier; the pre-trained MEV risk probability classifier outputs the risk probability.
[0199] Using historical multi-source data with training labels indicating sandwich attacks as the training set, and the actual maximum value loss amount as the target variable, the PMEV loss regressor in the risk prediction model is trained to obtain a pre-trained PMEV loss regressor; the pre-trained PMEV loss regressor outputs the predicted loss amount.
[0200] In some embodiments, the pre-training module is also used to periodically train the pre-trained risk prediction model based on the execution results generated by the user's transactions.
[0201] In some embodiments, the filtering module 220 is also used to call the strategy generator in the engine, compare the predicted loss amount with the acceptable value extraction limit, and generate multiple candidate strategies based on preset parameters when the predicted loss amount is greater than the acceptable value extraction limit.
[0202] The cost-benefit simulator in the engine is invoked to predict the simulation results of each candidate strategy under the current market conditions; the simulation results include the expected residual maximum value extraction, the expected gas cost, and the expected failure probability;
[0203] The decision optimizer in the engine is invoked to calculate the expected net return of each candidate strategy after risk adjustment, based on the simulation results of each candidate strategy, under the constraint of the user's predicted loss amount, so as to select the target strategy from the candidate strategies.
[0204] In some embodiments, candidate strategies include a first strategy of adaptive slippage adjustment, a second strategy of order splitting, a third strategy of trading channel switching, and a fourth strategy that combines one or more strategies.
[0205] It should be noted that the above modules can be functional modules or program modules, and can be implemented through software or hardware. For modules implemented through hardware, the above modules can reside in the same processor; or the above modules can be located in different processors in any combination.
[0206] This embodiment also provides a computer device, including a memory and a processor, wherein the memory stores a computer program and the processor is configured to run the computer program to perform the steps in any of the above method embodiments.
[0207] Optionally, the computer device may further include a transmission device and an input / output device, wherein the transmission device is connected to the processor and the input / output device is connected to the processor.
[0208] Optionally, in this embodiment, the processor can be configured to perform the following steps via a computer program:
[0209] S21, Input the user-set transaction parameters and the real-time feature vector of the constructed multi-source data into the pre-trained risk prediction model to obtain the risk probability and the predicted loss amount; the transaction parameters include the acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model is pre-trained under the decision constraint of the acceptable value extraction upper limit;
[0210] S22, when the predicted loss amount is greater than the acceptable value extraction limit, generate multiple candidate strategies, calculate the expected residual maximum value extraction and expected net profit for each candidate strategy; and select the target strategy from the candidate strategies under the constraint of the predicted loss amount.
[0211] S23, based on transaction information, execute the user's transaction according to the target strategy.
[0212] It should be noted that the specific examples in this embodiment can refer to the examples described in the above embodiments and optional implementations, and will not be repeated in this embodiment.
[0213] Furthermore, in conjunction with the real-time risk quantification trading methods provided in the above embodiments, this embodiment can also provide a storage medium for implementation. This storage medium stores a computer program; when executed by a processor, the computer program implements any of the real-time risk quantification trading methods described in the above embodiments.
[0214] It should be noted that all information and data involved in this application are authorized by the user or fully authorized by all parties and will be used legally.
[0215] It should be understood that the specific embodiments described herein are merely illustrative of the application and not intended to limit it. All other embodiments derived by those skilled in the art based on the embodiments provided in this application without inventive effort are within the scope of protection of this application.
[0216] Obviously, the accompanying drawings are merely some examples or embodiments of this application. Those skilled in the art can apply this application to other similar situations based on these drawings without any creative effort. Furthermore, it is understood that although the work done in this development process may be complex and lengthy, for those skilled in the art, certain design, manufacturing, or production modifications made based on the technical content disclosed in this application are merely conventional technical means and should not be considered as insufficient disclosure of this application.
[0217] The term "embodiment" in this application refers to a specific feature, structure, or characteristic described in connection with an embodiment that may be included in at least one embodiment of this application. The appearance of this phrase in various places in the specification does not necessarily imply the same embodiment, nor does it imply that it is mutually exclusive with or independent of other embodiments. It will be clearly or implicitly understood by those skilled in the art that the embodiments described in this application may be combined with other embodiments without conflict.
[0218] The embodiments described above are merely illustrative of several implementation methods of this application, and while the descriptions are relatively specific and detailed, they should not be construed as limiting the scope of patent protection. It should be noted that those skilled in the art can make various modifications and improvements without departing from the concept of this application, and these all fall within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the appended claims.
Claims
1. A method of trading that quantifies risk in real time, characterized by, The method comprises the following steps: inputting a transaction parameter set by a user and a real-time feature vector of constructed multi-source data into a pre-trained risk prediction model to obtain a risk probability and a predicted loss amount; the transaction parameter comprises an acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model is obtained by pre-training under the decision constraint of the acceptable value extraction upper limit; when the predicted loss amount is greater than the acceptable value extraction upper limit, generating a plurality of candidate strategies, calculating an expected residual maximum value extraction and an expected net income corresponding to each candidate strategy, and selecting a target strategy from the candidate strategies under the constraint of the predicted loss amount; executing the transaction of the user based on the transaction information according to the target strategy.
2. The method of trading that quantifies risk in real time according to claim 1, wherein, The method further comprises the following steps: constructing a real-time feature vector of multi-source data, which comprises the following steps: collecting multi-source data in real time; the multi-source data comprises on-chain data and CEX data; extracting features from the multi-source data to obtain a plurality of sub-features; combining the plurality of sub-features into the real-time feature vector.
3. The method of trading that quantifies risk in real time according to claim 2, wherein, The plurality of sub-features are transaction self-features, on-chain liquidity pool features, memory pool microstructure features and CEX-DEX features.
4. The method of trading with real-time quantification of risk according to any one of claims 1 to 3, wherein, The method further comprises the following steps: training an original risk prediction model to obtain a pre-trained risk prediction model, which comprises the following steps: labeling a target variable of historical multi-source data to obtain a training label; the target variable comprises whether to be sandwiched and an actual maximum value extraction loss amount; extracting a plurality of sub-features corresponding to to-be-predicted transaction information to obtain a prediction feature vector; training an MEV risk probability classifier in the original risk prediction model by taking historical multi-source data with the training label as a training set, taking whether to be sandwiched as a target variable, to obtain a pre-trained MEV risk probability classifier; the pre-trained MEV risk probability classifier outputs a risk probability; training a PMEV loss regressor in the original risk prediction model by taking historical multi-source data with a training label of being sandwiched as a training set and taking an actual maximum value extraction loss amount as a target variable, to obtain a pre-trained PMEV loss regressor; the pre-trained PMEV loss regressor outputs a predicted loss amount.
5. The method of trading with real-time quantification of risk according to claim 4, wherein, The method further comprises the following steps: periodically training the pre-trained risk prediction model based on an execution result generated by executing the transaction of the user.
6. The method of trading to quantify risk in real time of claim 4, wherein, when the predicted loss amount is greater than the acceptable value extraction upper limit, generating a plurality of candidate strategies, calculating an expected residual maximum value extraction and an expected net income corresponding to each candidate strategy, and selecting a target strategy from the candidate strategies under the constraint of the predicted loss amount; and selecting a target strategy from the candidate strategies under the constraint of the predicted loss amount, comprising the following steps: calling a strategy generator in an engine, comparing the predicted loss amount and the acceptable value extraction upper limit, and generating a plurality of candidate strategies based on preset parameters when the predicted loss amount is greater than the acceptable value extraction upper limit; calling a cost-effectiveness simulator in the engine to predict a simulation result of each of the candidate strategies under current market conditions; the simulation result including an expected residual maximum value extraction, an expected gas cost, and an expected failure probability; calling a decision optimizer in the engine to calculate a risk-adjusted expected net benefit of each of the candidate strategies based on the simulation result of each of the candidate strategies under a constraint of the predicted loss amount of the user; and to select a target strategy from the candidate strategies.
7. The method of trading with real-time quantification of risk of claim 4, wherein, the candidate strategies including a first strategy of adaptive slippage adjustment, a second strategy of order splitting, a third strategy of transaction channel switching, and a fourth strategy of mixing one or more strategies.
8. A transaction device that quantifies risk in real time, characterized by, comprising: a prediction module, a screening module, and an execution module; the prediction module configured to input a transaction parameter set by a user and a real-time feature vector of constructed multi-source data into a pre-trained risk prediction model to obtain a risk probability and a predicted loss amount; the transaction parameter including an acceptable value extraction upper limit and transaction information; the pre-trained risk prediction model being pre-trained under a decision constraint of the acceptable value extraction upper limit; the screening module configured to generate a plurality of candidate strategies when the predicted loss amount is greater than the acceptable value extraction upper limit, to calculate an expected residual maximum value extraction and an expected net benefit corresponding to each candidate strategy, and to select a target strategy from the candidate strategies under a constraint of the predicted loss amount; the execution module configured to execute the transaction of the user according to the target strategy based on the transaction information. 9.A computer device, comprising a memory and a processor, and characterized in that, The memory stores a computer program, and the processor is configured to run the computer program to execute the steps of the real-time risk quantification transaction method of any one of claims 1-7.
10. A computer-readable storage medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the steps of the real-time risk quantification transaction method of any one of claims 1-7.
Citation Information
Patent Citations
Blockchain transaction risk control method
CN113807844A
Attack detection method and system for floating token interaction, terminal and storage medium
CN118138333A
Current limiting method and device for building block, electronic equipment and computer program product
CN119402503A
Transaction processing method and device in block chain, electronic equipment and storage medium
CN119515386A
Abnormal transaction data early warning method and device based on block chain transaction pool
CN120338784A