A time-varying supply-demand adaptive transaction matching method and system based on a blockchain
Patent Information
- Application Number
- CN202611382576.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-09-08
- Publication Date
- 2026-10-09
AI Technical Summary
[0007]然而,现有基于区块链的交易系统大多侧重于交易记录与结算过程,对于撮合策略本身仍采用固定机制,缺乏对时变供需关系的自适应能力
1、提出时变供需状态建模方法,通过交易到达率、价格波动率及订单密度等多维指标刻画系统运行状态,并经滑动窗口平滑得到实时供需状态向量,实现对交易环境的动态感知。
Smart Images

Figure CN122887592A_ABST
Abstract
Description
Technical Field
[0001] This invention belongs to the field of distributed transaction system technology, and in particular relates to a time-varying supply and demand adaptive transaction matching method and system based on blockchain. Background Technology
[0002] With the rapid development of the data factor market and the digital economy, transaction models based on internet platforms are becoming increasingly popular. Transaction matching, as the core mechanism connecting supply and demand, plays a crucial role in financial transactions, data transactions, and digital service markets. In practical applications, transaction systems typically face significant time-varying supply and demand characteristics, such as sudden increases in transaction requests, dynamic fluctuations in market prices, and highly uneven order distribution. These factors collectively lead to a highly dynamic and uncertain trading environment.
[0003] Most existing trading matching mechanisms employ fixed strategies, such as price priority or time priority rules. While these mechanisms exhibit good stability in static or weakly dynamic environments, their limitations become increasingly apparent in time-varying supply and demand scenarios. On one hand, fixed matching strategies struggle to dynamically adjust to system load and market changes, easily leading to increased matching latency and exacerbated system congestion in high-frequency trading scenarios. On the other hand, under conditions of drastic price fluctuations or high order concentration, a single strategy struggles to balance matching efficiency and resource utilization, thus impacting overall trading performance.
[0004] Furthermore, traditional trading systems typically rely on centralized matching platforms to complete order matching and result confirmation. This model suffers from problems such as opaque matching processes, difficulty in independently verifying results, and susceptibility to tampering of transaction records. In open trading environments with multi-party collaboration, these issues further impact the system's credibility and auditability, hindering its application in high-value or heavily regulated scenarios.
[0005] Blockchain technology, as a decentralized distributed ledger technology, possesses characteristics such as data immutability, traceability, and automatic execution of smart contracts, providing a new technological path to solve the trust issues in the transaction matching process. By deploying the transaction confirmation and result verification process on the blockchain, the public verification and reliable recording of matching results can be achieved, thereby enhancing the transparency and security of the system.
[0006] For example, Chinese patent document CN115239443A discloses a blockchain-based transaction matching method, apparatus, device, and medium. The implementation scheme is as follows: obtaining a transaction request for a target element; wherein, the counterparty of the transaction request is undetermined; during the execution of the transaction request, reading available counterparty transaction information from an off-chain queue; matching the original transaction information in the transaction request with the counterparty transaction information according to matching rules to obtain a matching result; performing on-chain operations based on the matching result, and updating the off-chain queue based on the matching result.
[0007] However, most existing blockchain-based trading systems focus on transaction recording and settlement processes, while still using fixed mechanisms for matching strategies, lacking the ability to adapt to time-varying supply and demand relationships.
[0008] Therefore, how to build a trading mechanism that can dynamically adjust the matching strategy according to the time-varying supply and demand status in the trusted environment provided by blockchain, and achieve synergistic optimization of matching efficiency and system reliability, has become a key technical problem that urgently needs to be solved in the field of distributed trading systems. Summary of the Invention
[0009] To address the problems existing in the aforementioned background technology, this invention provides a blockchain-based time-varying supply and demand adaptive transaction matching method and system. This system can dynamically adjust the matching strategy according to the time-varying supply and demand status, thereby improving the system's matching efficiency while ensuring the verifiability of transaction results and the reliability of system operation.
[0010] A blockchain-based time-varying supply and demand adaptive transaction matching method includes the following steps: (1) In discrete time The system samples the trading environment and defines the instantaneous supply and demand status. ;in , , These represent transaction arrival rate, price volatility, and order density, respectively. (2) For instantaneous supply and demand status Smooth supply and demand status compared to the previous moment Perform exponentially weighted smoothing to obtain the smoothed supply and demand state at the current moment. After normalization, the normalized state is obtained. ; (3) For the normalized state Applying a Softmax mapping with a temperature coefficient yields adaptive weight vectors corresponding to transaction arrival rate, price volatility, and order density. , , ; (4) Define the set of matching mechanisms Includes price priority mechanism Time priority mechanism With hybrid matching mechanism ; (5) Based on the adaptive weight vector, it is a set of matching mechanisms. Each mechanism in Calculate the basic utility in the current state and introduce a switching cost hysteresis term to obtain the overall utility; (6) Based on the obtained comprehensive utility, in the set of matching mechanisms The optimal matching mechanism at the current moment is determined by the utility maximization criterion. ; (7) Select the optimal matching mechanism The order is sent to the off-chain matching module for high-frequency order processing, where orders are sorted and matching results are generated. ; (8) On the matching results The cryptographic digest is calculated and submitted to the on-chain smart contract in the form of a transaction, and the result verification and transaction confirmation are completed on the chain.
[0011] Furthermore, in step (1), the transaction arrival rate... This represents the number of orders within a unit of time window, reflecting the strength of order requests; the price volatility... Indicates recent The standard deviation of historical transaction prices is used to characterize the drastic changes in market prices; the order density mentioned above... It represents the degree of order clustering within a unit price range of the mean price neighborhood, and is used to characterize the concentration of order distribution.
[0012] Furthermore, in step (2), the smoothed supply and demand state at the current moment is obtained. The specific formula is as follows: ; in, , is the smoothing factor.
[0013] Furthermore, in step (3), the adaptive weight vector is obtained. , , The specific formula is as follows: ; in, Normalized state The One component; , where is the temperature coefficient; the weights satisfy . ,and The larger the weight, the more concentrated it becomes towards the most prominent state dimension at present; when At that time, the weights degenerate into taking the maximum normalized component. The rest are taken The unique heat vector.
[0014] Furthermore, in step (5), the set of matching mechanisms is... Each mechanism in Calculate the basic utility in the current state, specifically as follows: For each mechanism Assigning ability profile vectors The components represent the relative effectiveness of the mechanism in reducing queuing delay, enhancing price discovery, and balancing congestion and fairness, respectively, with a value range of [value range missing]. ; Each mechanism Basic utility in the current state Defined as the weighted inner product of the adaptive weights and their capability profile vectors, the expression is: .
[0015] Furthermore, in step (5), a switching cost hysteresis term is introduced to obtain the overall utility. The formula is: ; in, For the switching cost coefficient, For indicator functions, when Different from the mechanism selected in the previous moment Time to take .
[0016] Furthermore, in step (6), the optimal matching mechanism at the current moment is determined. The formula is: ; When multiple mechanisms have equal utility, priority is determined based on business settings. Perform deterministic selection.
[0017] Furthermore, in step (8), the result verification specifically includes: Do the traded pairs satisfy the selected optimal matching mechanism? The matching rules, whether the transaction price and quantity are consistent with the on-chain order summary, and whether the conservation constraints are satisfied.
[0018] A blockchain-based time-varying supply and demand adaptive transaction matching system includes a memory and one or more processors. The memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the aforementioned blockchain-based time-varying supply and demand adaptive transaction matching method.
[0019] Compared with the prior art, the present invention has the following beneficial effects: 1. A time-varying supply and demand state modeling method is proposed. The system operation state is characterized by multi-dimensional indicators such as transaction arrival rate, price volatility and order density. The real-time supply and demand state vector is obtained by smoothing through a sliding window, so as to realize the dynamic perception of the trading environment.
[0020] 2. A state-driven method for selecting the optimal matching mechanism is proposed. After normalizing the system state, the method maps the comprehensive utility of each matching mechanism to adaptive weights and mechanism capability profiles. A switching cost hysteresis term is introduced, and the method adaptively switches between price-priority, time-priority, and hybrid matching mechanisms based on the utility maximization criterion.
[0021] 3. Design an on-chain and off-chain collaborative transaction matching architecture, complete efficient matching calculations off-chain, and complete result verification and transaction confirmation on-chain, balancing system performance and data credibility. Attached Figure Description
[0022] To more clearly illustrate the technical solutions in the embodiments of the present invention, the accompanying drawings used in the description of the embodiments will be briefly introduced below. Obviously, the accompanying drawings described below are only some embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0023] Figure 1 This is a flowchart of a blockchain-based time-varying supply and demand adaptive transaction matching method according to an embodiment of the present invention. Detailed Implementation
[0024] The technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0025] It should be noted that, unless otherwise specified, the features in the following embodiments and implementation methods can be combined with each other.
[0026] like Figure 1As shown, this embodiment provides a blockchain-based time-varying supply and demand adaptive transaction matching method, which matches transactions at each discrete moment. The process is executed sequentially from step S1 to step S11, with the output of the previous step serving as the input for the next step, forming a complete processing chain.
[0027] In this embodiment, the parameter is set as: sliding time window Volatility sample size Order density range half width Smoothing factor Temperature coefficient Switching cost coefficient Threshold , , A profile of the matching mechanism's capabilities. , , The mechanism selected in the previous moment was... The smoothed state at the previous time step was .
[0028] The following steps will be explained in sequence: Step S1: Collect multi-dimensional supply and demand status indicators.
[0029] The system in discrete time The following sample is taken of the trading environment, and the system supply and demand state vector is defined as follows: ,in , , These represent trade arrival rate, price volatility, and order density, respectively. First, trade arrival rate... This represents the number of orders within a unit time window, reflecting the intensity of order requests, and is defined as follows: ; in express The cumulative number of orders before the time. This represents the length of the sliding time window. This can be obtained by counting and statistically analyzing the time series of order arrivals. Secondly, price volatility... Used to depict the drastic changes in market prices, taking the most recent... The standard deviation of historical transaction prices is calculated using the following formula: ; in This is a historical transaction price series. Take its mean. Finally, order density. This indicates the degree of order clustering within a unit price range near the mean price, used to characterize the centrality of order distribution, and is calculated as follows: ; in, This indicates that the price has fallen into the range. The number of orders within, The interval is half-width.
[0030] In this embodiment, Within a one-minute window, the cumulative number of orders increased from [previous value]. Increase to Transaction arrival rate . recent The transaction price of the data product (unit: yuan / item) is Its mean Price volatility In the interval The number of orders within Order density Therefore, the instantaneous state .
[0031] Step S2: Smoothly update the sliding window.
[0032] To suppress sampling noise and improve the robustness of state characterization, the instantaneous state obtained in step S1 is... Smooth state compared to the previous time step Perform exponentially weighted smoothing to obtain the smoothed supply and demand state vector at this moment. As shown in the following formula: ; in As a smoothing factor, The larger the value, the more sensitive it is to the current sample. Output of step S2 It is the sole basis for subsequent mechanism selection.
[0033] In this embodiment, the supply and demand state vector is smoothed. .
[0034] Step S3: Normalize the state indicators. Because... , , The three indicators have different dimensions and significantly different numerical ranges, making direct comparison or weighting impossible. Therefore, this invention uses preset thresholds for each indicator. For reference, saturation normalization is used to map each indicator to... The interval is as follows: ; The characteristic of this normalization is that its normalized value is exactly equal to the threshold value of a certain indicator. When the indicator far exceeds the threshold, the normalized value approaches the threshold. This smoothly embeds the segmented criterion of "whether the threshold is exceeded" into the continuous utility calculation, providing a basis for the threshold segmentation decision in step S7 to become a special case of the utility model. Let the normalized state be... .
[0035] In this embodiment, , , That is, the normalized state All three items are greater than This indicates that the current system has exceeded its respective thresholds in terms of load, volatility, and congestion.
[0036] Step S4: State adaptive weight calculation.
[0037] To enable the selection of the matching mechanism to adaptively adjust its emphasis based on the current primary pressure source of the system, this invention applies a normalized state... Applying a temperature-dependent Softmax mapping yields adaptive weight vectors that act on the time delay, price, and congestion dimensions, respectively. As shown in the following formula: ; in for The One portion, This is the temperature coefficient. The weights satisfy... ,and The larger the weight, the more concentrated it becomes towards the most prominent state dimension at present; when At that time, the weights degenerate into taking the maximum normalized component. The rest are taken The unique heat vector.
[0038] In this embodiment, take The weights are calculated. The sum of the weights is Furthermore, it leans slightly towards the price dimension and the congestion dimension.
[0039] Step S5: Mechanism capability profile and basic utility calculation.
[0040] Predefined matching mechanism set These are the price priority mechanisms. Time priority mechanism With hybrid matching mechanism To quantify the adaptability of different mechanisms across different state dimensions, this invention provides a method for each mechanism. Assigning ability profile vectors The components represent the relative effectiveness of the mechanism in reducing queuing delay, enhancing price discovery, and balancing congestion and fairness, respectively, with a value range of [value range missing]. Based on this, the mechanism The basic utility in the current state is defined as the weighted inner product of the adaptive weights and their capability profile, as follows: ; As can be seen from the above formula, when a certain state dimension becomes the dominant pressure (its weight) When the value is relatively large, the mechanism with stronger capabilities in that dimension will obtain higher basic utility.
[0041] In this embodiment, the basic utility of each mechanism is as follows: ; ; .
[0042] Step S6: Switch between cost delay and overall utility calculation.
[0043] If the selection is based solely on maximizing basic utility, when the utilities of two mechanisms are similar, small fluctuations in the state will cause frequent switching between mechanisms in adjacent time steps, increasing system overhead and disrupting matching continuity. Therefore, this invention introduces a switching cost hysteresis term to address deviations from the previously selected mechanism. The candidate mechanism is penalized to obtain the comprehensive utility, as shown in the following formula: ; in For the switching cost coefficient, For indicator functions, when When the mechanism selected is different from the one selected in the previous time step Otherwise take This ensures that the new mechanism's base utility gain will only be applied if it exceeds the switching cost. Switching occurs only at specific times, thereby suppressing unnecessary oscillations.
[0044] In this embodiment, the previous time-instance mechanism is as follows: ,right , Apply switching cost : , , .
[0045] Step S7: Select the optimal matching mechanism.
[0046] Based on comprehensive utility, the optimal matching mechanism for this moment is determined according to the utility maximization criterion. As shown in the following formula: ; When multiple mechanisms have equal utility, priority is determined based on business settings. A deterministic selection is performed. The utility-optimal selection function proposed in this invention has the following uniformity: when the temperature coefficient... Switching costs Furthermore, the ability profile is taken as the unique hot form in which each mechanism is dominant in a single dimension (i.e., , , In the delay dimension, price dimension, and congestion dimension respectively. When the optimal matching mechanism is in use, This strictly degenerates into the threshold segmentation decision shown in the following formula: ; In other words, the traditional threshold segmentation rule is a special case of the utility-optimal selection function of this invention. In contrast, the selection function of this invention uses continuous utility to characterize the fitness of each mechanism in multi-dimensional states, realizes joint decision-making in multi-dimensional states through adaptive weights, and ensures the stability of mechanism switching through switching cost hysteresis terms. Thus, while retaining the interpretability of the threshold rule, it significantly improves the matching accuracy and robustness of the strategy and market state.
[0047] In this embodiment, That is, in situations where orders are highly concentrated ( In a state of significantly exceeding the threshold, although the responsibility lies with... Switch to Despite the cost, the utility gain of the hybrid matching mechanism is still sufficient to trigger a switch, and the system chooses the hybrid matching mechanism to balance fairness and efficiency. This result is consistent with the intuition of threshold segmentation and reflects the joint trade-off of multidimensional states in the utility model.
[0048] Step S8: Off-chain matching execution.
[0049] The mechanism selected in step S7 The order is sent to the off-chain matching module for high-frequency order processing. Let the current order set be... The off-chain module uses the sorting function corresponding to the selected mechanism. Sort the orders as follows: ; in This is the sorted order sequence. Then in... The matching rules are executed to generate the matching results, as shown in the following formula: ; It records all traded pairs, their prices, and quantities at any given moment. Off-chain execution reduces the computational burden on the blockchain system and improves processing efficiency.
[0050] In this embodiment, the selected (Price priority, then time priority for orders with the same price). The current buy and sell order set is as follows (order number, price, quantity, time): Buy Orders ; Selling orders .
[0051] Sort by: Order of purchase price reduction The order of sell orders with increasing prices is as follows: Matching transactions one by one according to the best bid-ask pair (the transaction price is the midpoint between the bid and ask prices) yields the matching results. : , , Total transactions Data products.
[0052] Step S9: Summarize and Submit.
[0053] The matching results are summarized and submitted on-chain. When a user submits an order, their key information is summarized and stored on the blockchain; the matching results are generated off-chain. Then, its cryptographic digest is calculated and submitted to the on-chain smart contract in the form of a transaction, as follows: ; Soon Its summary is packaged and written into the block to be confirmed.
[0054] In this embodiment, for Calculate the SHA-256 digest to obtain (First 16 hexadecimal digits) The summary is packaged and submitted to the smart contract and written into the pending confirmation block.
[0055] Step S10: On-chain verification and ledger writing.
[0056] The smart contract performs a consistency check on the submitted matching results, as follows: ; The verification includes: whether the traded pair meets the selected mechanism. The matching rules, whether the transaction price and quantity are consistent with the on-chain order summary, and whether the conservation constraints are satisfied. When a transaction is confirmed, the confirmed transaction result is written into the blockchain ledger to achieve immutable recording and traceable auditing; otherwise, the result is rejected and the transaction is rolled back to the off-chain for rematching.
[0057] In this embodiment, the smart contract verifies each transaction pair: the buy price is not lower than the sell price, and the transaction volume is conserved. quantity, Quantity), and the price is consistent with the on-chain order summary, therefore ,Will Write the transaction to the ledger to confirm the transaction.
[0058] Step S11: Performance feedback and parameter closed-loop update.
[0059] This invention feeds back the execution performance confirmed on-chain to the preceding stages, forming a closed-loop adaptive mechanism. Specifically, it calculates performance indicators such as actual matching latency and success rate at any given moment based on the on-chain confirmation results. And based on this, the threshold , ability portrait and switching costs The parameters are fine-tuned online, as shown in the following formula: ; in, This represents the set of adjustable parameters mentioned above. The learning rate is used. The updated parameters are used in the next time step. Steps S3 to S7 enable the system to continuously approach the optimal matching strategy during long-term operation. Thus, state awareness (S1–S2), mechanism selection (S3–S7), off-chain matching (S8), on-chain confirmation (S9–S10), and performance feedback (S11) form a complete closed loop, which is executed cyclically.
[0060] In this embodiment, the actual transaction rate and latency, among other performance metrics, are statistically analyzed in this matching process. Online fine-tuning of parameters such as thresholds and capability profiles is provided. Use it at all times.
[0061] The above embodiments demonstrate that the closed-loop matching process proposed in this invention can be calculated step by step and executed given actual data, and the matching results can be independently verified on the chain, thereby verifying the feasibility of the present invention.
[0062] This embodiment also provides a blockchain-based time-varying supply and demand adaptive transaction matching system, including a memory and one or more processors. The memory stores executable code, and when the one or more processors execute the executable code, they are used to implement the blockchain-based time-varying supply and demand adaptive transaction matching method described in the above embodiment.
[0063] The embodiments described above provide a detailed explanation of the technical solutions and beneficial effects of the present invention. It should be understood that the above descriptions are merely specific embodiments of the present invention and are not intended to limit the present invention. Any modifications, additions, and equivalent substitutions made within the scope of the principles of the present invention should be included within the protection scope of the present invention.
Claims
1. A time-varying supply and demand adaptive transaction matching method based on blockchain, characterized in that, Includes the following steps: (1) In discrete time The system samples the trading environment and defines the instantaneous supply and demand status. ;in , , These represent transaction arrival rate, price volatility, and order density, respectively. (2) For instantaneous supply and demand status Smooth supply and demand status compared to the previous moment Perform exponentially weighted smoothing to obtain the smoothed supply and demand state at the current moment. After normalization, the normalized state is obtained. ; (3) For the normalized state Applying a Softmax mapping with a temperature coefficient yields adaptive weight vectors corresponding to transaction arrival rate, price volatility, and order density. , , ; (4) Define the set of matching mechanisms Includes price priority mechanism Time priority mechanism With hybrid matching mechanism ; (5) Based on the adaptive weight vector, it is a set of matching mechanisms. Each mechanism in Calculate the basic utility in the current state and introduce a switching cost hysteresis term to obtain the overall utility; (6) Based on the obtained comprehensive utility, in the set of matching mechanisms The optimal matching mechanism at the current moment is determined by the utility maximization criterion. ; (7) Select the optimal matching mechanism The order is sent to the off-chain matching module for high-frequency order processing, where orders are sorted and matching results are generated. ; (8) On the matching results The cryptographic digest is calculated and submitted to the on-chain smart contract in the form of a transaction, and the result verification and transaction confirmation are completed on the chain.
2. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 1, characterized in that, In step (1), the transaction arrival rate This represents the number of orders within a unit of time window, reflecting the strength of order requests; the price volatility... Indicates recent The standard deviation of historical transaction prices is used to characterize the drastic changes in market prices; the order density mentioned above... It represents the degree of order clustering within a unit price range of the mean price neighborhood, and is used to characterize the concentration of order distribution.
3. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 1, characterized in that, In step (2), the smoothed supply and demand state at the current moment is obtained. The specific formula is as follows: ; in, , is the smoothing factor.
4. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 1, characterized in that, In step (3), the adaptive weight vector is obtained. , , The specific formula is as follows: ; in, Normalized state The One component; , where is the temperature coefficient; the weights satisfy . .
5. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 1, characterized in that, In step (5), the matching mechanism set is defined. Each mechanism in Calculate the basic utility in the current state, specifically as follows: For each mechanism Assigning ability profile vectors The components represent the relative effectiveness of the mechanism in reducing queuing delay, enhancing price discovery, and balancing congestion and fairness, respectively, with a value range of [value range missing]. ; Each mechanism Basic utility in the current state Defined as the weighted inner product of the adaptive weights and their capability profile vectors, the expression is: 。 6. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 5, characterized in that, In step (5), a switching cost hysteresis term is introduced to obtain the overall utility. The formula is: ; in, For the switching cost coefficient, For indicator functions, when Different from the mechanism selected in the previous moment Time to take .
7. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 6, characterized in that, In step (6), the optimal matching mechanism for the current moment is determined. The formula is: ; When multiple mechanisms have equal utility, priority is determined based on business settings. Perform deterministic selection.
8. The blockchain-based time-varying supply and demand adaptive transaction matching method according to claim 1, characterized in that, In step (8), the result verification specifically includes: Do the traded pairs satisfy the selected optimal matching mechanism? The matching rules, whether the transaction price and quantity are consistent with the on-chain order summary, and whether the conservation constraints are satisfied.
9. A blockchain-based time-varying supply and demand adaptive transaction matching system, characterized in that, The method includes a memory and one or more processors, wherein the memory stores executable code, and the one or more processors execute the executable code to implement the blockchain-based time-varying supply and demand adaptive transaction matching method as described in any one of claims 1-8.
Citation Information
Patent Citations
Transaction matching method and device based on block chain, equipment and medium
CN115239443A