Out-of-order protection method for transaction system, transaction system, device and medium
By processing order return information sequentially in the securities trading system and using a post-processing module to filter out unnecessary information, the problem of out-of-order parent order and child order returns was solved, improving system performance and the accuracy of client information processing.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- SHANGHAI KAFANG TECH CO LTD
- Filing Date
- 2025-10-13
- Publication Date
- 2026-05-08
AI Technical Summary
In securities trading systems, the timing of parent order reports and child order reports is prone to being out of order, causing clients to receive out-of-order order report information. Existing technologies have solved the out-of-order problem by processing business logic within transaction locks, but this has impacted system performance.
The business processing module receives order feedback information in sequence, updates the local database and generates a serial number ID, and uses a post-out-of-order processing module to filter out unnecessary order feedback information, ensuring that the message push module sends the message to the client in order.
Without affecting system performance, this method avoids clients receiving out-of-order order feedback information, thereby improving business processing speed and system performance.
Smart Images

Figure CN121235819B_ABST
Abstract
Description
Technical Field
[0001] This application relates to the field of data processing technology, and in particular to a method for protecting trading systems from disorder, a trading system, equipment, and media. Background Technology
[0002] In the financial sector, when a securities trading system receives a user's order, the order is sent as a master order to an external brokerage firm. The external brokerage firm typically splits the master order into multiple sub-orders for separate securities transactions. The securities trading system then returns the sub-order data through a channel, and the master order data updates the system's master order completion status.
[0003] Because parent order reports and child order reports are pushed to the securities trading system through independent thread queues, they can create asymmetrical timing processing scenarios. For example, within a short period, one thread receives the child order report information (updating the parent order's transaction quantity and status as partially completed), while another thread receives the parent order report information, such as a partial cancellation report. The processing of these two parent order statuses within the transaction is correct. However, when updating the parent order status report, because the push step is executed outside of a lock, it can easily lead to out-of-order processing of the two order reports received within a short period (e.g., receiving the child order report information, then receiving the parent order's partial cancellation report, but sending the parent order's partial cancellation report to the client first, then sending the child order report information). This results in downstream system clients receiving order reports out of order.
[0004] To address the aforementioned issues, existing technologies also process the business logic (network I / O operations) of each thread handling transaction pushes within the transaction lock. While this resolves the out-of-order issue, the entire process (business transaction processing and business transaction pushes) is serial. The transaction lock must wait for the entire process to complete before executing the next thread's information, resulting in slow data processing and impacting system performance. Summary of the Invention
[0005] This application provides a method, system, device, and medium for protecting the order of transactions in a transaction system. It enables the message push module to send order feedback information to the client in sequence without affecting system performance, thus preventing the client from receiving out-of-order order feedback information.
[0006] In a first aspect, embodiments of this application provide a method for out-of-order protection in a transaction system. The method is applied to a transaction system including a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock. The method includes:
[0007] The business processing module receives order feedback information from a preset channel in sequence. The order feedback information includes the target parent order identifier and status feedback information.
[0008] The business processing module updates the parent order record associated with the target parent order identifier in the local database according to the status report information, and generates a target sequence number ID by incrementing it. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume.
[0009] The order feedback information is sent to the post-out-of-order processing module through the business processing module.
[0010] The post-out-of-order processing module determines whether there exists a sequence number ID in the cache container that is associated with the target master unit identifier and is larger than the target sequence number ID;
[0011] If there exists a sequence number ID associated with the target parent order identifier and that is larger than the target sequence number ID, then the order report information is filtered through the post-out-of-order processing module.
[0012] If there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order feedback information is sent to the message push module, and the order feedback information is sent to the client associated with the target parent order identifier through the message push module.
[0013] Secondly, embodiments of this application also provide a transaction system, which includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock, wherein:
[0014] The business processing module is used to receive order feedback information from a preset channel in sequence. The order feedback information includes a target parent order identifier and status feedback information. It updates the parent order record associated with the target parent order identifier in the local database according to the status feedback information, and generates a target sequence number ID by incrementing the sequence number. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume. Finally, it sends the order feedback information to the post-out-of-order processing module.
[0015] The post-out-of-order processing module is used to determine whether there is a serial number ID in the cache container that is associated with the target parent order identifier and is larger than the target serial number ID; if there is a serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is filtered; if there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is sent to the message push module.
[0016] The message push module is used to send the order feedback information to the client associated with the target parent order identifier.
[0017] Thirdly, embodiments of this application also provide a computer device, which includes a memory and a processor, wherein the memory stores a computer program, and the processor executes the computer program to implement the above-described method.
[0018] Fourthly, embodiments of this application also provide a computer-readable storage medium storing a computer program, the computer program including program instructions that, when executed by a processor, can implement the above-described method.
[0019] This application provides a method for out-of-order protection in a transaction system, a transaction system, a device, and a medium. The method is applied to a transaction system, which includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock. This embodiment of the application places the push logic (message push module) outside the business transaction lock, which can reduce the time that a single order report message occupies the business transaction lock, thereby reducing the transaction processing time under high concurrency, improving business processing speed, and ensuring system performance. In addition, this embodiment of the application can ensure that the message push module only sends the order report message corresponding to the latest received system-sent order parent identifier (the cache container does not contain a sequence number ID associated with the target parent identifier and which is larger than the target sequence number ID). For order report messages received before the latest received order report message but not yet sent (the cache container contains a sequence number ID associated with the target parent identifier and which is larger than the target sequence number ID), they are directly filtered out to avoid sending old information after new information. This allows the message push module to send order report messages to the client in order, avoiding the client receiving out-of-order order report messages. Attached Figure Description
[0020] To more clearly illustrate the technical solutions of the embodiments of this application, the drawings used in the description of the embodiments will be briefly introduced below. Obviously, the drawings described below are some embodiments of this application. For those skilled in the art, other drawings can be obtained based on these drawings without creative effort.
[0021] Figure 1 A schematic diagram illustrating an application scenario of the out-of-order protection method for a transaction system provided in this embodiment of the application.
[0022] Figure 2 A flowchart illustrating the out-of-order protection method for a transaction system provided in this application embodiment;
[0023] Figure 3 A schematic diagram of the overall process of the out-of-order protection method for a transaction system provided in this application embodiment;
[0024] Figure 4 A schematic block diagram of a transaction system provided in an embodiment of this application;
[0025] Figure 5 A schematic block diagram of a transaction system provided in another embodiment of this application;
[0026] Figure 6 A schematic block diagram of a computer device provided in an embodiment of this application. Detailed Implementation
[0027] The technical solutions of the embodiments of this application will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some, not all, of the embodiments of this application. Based on the embodiments of this application, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of this application.
[0028] It should be understood that, when used in this specification and the appended claims, the terms "comprising" and "including" indicate the presence of the described features, integrals, steps, operations, elements and / or components, but do not exclude the presence or addition of one or more other features, integrals, steps, operations, elements, components and / or collections thereof.
[0029] It should also be understood that the terminology used in this specification is for the purpose of describing particular embodiments only and is not intended to limit the scope of the application. As used in this specification and the appended claims, the singular forms “a,” “an,” and “the” are intended to include the plural forms unless the context clearly indicates otherwise.
[0030] It should also be further understood that the term “and / or” as used in this application specification and the appended claims means any combination of one or more of the associated listed items and all possible combinations, and includes such combinations.
[0031] This application provides a method for protecting trading systems from disorder, a trading system, equipment, and media.
[0032] The execution entity of the out-of-order protection method of the trading system can be the trading system provided in the embodiments of this application, or a computer device that integrates the trading system. The trading system can be implemented in hardware or software, and the computer device can be a terminal or a server. Specifically, the trading system can be a securities trading system (a securities trading system deployed in SaaS). The trading system specifically includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within the business transaction lock.
[0033] Please see Figure 1 , Figure 1 This is a schematic diagram illustrating an application scenario of the out-of-order protection method for a transaction system provided in this application embodiment.
[0034] When the securities trading system 10 receives an order placement instruction (including user identifier and total order amount) sent by a user through the client 20, after verifying the legality of the user placing the order, it automatically generates a target master order corresponding to the order placement instruction. The target master order carries the target master order identifier and the total order amount. Then, it creates a master order record associated with the target master order identifier in the local database and sends the target master order to the brokerage terminal 30. The brokerage terminal 30 usually splits the master order into multiple sub-orders. At this time, the brokerage terminal returns order feedback information to the securities trading system 10 through different channels for different types of orders (master order or sub-order). After receiving the order feedback information, the securities trading system 10 determines whether the order feedback information is the latest feedback information corresponding to the master order. If so, it sends it to the client 20 to avoid the client 20 receiving out-of-order order feedback information.
[0035] Figure 2 This is a flowchart illustrating the out-of-order protection method for a transaction system provided in an embodiment of this application. Figure 2 As shown, the method includes the following steps S110-S160.
[0036] S110. The business processing module receives order feedback information from a preset channel in sequence. The order feedback information includes the target parent order identifier and status feedback information.
[0037] In this embodiment, the preset channel includes a parent order channel corresponding to the parent order reporting thread or a child order channel corresponding to the child order reporting thread. The status reporting information in the order reporting information from the parent order channel includes order cancellation status reporting information or cumulative completion status reporting information. The cumulative completion status reporting information carries the cumulative transaction volume corresponding to the target parent order identifier. The status reporting information in the order reporting information from the child order channel includes parent order completion status reporting information. The parent order completion status reporting information carries the transaction volume of the corresponding child order.
[0038] Specifically, in some embodiments, step S110 includes: receiving order feedback information from preset channels through the business processing module according to the generation time of order feedback information from each preset channel. If both the parent channel and the child channel currently have order feedback information arriving, it is necessary to determine the generation time of the order feedback information, and the business processing module prioritizes obtaining the order feedback information with the earlier generation time.
[0039] On the brokerage terminal side, if a cancellation operation is triggered (such as partial cancellation), subsequent sub-orders will also stop executing. Therefore, generally, for the same parent order (i.e., the same data source) in the system, if a partial cancellation operation is performed on the parent order, no subsequent sub-order order report information will be generated. Thus, for the same parent order in the system, if there is both parent order cancellation information and sub-order order report information (already completed) in the preset channel, the sub-order order report information will occur earlier than the parent order cancellation information. In this case, the sub-order order report information first enters the business transaction lock and is processed by the business processing module.
[0040] In some embodiments, the transaction system further includes a pre-processing module for handling out-of-order data. Before the order feedback information from the preset channel is received sequentially by the business processing module, the method further includes:
[0041] When the preset channel is the parent order channel corresponding to the parent order reporting thread, the pre-order disorder processing module determines whether the cumulative transaction volume in the order reporting information is less than or equal to the parent order transaction volume in the parent order record.
[0042] If the cumulative transaction volume is less than or equal to the parent order transaction volume, the order return information is filtered through the pre-processing disordered order processing module.
[0043] In this embodiment, the pre-order processing module is connected to the master order channel and is used to filter duplicate statuses or expired master order reports in the master order channel.
[0044] For example, brokerage terminals sometimes periodically synchronize the status of parent orders, repeatedly sending the parent order's order feedback information (the status feedback information in the order feedback information is the cumulative partial status feedback information) to the trading system to avoid the loss of child order feedback information. If child order feedback information is lost, the cumulative trading volume will be greater than the parent order's trading volume. In this case, the order feedback information is sent to the business processing module through the pre-processing out-of-order processing module. The business processing module then updates the parent order's trading volume in the associated parent order record to the cumulative trading volume in the current parent order's order feedback information. If the cumulative trading volume is less than or equal to the parent order's trading volume, it indicates that the parent order feedback is lagging (the cumulative trading volume is less than the parent order's trading volume), or it indicates that no child order feedback information has been lost (the cumulative trading volume equals the parent order's trading volume). In this case, there is no need to process the order feedback information; the pre-processing out-of-order processing module directly filters the order feedback information to reduce system load.
[0045] The pre-order processing module can be set inside or outside the business transaction lock; the specific location is not limited in this embodiment.
[0046] In some embodiments, before receiving order feedback information from a preset channel sequentially via the business processing module, the method further includes:
[0047] The system receives an order placement instruction sent by the client, the order placement instruction including a user identifier and a total order amount; performs a validity check on the user corresponding to the user identifier; when the validity check passes, generates a target master order corresponding to the order placement instruction, the target master order carrying the target master order identifier and the total order amount; creates a master order record associated with the target master order identifier in the local database, and sends the target master order to the brokerage terminal, so that the brokerage terminal processes the target master order, and returns the order feedback information to the trading system through the preset channel based on the processing result.
[0048] The legality verification process verifies whether the user who needs to place an order has the qualifications to trade securities and whether the user can conduct securities trading through the trading system provided in this application.
[0049] S120. The business processing module updates the parent order record associated with the target parent order identifier in the local database according to the status report information, and generates a target sequence number ID by incrementing it. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume.
[0050] In some embodiments, the parent order record also stores the total order amount corresponding to the target parent order identifier, and updating the parent order record associated with the target parent order identifier in the local database according to the status report information includes:
[0051] When the status report is an order cancellation status report, the current status of the parent order in the parent order record is updated to the cancellation status; when the status report is a parent order completion (partial success) status report, the parent order transaction volume in the parent order record is updated by accumulating the transaction volume of the sub-orders carried by the parent order completion status report; if the updated parent order transaction volume is equal to the total order amount, the current status of the parent order in the parent order record is updated to the completion status; if the updated parent order transaction volume is less than the total order amount, the current parent order in the parent order record is updated to the partial completion status.
[0052] As can be seen, this application records the status of the corresponding parent order and the current transaction status (total order amount) in real time through the parent order record constructed in the local database.
[0053] The target sequence number ID is either a globally incrementing ID or an ID that increments based on the target parent unit identifier.
[0054] S130. The order feedback information is sent to the post-out-of-order processing module through the business processing module.
[0055] In this embodiment, after the business processing module processes the order report information according to the corresponding business logic, it sends the order report information to the post-out-of-order processing module. The business processing module can then execute the processing of the next order report information. This reduces the time that a single order report information occupies the business transaction lock, thereby reducing the transaction processing time under high concurrency, improving business processing speed, and ensuring system performance.
[0056] The post-out-of-order processing module can be set inside or outside the business transaction lock; the specific location is not limited in this embodiment.
[0057] S140. The post-out-of-order processing module determines whether there is a sequence number ID in the cache container that is associated with the target master unit identifier and is larger than the target sequence number ID. If yes, then proceed to step S150; otherwise, proceed to step S160.
[0058] If there exists a sequence number ID associated with the target parent order identifier and larger than the target sequence number ID, it indicates that the order feedback information to be sent is not the latest. The latest order feedback data (the order feedback data corresponding to the sequence number ID associated with the target parent order identifier and larger than the target sequence number ID) may have already been sent. In this case, if the current order feedback information is sent, out-of-order situations may occur. For example, after sending the order cancellation status feedback information to the client, the parent order completion status feedback information is sent to the client again (in fact, order cancellation is the final state, and the client should not receive parent order completion status feedback information again). This will cause message out-of-order, which may mislead the customer and affect the customer experience.
[0059] S150. The order report information is filtered by the post-out-of-order processing module.
[0060] In this embodiment, if there is a sequence number ID associated with the target parent order identifier and that is larger than the target sequence number ID, it indicates that sending the order report information may result in out-of-order issues. To prevent out-of-order issues, this embodiment filters the order report information.
[0061] S160. The order feedback information is sent to the message push module, and the order feedback information is sent to the client associated with the target parent order identifier through the message push module.
[0062] If there is no sequence number ID associated with the target parent order identifier that is larger than the target sequence number ID, it means that the order feedback information to be sent is the latest, and sending this information will not result in out-of-order delivery.
[0063] In some embodiments, users can also query the transaction status of the corresponding parent order in the trading system in real time through a client. In this case, the steps further include: receiving an order query instruction sent by the client, the order query instruction carrying the target parent order identifier; responding to the order query instruction, generating order feedback information based on the parent order record corresponding to the target parent order identifier; and sending the order feedback information to the client.
[0064] For a further understanding of this application, please refer to Figure 3 This embodiment will provide a detailed description of the application in conjunction with the pre-processing out-of-order module, the business processing module, the post-processing out-of-order module, and the message push module:
[0065] Depend on Figure 3As can be seen, the pre-processing out-of-order module provides a filter to filter out subsequent duplicate state parent order reports (parent order transaction states within the system that have already been processed by child order reports), reducing the load on the business system. Even after filtering by the pre-processing out-of-order module, out-of-order scenarios may still exist, such as completed child order reports and partially withdrawn parent order reports. From a business logic perspective, the system prioritizes processing the completed child order (intermediate state, parent order partially completed) and then processes the partially withdrawn parent order (final state, parent order partially withdrawn). However, the completed child order report and the partially withdrawn parent order report are processed almost within the same millisecond; out-of-order issues may still occur. Therefore, a post-processing out-of-order module is needed to address this.
[0066] At this point, the business processing module within the business transaction lock first processes the sub-order completion report, generating an ID within the transaction (ID1=1 in this example), and then processes the parent order partial cancellation report, generating an ID within the transaction (ID2=2 in this example). After the sub-order and parent order's respective transaction processing is completed, the push logic of the sub-order and parent order may be parallel. Therefore, the message push module may push the business logic processed later first, for example, pushing the parent order partial cancellation (partial cancellation) first, and then pushing the parent order completion report (partial completion of the parent order). To avoid this situation, the post-out-of-order processing module also provides a filter, which filters by comparing IDs. If the ID currently being pushed is greater than the corresponding ID in the cache container, it is pushed through the message push module; otherwise, the corresponding information is filtered out, and the status of the partial completion of the parent order is not pushed. This will not cause out-of-order information received by the client.
[0067] Figure 4 This is a schematic block diagram of a transaction system provided in an embodiment of this application. Figure 4 As shown, corresponding to the out-of-order protection method of the above-described trading system 10, this application also provides a trading system 10. This trading system 10 includes a unit for executing the out-of-order protection method described above, and the trading system 10 can be configured in a terminal or server. Specifically, please refer to... Figure 4 The transaction system 10 includes a business processing module 401, a post-out-of-order processing module 402, and a message push module 403. The business processing module is located within a business transaction lock, wherein:
[0068] The business processing module is used to receive order feedback information from a preset channel in sequence. The order feedback information includes a target parent order identifier and status feedback information. It updates the parent order record associated with the target parent order identifier in the local database according to the status feedback information, and generates a target sequence number ID by incrementing the sequence number. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume. Finally, it sends the order feedback information to the post-out-of-order processing module.
[0069] The post-out-of-order processing module is used to determine whether there is a serial number ID in the cache container that is associated with the target parent order identifier and is larger than the target serial number ID; if there is a serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is filtered; if there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is sent to the message push module.
[0070] The message push module is used to send the order feedback information to the client associated with the target parent order identifier.
[0071] In some embodiments, the preset channel includes a parent order channel corresponding to a parent order reporting thread or a child order channel corresponding to a child order reporting thread. The status report information in the order report information from the parent order channel includes order cancellation status report information or cumulative completion status report information. The cumulative completion status report information carries the cumulative transaction volume corresponding to the target parent order identifier. The status report information in the order report information from the child order channel includes parent order completion status report information. The parent order completion status report information carries the transaction volume of the corresponding child order.
[0072] In some embodiments, please refer to Figure 5 The transaction system 10 further includes a pre-order scrambling module 404, which is used for:
[0073] When the preset channel is the parent order channel corresponding to the parent order report thread, determine whether the cumulative transaction volume in the order report information is less than or equal to the parent order transaction volume in the parent order record;
[0074] If the cumulative transaction volume is less than or equal to the parent order transaction volume, the order return information is filtered.
[0075] In some embodiments, the parent order record also stores the total order amount corresponding to the target parent order identifier. When the business processing module 401 executes the step of updating the parent order record associated with the target parent order identifier in the local database according to the status report information, it is specifically used for:
[0076] When the status report information is an order cancellation status report information, the current status of the parent order in the parent order record is updated to the cancellation status;
[0077] When the status report information is the status report information of the parent order component, the parent order transaction volume in the parent order record is updated by accumulating the transaction volume of the sub-orders carried by the status report information of the parent order component.
[0078] If the updated transaction volume of the master order is equal to the total order volume, then the current master order status in the master order record will be updated to the completed status.
[0079] If the updated transaction volume of the master order is less than the total order volume, then the current master order in the master order record will be updated to a partially completed state.
[0080] In some embodiments, the transaction system 10 is further configured to:
[0081] The system receives an order placement instruction sent by the client, the order placement instruction including a user identifier and a total order amount; performs a validity check on the user corresponding to the user identifier; when the validity check passes, generates a target master order corresponding to the order placement instruction, the target master order carrying the target master order identifier and the total order amount; creates a master order record associated with the target master order identifier in the local database, and sends the target master order to the brokerage terminal, so that the brokerage terminal processes the target master order, and returns the order feedback information to the trading system 10 through the preset channel based on the processing result.
[0082] In some embodiments, the transaction system 10 is further configured to:
[0083] The system receives an order query instruction sent by the client, the order query instruction carrying the target parent order identifier; in response to the order query instruction, it generates order feedback information based on the parent order record corresponding to the target parent order identifier; and sends the order feedback information to the client.
[0084] In some embodiments, the target sequence number ID is a globally incrementing ID or an ID that increments based on the target parent identifier.
[0085] It should be noted that those skilled in the art can clearly understand that the specific implementation process of the above-mentioned transaction system and its various units can be referred to the corresponding descriptions in the foregoing method embodiments. For the sake of convenience and brevity, these details will not be repeated here.
[0086] The aforementioned trading system can be implemented as a computer program, which can be used in, for example... Figure 6 It runs on the computer device shown.
[0087] Please see Figure 6 , Figure 6This is a schematic block diagram of a computer device provided in an embodiment of this application. The computer device 500 can be a terminal or a server. A transaction system is deployed in the computer device 500. The transaction system includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock.
[0088] See Figure 6 The computer device 500 includes a processor 502, a memory, and a network interface 505 connected via a system bus 501. The memory may include a non-volatile storage medium 503 and internal memory 504.
[0089] The non-volatile storage medium 503 may store an operating system 5031 and a computer program 5032. The computer program 5032 includes program instructions that, when executed, cause the processor 502 to perform an out-of-order protection method for a transaction system.
[0090] The processor 502 provides computing and control capabilities to support the operation of the entire computer device 500.
[0091] The internal memory 504 provides an environment for the execution of the computer program 5032 in the non-volatile storage medium 503. When the computer program 5032 is executed by the processor 502, the processor 502 can execute a method for protecting the out-of-order performance of a transaction system.
[0092] This network interface 505 is used for network communication with other devices. Those skilled in the art will understand that... Figure 6 The structure shown is merely a block diagram of a portion of the structure related to the present application and does not constitute a limitation on the computer device 500 to which the present application is applied. The specific computer device 500 may include more or fewer components than those shown in the figure, or combine certain components, or have different component arrangements.
[0093] The processor 502 is used to run a computer program 5032 stored in the memory to perform the following steps:
[0094] The business processing module receives order feedback information from a preset channel in sequence. The order feedback information includes the target parent order identifier and status feedback information.
[0095] The business processing module updates the parent order record associated with the target parent order identifier in the local database according to the status report information, and generates a target sequence number ID by incrementing it. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume.
[0096] The order feedback information is sent to the post-out-of-order processing module through the business processing module.
[0097] The post-out-of-order processing module determines whether there exists a sequence number ID in the cache container that is associated with the target master unit identifier and is larger than the target sequence number ID;
[0098] If there exists a sequence number ID associated with the target parent order identifier and that is larger than the target sequence number ID, then the order report information is filtered through the post-out-of-order processing module.
[0099] If there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order feedback information is sent to the message push module, and the order feedback information is sent to the client associated with the target parent order identifier through the message push module.
[0100] It should be understood that in the embodiments of this application, the processor 502 may be a central processing unit (CPU), or it may be other general-purpose processors, digital signal processors (DSPs), application-specific integrated circuits (ASICs), field-programmable gate arrays (FPGAs), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. The general-purpose processor may be a microprocessor or any conventional processor.
[0101] It will be understood by those skilled in the art that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. The computer program includes program instructions and can be stored in a storage medium, which is a computer-readable storage medium. The program instructions are executed by at least one processor in the computer system to implement the process steps of the embodiments of the above methods.
[0102] Therefore, this application also provides a storage medium. This storage medium can be a computer-readable storage medium. The storage medium stores a computer program, wherein the computer program includes program instructions. When executed by a processor, the program instructions cause the processor to perform the following steps:
[0103] The business processing module receives order feedback information from a preset channel in sequence. The order feedback information includes the target parent order identifier and status feedback information.
[0104] The business processing module updates the parent order record associated with the target parent order identifier in the local database according to the status report information, and generates a target sequence number ID by incrementing it. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume.
[0105] The order feedback information is sent to the post-out-of-order processing module through the business processing module.
[0106] The post-out-of-order processing module determines whether there exists a sequence number ID in the cache container that is associated with the target master unit identifier and is larger than the target sequence number ID;
[0107] If there exists a sequence number ID associated with the target parent order identifier and that is larger than the target sequence number ID, then the order report information is filtered through the post-out-of-order processing module.
[0108] If there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order feedback information is sent to the message push module, and the order feedback information is sent to the client associated with the target parent order identifier through the message push module.
[0109] The storage medium can be any computer-readable storage medium capable of storing program code, such as a USB flash drive, portable hard drive, read-only memory (ROM), magnetic disk, or optical disk.
[0110] Those skilled in the art will recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this application.
[0111] In the several embodiments provided in this application, it should be understood that the disclosed apparatus and methods can be implemented in other ways. For example, the apparatus embodiments described above are merely illustrative. For example, the division of each unit is merely a logical functional division, and there may be other division methods in actual implementation. For example, multiple units or components may be combined or integrated into another system, or some features may be ignored or not executed.
[0112] The steps in the methods of this application embodiment can be adjusted, merged, or deleted according to actual needs. The units in the apparatus of this application embodiment can be merged, divided, or deleted according to actual needs. Furthermore, the functional units in the various embodiments of this application can be integrated into one processing unit, or each unit can exist physically separately, or two or more units can be integrated into one unit.
[0113] If the integrated unit is implemented as a software functional unit and sold or used as an independent product, it can be stored in a storage medium. Based on this understanding, the technical solution of this application, in essence, or the part that contributes to the prior art, or all or part of the technical solution, can be embodied in the form of a software product. This computer software product is stored in a storage medium and includes several instructions to cause a computer device (which may be a personal computer, a terminal, or a network device, etc.) to execute all or part of the steps of the methods described in the various embodiments of this application.
[0114] The above description is merely a specific embodiment of this application, but the scope of protection of this application is not limited thereto. Any person skilled in the art can easily conceive of various equivalent modifications or substitutions within the technical scope disclosed in this application, and these modifications or substitutions should all be covered within the scope of protection of this application. Therefore, the scope of protection of this application should be determined by the scope of the claims.
Claims
1. A method for protecting the order of transactions in a trading system, characterized in that, The method is applied to a transaction system, which includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock, and the message push module is located outside the business transaction lock. The method includes: The business processing module receives order feedback information from a preset channel in sequence. The order feedback information includes the target parent order identifier and status feedback information. The business processing module updates the parent order record associated with the target parent order identifier in the local database according to the status report information, and generates a target sequence number ID by incrementing it. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume. The order feedback information is sent to the post-out-of-order processing module through the business processing module. The post-out-of-order processing module determines whether there exists a sequence number ID in the cache container that is associated with the target master unit identifier and is larger than the target sequence number ID; If there exists a sequence number ID associated with the target parent order identifier and that is larger than the target sequence number ID, then the order report information is filtered through the post-out-of-order processing module. If there is no serial number ID that is associated with the target parent order ID and is larger than the target serial number ID, then the order feedback information is sent to the message push module, and the order feedback information is sent to the client associated with the target parent order ID through the message push module; The preset channels include a parent order channel corresponding to a parent order reporting thread or a child order channel corresponding to a child order reporting thread. The status reporting information in the order reporting information from the parent order channel includes order cancellation status reporting information or cumulative completion status reporting information. The cumulative completion status reporting information carries the cumulative transaction volume corresponding to the target parent order identifier. The status reporting information in the order reporting information from the child order channel includes parent order completion status reporting information. The parent order completion status reporting information carries the transaction volume of the corresponding child order. The transaction system further includes a pre-processing module for handling out-of-order data. Before the business processing module receives order feedback information from a preset channel in sequence, the method further includes: When the preset channel is the parent order channel corresponding to the parent order reporting thread, the pre-order disorder processing module determines whether the cumulative transaction volume in the order reporting information is less than or equal to the parent order transaction volume in the parent order record. If the cumulative transaction volume is less than or equal to the parent order transaction volume, the order return information is filtered through the pre-processing disordered order processing module.
2. The method according to claim 1, characterized in that, The parent order record also stores the total order amount corresponding to the target parent order identifier. Updating the parent order record associated with the target parent order identifier in the local database based on the status report information includes: When the status report information is an order cancellation status report information, the current status of the parent order in the parent order record is updated to the cancellation status; When the status report information is the status report information of the parent order component, the parent order transaction volume in the parent order record is updated by accumulating the transaction volume of the sub-orders carried by the status report information of the parent order component. If the updated transaction volume of the master order is equal to the total order volume, then the current master order status in the master order record will be updated to the completed status. If the updated transaction volume of the master order is less than the total order volume, then the current master order in the master order record will be updated to a partially completed state.
3. The method according to claim 1, characterized in that, Before receiving order feedback information from the preset channel sequentially through the business processing module, the method further includes: Receive an order entrustment instruction sent by the client, the order entrustment instruction including a user identifier and an order quantity; The legitimacy of the user is verified based on the user identifier. When the legality verification passes, a target master order corresponding to the order entrustment instruction is generated. The target master order carries the target master order identifier and the total entrustment quantity. A parent order record associated with the target parent order identifier is created in the local database, and the target parent order is sent to the brokerage terminal so that the brokerage terminal processes the target parent order and returns the order feedback information to the trading system through the preset channel based on the processing result.
4. The method according to claim 1, characterized in that, The method further includes: Receive an order query instruction sent by the client, the order query instruction carrying the target parent order identifier; In response to the order query command, order feedback information is generated based on the parent order record corresponding to the target parent order identifier; Send the order feedback information to the client.
5. The method according to claim 1, characterized in that, The target serial number ID is a globally incrementing ID or an ID that increments based on the target parent identifier.
6. A trading system, characterized in that, The transaction system includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within the business transaction lock, and the message push module is located outside the business transaction lock, wherein: The business processing module is used to receive order feedback information from a preset channel in sequence. The order feedback information includes a target parent order identifier and status feedback information. It updates the parent order record associated with the target parent order identifier in the local database according to the status feedback information, and generates a target sequence number ID by incrementing the sequence number. The target sequence number ID is associated with the target parent order identifier and stored in a preset cache container. The parent order record stores the current parent order status and the parent order transaction volume. Finally, it sends the order feedback information to the post-out-of-order processing module. The post-out-of-order processing module is used to determine whether there is a serial number ID in the cache container that is associated with the target parent order identifier and is larger than the target serial number ID; if there is a serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is filtered; if there is no serial number ID that is associated with the target parent order identifier and is larger than the target serial number ID, then the order report information is sent to the message push module. The message push module is used to send the order feedback information to the client associated with the target parent order identifier; The preset channels include a parent order channel corresponding to a parent order reporting thread or a child order channel corresponding to a child order reporting thread. The status reporting information in the order reporting information from the parent order channel includes order cancellation status reporting information or cumulative completion status reporting information. The cumulative completion status reporting information carries the cumulative transaction volume corresponding to the target parent order identifier. The status reporting information in the order reporting information from the child order channel includes parent order completion status reporting information. The parent order completion status reporting information carries the transaction volume of the corresponding child order. The transaction system further includes a pre-processing module for out-of-order handling, which is used for: When the preset channel is the parent order channel corresponding to the parent order report thread, determine whether the cumulative transaction volume in the order report information is less than or equal to the parent order transaction volume in the parent order record; If the cumulative transaction volume is less than or equal to the parent order transaction volume, the order return information is filtered.
7. A computer device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that, The computer device is equipped with a transaction system, which includes a business processing module, a post-out-of-order processing module, and a message push module. The business processing module is located within a business transaction lock. When the processor executes the computer program, it implements the out-of-order protection method of the transaction system as described in any one of claims 1-5.
8. A storage medium, characterized in that, The storage medium stores a computer program, which includes program instructions that, when executed by a processor, cause the processor to perform the out-of-order protection method for the transaction system as described in any one of claims 1-5.
Citation Information
Patent Citations
Message order preserving method based on serial number mechanism
CN112448898A