A method and system for controlling entrustment synchronization flow in quantitative trading scenarios
Through the dynamic token bucket mechanism and full commission query optimization, the deficiencies in request traffic management in the quantitative trading system are solved, efficient and balanced traffic distribution and dynamic adjustment are achieved, and transaction stability and efficiency are improved.
Patent Information
- Application Number
- CN202410824108.6
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2024-06-25
- Publication Date
- 2024-08-23
- Estimated Expiration
- 2044-06-25
AI Technical Summary
In quantitative trading scenarios, traditional current limiting mechanisms cannot effectively manage the priorities and dynamic adjustments of different types of requests, resulting in overloading of the trading desk and affecting the execution of trading strategies.
Adopt a dynamic token bucket mechanism to create sub-token buckets for different types of requests based on the processing capabilities of the trading desk, adjust the token generation rate and distribution in real time, prioritize request types with tight traffic, and trigger full entrusted queries during peak traffic periods to release resources.
It achieves refined management of the request flow of the quantitative trading system, avoids system overload, improves transaction processing efficiency and stability, and ensures the accurate execution of quantitative trading strategies.
Smart Images

Figure CN118400331B
Abstract
Description
Technical Field
[0001] The present invention relates to the field of financial technology, and in particular to a method and system for controlling entrustment synchronization flow in a quantitative trading scenario. Background Art
[0002] Quantitative trading relies on rapid analysis and response to large amounts of market data. Its system architecture consists of a quantitative trading algorithm platform, a quantitative trading system, and a trading counter. As the scale of quantitative trading continues to expand, the processing capacity of the trading counter, as the core processing unit, has become a key factor restricting the overall performance of the system. Especially during high-concurrency trading periods, if the request flow from the quantitative trading system to the trading counter is not properly controlled, the trading counter may be overloaded, resulting in delays and loss of entrustment instructions, affecting the execution effect of trading strategies. Although traditional flow limiting mechanisms such as fixed-rate flow limiting can simply control flow, they ignore the priority and dynamic adjustment requirements between different types of requests, which can easily lead to uneven resource allocation and increase system latency. Summary of the invention
[0003] In view of the technical problems existing in the prior art, the present invention provides a method and system for controlling the synchronization flow of entrustment in a quantitative trading scenario, the technical effect of which is to optimize the flow management of trading counter requests, ensure that while meeting the requirements of high concurrency and low latency, the balanced distribution and dynamic adjustment of various types of request flows are achieved, so as to improve the stability and efficiency of the entire quantitative trading process.
[0004] According to a first aspect of the present invention, the present invention provides a method for controlling entrustment synchronization flow in a quantitative trading scenario, comprising the following steps:
[0005] According to the upper limit of the traffic volume of the quantitative trading system set by the trading counter, a sub-token bucket is created for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query, which have a large traffic share, and a token bucket is used for other requests of the trading counter;
[0006] Initialize the maximum number of tokens in each token bucket, and limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached;
[0007] When a request is popped out of the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. If the token is retrieved successfully, the request is sent to the counter. If the token fails to be retrieved, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic.
[0008] When the traffic adjustment space is limited, the full entrustment query instruction is automatically triggered to query and obtain the latest status of all outstanding algorithmic orders; finally, based on the query results, the entrustments that have become final are filtered out, the corresponding entrustment synchronization query tasks are canceled, and traffic resources are released.
[0009] Based on the above technical solution, the present invention can also make the following improvements.
[0010] Optionally, the step of creating sub-token buckets for algorithm sub-order entrustment and algorithm sub-order entrustment synchronous query respectively according to the upper limit of the traffic volume restricted by the trading counter for the quantitative trading system, using one token bucket for other requests of the trading counter, and initializing the maximum number of tokens of each token bucket includes the following sub-steps:
[0011] Step 1.1: Initialize the token bucket, set the overall traffic limit according to the processing capacity of the trading counter, and allocate the initial number of tokens for algorithmic sub-order entrustment, algorithmic sub-order entrustment synchronous query and other request types;
[0012] Step 1.2: Monitor the traffic consumption of various requests in real time, and replenish tokens in the token bucket at a predetermined rate to ensure a dynamic balance between traffic supply and consumption;
[0013] Step 1.3: After the request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. When the token is retrieved successfully, the token is consumed and the request is sent to the counter.
[0014] Optionally, the initializing the maximum number of tokens in each token bucket and limiting the traffic to the transaction counter by a token generation rate determined by the maximum number of tokens includes:
[0015] Let the maximum number of tokens be , then every 1 / A token is generated every second. The more the maximum number of tokens is, the faster the tokens are generated and the greater the flow that can be restricted.
[0016] Optionally, when the token extraction fails, calculating and adjusting the maximum number of tokens in real time to give priority to request types with tight traffic includes the following sub-steps:
[0017] Step 2.1: When a surge in a certain type of request traffic is detected and other types of request traffic are lower than their average consumption level, the traffic adjustment algorithm is automatically started;
[0018] Step 2.2: Calculate the number of tokens that can be adjusted to ensure that the total number of tokens after adjustment does not exceed the originally set flow limit and complies with the constraint of the maximum change rate of flow control;
[0019] Step 2.3: Adjust token allocation in real time to prioritize request types with high traffic volume and ensure timely execution of key transaction operations.
[0020] Optionally, the automatically starting the traffic adjustment algorithm to calculate and adjust the maximum number of tokens in real time includes:
[0021] Set the maximum traffic change rate for algorithm sub-order entrustment and algorithm sub-order entrustment synchronous query request , and the magnitude of change , each time the adjustment is made, the maximum flow rate increases or decreases , the sum of the maximum flow of each type of request after dynamic adjustment does not exceed the overall maximum flow of the shared token bucket.
[0022] Optionally, in step 2.2, the calculation of the adjustable number of tokens to ensure that the adjusted total number of tokens does not exceed the originally set flow upper limit and at the same time comply with the constraint of the maximum change rate of flow control includes:
[0023] If the token cannot be obtained, determine other sub-token buckets to reduce the change range After that, whether it exceeds the maximum flow value range;
[0024] If it does not exceed the limit, the token production rate of the current sub-token bucket is increased, and the token production speed of other sub-token buckets is reduced. The thread processing the current request gives up the CPU slice to wait. When the thread resumes execution, it produces a corresponding number of tokens according to the waiting time and the token production rate, and transfers them to the cache queue for judgment and processing.
[0025] When the token production rate cannot be adjusted, if the current request is an algorithm sub-order delegation synchronization query, the full delegation synchronization will be triggered, otherwise the CPU shard will be released for waiting.
[0026] Optionally, the automatic triggering of the full amount entrustment query instruction to query and obtain the latest status of all outstanding algorithmic orders includes the following steps:
[0027] When full delegation synchronization is triggered, a full delegation synchronization request cache is first created, and a check is made to determine whether the minimum sending interval for full delegation synchronization requests is met. If not, full delegation synchronization is canceled.
[0028] Optionally, the triggering of full delegation synchronization includes:
[0029] Traverse the entrustment synchronization request queue, extract the fund account information from the entrustment synchronization request and put it into the full entrustment synchronization request cache, and clear the entrustment synchronization request queue;
[0030] Extract the fund account information from the entrustment synchronization request and put it into the full entrustment synchronization request cache, and clear the entrustment synchronization request queue.
[0031] Optionally, when triggering full delegation synchronization, the process further includes:
[0032] Traverse the full delegation synchronization request cache and initiate a full delegation synchronization request;
[0033] Traverse the entrustment records in the full entrustment synchronization response, update the positioning string of the full entrustment synchronization cache, and stop updating the positioning string when the first entrustment is in a non-final state;
[0034] Traverse the entrustment records in the full entrustment synchronization response and reschedule all entrustments in a non-final state to the entrustment synchronization request queue.
[0035] According to a second aspect of the present invention, a system for controlling a flow of entrusted synchronization in a quantitative trading scenario is provided, comprising:
[0036] The quantitative trading system module is used to create sub-token buckets for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query with large traffic proportion according to the upper limit of traffic volume restricted by the trading counter for the quantitative trading system, and use one token bucket for other requests of the trading counter;
[0037] A token generation module is used to initialize the maximum number of tokens in each token bucket, and to limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached;
[0038] The token bucket traffic control system module is used to pop a request from the request queue, try to take out a token from the corresponding token bucket according to the request type, and send the request to the counter when the token is successfully taken out; when the token fails to be taken out, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic;
[0039] The quantitative trading algorithm platform module is used to automatically trigger the full entrustment query instruction when the flow adjustment space is limited, query and obtain the latest status of all outstanding algorithm orders;
[0040] The result processing module is used to filter out the entrustments that have become final based on the query results, cancel the corresponding entrustment synchronization query tasks, and release traffic resources.
[0041] Technical effects and advantages of the present invention:
[0042] The present invention provides a method and system for controlling the flow of entrusted synchronization in a quantitative trading scenario. The present invention realizes the refined management of the request flow between the quantitative trading system and the trading counter through the intelligent flow control strategy of the dynamic token bucket, effectively avoids system overload, and improves the transaction processing efficiency. The adaptive flow adjustment mechanism enables the system to dynamically allocate resources according to actual needs, optimizing resource utilization efficiency. The introduction of full entrusted query further alleviates the query pressure during peak traffic periods, reduces system latency, and ensures the accurate execution of quantitative trading strategies. In summary, the present invention significantly improves the stability and efficiency of the quantitative trading system, and provides strong support for technological innovation and application practice in the field of quantitative trading. BRIEF DESCRIPTION OF THE DRAWINGS
[0043] Figure 1 is a schematic diagram of an adaptive traffic adjustment algorithm based on a shared token bucket model provided by an embodiment of the present invention;
[0044] Figure 2 It is a schematic diagram of the process of full-volume delegation synchronization provided by an embodiment of the present invention;
[0045] Figure 3 It is an architecture diagram of a delegated synchronization flow control system in a quantitative trading scenario provided by an embodiment of the present invention. DETAILED DESCRIPTION
[0046] In order to make the purpose, technical solution and advantages of the present invention clearer, the technical solution of the present invention will be clearly and completely described below in conjunction with the drawings of the present invention. Obviously, the described embodiments are part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0047] It can be understood that, based on the defects in the background technology, the embodiment of the present invention proposes a method for controlling the synchronization flow of entrustment in a quantitative trading scenario, which is used to optimize the flow management of the transaction counter request. The method includes the following steps:
[0048] According to the upper limit of the traffic volume of the quantitative trading system set by the trading counter, a sub-token bucket is created for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query, which have a large traffic share, and a token bucket is used for other requests of the trading counter;
[0049] Initialize the maximum number of tokens in each token bucket, and limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached;
[0050] After a request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. If the token is retrieved successfully, the request is sent to the counter. If the token fails to be retrieved, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic.
[0051] When the traffic adjustment space is limited, the full entrustment query instruction is automatically triggered to query and obtain the latest status of all outstanding algorithmic orders. Based on the query results, the entrustments that have become final are screened out, the corresponding entrustment synchronization query tasks are canceled, and traffic resources are released.
[0052] In the above technical scheme, the embodiment of the present invention is based on a dynamic token bucket mechanism, an adaptive traffic adjustment strategy and full-volume entrustment query optimization, aiming to solve the problem of intelligent allocation and dynamic adjustment of transaction counter request traffic in a quantitative trading system, so as to achieve efficient and balanced traffic management and ensure the smooth progress of quantitative trading.
[0053] It should be noted that the embodiment of the present invention first uses a dynamic token bucket mechanism and introduces a shared token bucket model, and sets up flow limiting controls for algorithm sub-order delegation, algorithm sub-order delegation synchronous query and other types of requests respectively. The total traffic limit does not exceed the threshold set by the transaction counter, ensuring that the system will not be overloaded due to excessive single traffic.
[0054] The steps of referencing the dynamic token bucket mechanism include: setting the overall flow limit of the shared token bucket according to the processing capacity limited by the trading counter, creating sub-token buckets for algorithm sub-order submission and algorithm sub-order delegation synchronous query respectively, and other requests to the trading counter share one token bucket.
[0055] Among them, according to the upper limit of the traffic volume restricted by the trading counter for the quantitative trading system, sub-token buckets are created for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query with a large traffic proportion, and a token bucket is used for other requests of the trading counter, including the following sub-steps:
[0056] Step 1.1: Initialize the token bucket, set the overall traffic limit according to the processing capacity of the trading counter, and allocate the initial number of tokens for algorithmic sub-order entrustment, algorithmic sub-order entrustment synchronous query and other request types;
[0057] Step 1.2: Monitor the traffic consumption of various requests in real time, and replenish tokens in the token bucket at a predetermined rate to ensure a dynamic balance between traffic supply and consumption;
[0058] Step 1.3: After the request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. When the token is retrieved successfully, the token is consumed and the request is sent to the counter.
[0059] Initializing the maximum number of tokens in each token bucket and limiting the traffic to the transaction counter by the token generation rate determined by the maximum number of tokens includes: initializing the maximum number of tokens in each token bucket, setting the maximum number of tokens to , then every 1 / A token is generated every second. The more the maximum number of tokens, the faster the token generation speed is, and the greater the flow it can limit. Among them, each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached.
[0060] It should be noted that the embodiment of the present invention secondly uses an adaptive traffic adjustment strategy to define the maximum flow control change rate and the flow control change rate. When a certain type of request is close to its traffic upper limit and the system still has room for adjustment, the token allocation is automatically adjusted to dynamically increase the number of tokens for this type of request, while moderately reducing the tokens for other types of requests, thereby ensuring the flexibility of traffic allocation and the agility of system response, and avoiding a certain type of request from monopolizing resources.
[0061] The steps of the adaptive traffic adjustment strategy include: after popping a request from the request queue, try to take out a token from the corresponding token bucket according to the request type, and send the request to the counter when the token is successfully taken out; when the token fails to be taken out, calculate and adjust the maximum number of tokens in real time to give priority to the request type with tight traffic;
[0062] When the token fails to be retrieved, it indicates that the traffic limit of this type of request has been reached. At this time, the maximum number of tokens is calculated and adjusted in real time. The types of requests with tight traffic are preferentially met, including:
[0063] Step 2.1: When a surge in a certain type of request traffic is detected and other types of request traffic are lower than their average consumption level, the traffic adjustment algorithm is automatically started;
[0064] Step 2.2: Calculate the number of tokens that can be adjusted to ensure that the total number of tokens after adjustment does not exceed the originally set flow limit and complies with the constraint of the maximum change rate of flow control;
[0065] Step 2.3: Adjust token allocation in real time to prioritize request types with high traffic volume and ensure timely execution of key transaction operations.
[0066] Figure 1 Schematic diagram of an adaptive traffic adjustment algorithm based on a shared token bucket model provided by an embodiment of the present invention; the adaptive traffic adjustment based on the shared token bucket model includes the following steps:
[0067] Assume that the total maximum flow of the shared token bucket is , the maximum flow of algorithm sub-order is 1 ,The maximum flow of algorithm sub-order entrustment synchronous query is 2 , the traffic limit for other requests is 3 ,have ;
[0068] Set the maximum flow rate change for requests such as algorithmic sub-order submission, algorithmic sub-order entrustment synchronization query, etc. , the value range is (0, 1), and the range of change Taking the algorithm sub-order request as an example, the maximum flow range is , each time it is adjusted, the maximum flow rate increases or decreases The sum of the maximum flow rates of each type of request after dynamic adjustment shall not exceed the overall maximum flow rate of the shared token bucket.
[0069] The flow limit of each sub-token bucket reflects the size of its token production rate; taking the algorithm sub-order request as an example, if the current flow limit is 1 , then its token production rate is 1 / 1 ;
[0070] All types of requests are processed asynchronously and have their own cache queues. For example, algorithm sub-order submission has an order submission queue, and algorithm sub-order entrustment synchronization query has an entrustment synchronization request queue;
[0071] After the request is popped from the request queue, an attempt is made to obtain a token from the corresponding sub-token bucket based on the request type.
[0072] After successfully taking out the token, you can send the request to the trading counter.
[0073] If the token cannot be obtained, determine other sub-token buckets to reduce the change range After that, check whether it exceeds the maximum flow value range. If not, increase the token production rate of the current sub-token bucket and reduce the token production speed of other sub-token buckets. The thread processing the current request gives up the CPU slice to wait. When the thread resumes execution, it produces a corresponding number of tokens based on the waiting time and token production rate, and transfers them to the cache queue for judgment and processing;
[0074] When the token production rate cannot be adjusted, if the current request is an algorithm sub-order delegation synchronization query, the full delegation synchronization will be triggered, otherwise the CPU shard will be released for waiting.
[0075] It should be noted that the embodiment of the present invention finally uses full entrustment query optimization. When the algorithm sub-order entrustment and the entrustment synchronization query reach the traffic limit at the same time and the adjustment space is limited, the system triggers the full entrustment synchronization query, pulls the entrustment status of all unfinished transactions at one time, efficiently processes the entrustment synchronization information, reduces subsequent query requests, and effectively alleviates the traffic bottleneck.
[0076] The optimization steps of using full entrustment query include: when the traffic adjustment space is limited, automatically trigger the full entrustment query instruction, query and obtain the latest status of all outstanding algorithmic orders, and based on the query results, filter out the entrustment that has become the final state, cancel the corresponding entrustment synchronization query task, and release traffic resources.
[0077] It should be noted that the entrustment records in the trading counter contain the positioning string information. The full entrustment query is a batch query, which queries all the entrustment records greater than the given positioning string based on the fund account, transaction password, positioning string and other information. Before the initial full entrustment synchronization, a full entrustment synchronization cache will be created. The information in the cache includes fields such as fund account and positioning string. After the cache is successfully created, the positioning string of each fund account is initialized to empty.
[0078] Figure 2 The following is a schematic diagram of the process of full entrustment synchronization provided by an embodiment of the present invention; when the flow adjustment space is limited, the full entrustment query instruction is automatically triggered to query and obtain the latest status of all outstanding algorithm orders, which specifically includes the following steps:
[0079] When full entrustment synchronization is triggered, first create a full entrustment synchronization request cache, and determine whether the minimum sending interval of full entrustment synchronization requests is met. If not, cancel the full entrustment synchronization;
[0080] Traverse the entrustment synchronization request queue, extract the fund account and other information from the entrustment synchronization request and put it into the full entrustment synchronization request cache, and then clear the entrustment synchronization request queue;
[0081] Traverse the full delegation synchronization request cache and initiate a full delegation synchronization request;
[0082] Traverse the entrustment records in the full entrustment synchronization response, update the positioning string of the full entrustment synchronization cache, and stop updating the positioning string when the first entrustment is in a non-final state (such as unsubmitted order, submitted order, partially executed, submitted order pending withdrawal, etc.);
[0083] Traverse the entrustment records in the full entrustment synchronization response and reschedule all the entrustments in the non-final state to the entrustment synchronization request queue. In this way, if there are entrustments that have been changed to executed or partially executed and partially cancelled in the full entrustment synchronization, the number of entrustment synchronization requests can be reduced, thereby achieving the purpose of controlling traffic.
[0084] Finally, based on the query results, filter out the delegates that have become final, cancel the corresponding delegate synchronization query tasks, and release traffic resources.
[0085] In summary, the embodiment of the present invention provides a method for controlling the synchronous flow of entrustment in a quantitative trading scenario, which aims to solve the problem of intelligent allocation and dynamic adjustment of the flow of trading counter requests in the quantitative trading system, so as to achieve efficient and balanced flow management and ensure the smooth progress of quantitative trading. At the same time, the flow management of trading counter requests is optimized to ensure that while meeting the requirements of high concurrency and low latency, the balanced allocation and dynamic adjustment of various types of request flows can be achieved, so as to improve the stability and efficiency of the entire quantitative trading process.
[0086] Figure 3 The system architecture diagram of the embodiment of the present invention is shown, including a quantitative trading algorithm platform, a quantitative trading system, a token generation system and a token bucket flow control system, which intuitively presents the deployment location and data flow of the flow control mechanism. Therefore, according to the second aspect of the present invention, a delegated synchronization flow control system in a quantitative trading scenario is provided, including:
[0087] The quantitative trading system module is used to create sub-token buckets for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query with large traffic proportion according to the upper limit of traffic volume restricted by the trading counter for the quantitative trading system, and use one token bucket for other requests of the trading counter;
[0088] A token generation module is used to initialize the maximum number of tokens in each token bucket, and to limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached;
[0089] The token bucket traffic control system module is used to pop a request from the request queue, try to take out a token from the corresponding token bucket according to the request type, and send the request to the counter when the token is successfully taken out; when the token fails to be taken out, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic;
[0090] The quantitative trading algorithm platform module is used to automatically trigger the full entrustment query instruction when the flow adjustment space is limited, query and obtain the latest status of all outstanding algorithm orders;
[0091] The result processing module is used to filter out the entrustments that have become final based on the query results, cancel the corresponding entrustment synchronization query tasks, and release traffic resources.
[0092] It can be understood that the entrustment synchronization flow control system in a quantitative trading scenario provided by the present invention corresponds to the entrustment synchronization flow control method in a quantitative trading scenario provided by the aforementioned embodiments. The relevant technical features of the entrustment synchronization flow control system in a quantitative trading scenario can refer to the relevant technical features of the entrustment synchronization flow control method in a quantitative trading scenario, which will not be repeated here.
[0093] In addition, an embodiment of the present invention provides an electronic device, which may include: a processor, a communications interface, a memory, and a communication bus, wherein the processor, the communications interface, and the memory communicate with each other through the communication bus. The processor may call the logic instructions in the memory to execute the above-mentioned method for entrusting synchronous flow control in a quantitative trading scenario, and the method includes the following steps:
[0094] According to the upper limit of the traffic volume of the quantitative trading system set by the trading counter, a sub-token bucket is created for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query, which have a large traffic share, and a token bucket is used for other requests of the trading counter;
[0095] Initialize the maximum number of tokens in each token bucket; initialize the maximum number of tokens in each token bucket, and limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached;
[0096] After a request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. If the token is retrieved successfully, the request is sent to the counter. If the token fails to be retrieved, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic.
[0097] When the flow adjustment space is limited, the full amount entrustment query instruction is automatically triggered to query and obtain the latest status of all outstanding algorithmic orders;
[0098] Based on the query results, filter out the entrustments that have become final, cancel the corresponding entrustment synchronization query tasks, and release traffic resources.
[0099] In addition, the logic instructions in the above-mentioned memory can be implemented in the form of software functional units and can be stored in a computer-readable storage medium when sold or used as an independent product. Based on this understanding, the technical solution of the present invention, in essence, or the part that contributes to the prior art or the part of the technical solution, can be embodied in the form of a software product, which is stored in a storage medium and includes several instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to perform all or part of the steps of the method described in each embodiment of the present invention. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), disk or optical disk, etc., which can store program code.
[0100] Through the description of the above implementation methods, those skilled in the art can clearly understand that each implementation method can be implemented by means of software plus a necessary general hardware platform, and of course, can also be implemented by hardware. Based on this understanding, the above technical solution is essentially or the part that contributes to the prior art can be embodied in the form of a software product, and the computer software product can be stored in a computer-readable storage medium, such as ROM / RAM, a disk, an optical disk, etc., including a number of instructions for a computer device (which can be a personal computer, a server, or a network device, etc.) to execute the methods described in each embodiment or some parts of the embodiments.
[0101] Although the preferred embodiments of the present invention have been described, those skilled in the art may make other changes and modifications to these embodiments once they have learned the basic creative concept. Therefore, the appended claims are intended to be interpreted as including the preferred embodiments and all changes and modifications that fall within the scope of the present invention.
[0102] Finally, it should be noted that the above embodiments are only used to illustrate the technical solutions of the present invention, rather than to limit it. Although the present invention has been described in detail with reference to the aforementioned embodiments, those skilled in the art should understand that they can still modify the technical solutions described in the aforementioned embodiments, or make equivalent replacements for some of the technical features therein. However, these modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present invention.
Claims
1. A method for controlling the synchronization flow of entrustment in a quantitative trading scenario, characterized in that: The following steps are involved: According to the upper limit of the traffic volume of the quantitative trading system set by the trading counter, a sub-token bucket is created for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query, which have a large traffic share, and a token bucket is used for other requests of the trading counter; Initialize the maximum number of tokens in each token bucket, and limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached; After a request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. If the token is retrieved successfully, the request is sent to the counter. If the token fails to be retrieved, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic. When the flow adjustment space is limited, the full amount entrustment query instruction is automatically triggered to query and obtain the latest status of all outstanding algorithmic orders; Based on the query results, filter out the entrustments that have become final, cancel the corresponding entrustment synchronization query tasks, and release traffic resources.
2. According to the method for controlling the entrustment synchronization flow in a quantitative trading scenario according to claim 1, it is characterized in that: The method of creating sub-token buckets for algorithm sub-order entrustment and algorithm sub-order entrustment synchronous query with large traffic proportion according to the upper limit of traffic volume restricted by the trading counter for the quantitative trading system, and using one token bucket for other requests of the trading counter includes the following sub-steps: Step 1.1: Initialize the token bucket, set the overall traffic limit according to the processing capacity of the trading desk, create sub-token buckets for algorithmic sub-order entrustment, algorithmic sub-order entrustment synchronous query and other request types, and allocate the initial maximum number of tokens to each; Step 1.2: Monitor the traffic consumption of various requests in real time, and replenish tokens in the token bucket at a predetermined rate to ensure a dynamic balance between traffic supply and consumption; Step 1.3: After the request is popped from the request queue, an attempt is made to retrieve a token from the corresponding token bucket according to the request type. When the token is retrieved successfully, the token is consumed and the request is sent to the counter.
3. The method for controlling the synchronization flow of entrustment in a quantitative trading scenario according to claim 1 is characterized in that: Initializing the maximum number of tokens in each token bucket and limiting the traffic to the transaction counter by the token generation rate determined by the maximum number of tokens includes: Let the maximum number of tokens be , then every 1 / A token is generated every second. The more the maximum number of tokens is, the faster the tokens are generated and the greater the traffic that can be restricted.
4. The method for controlling the entrustment synchronization flow in a quantitative trading scenario according to claim 1 is characterized in that: When the token fails to be retrieved, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic, including the following sub-steps: Step 2.1: When a surge in a certain type of request traffic is detected and other types of request traffic are lower than their average consumption level, the traffic adjustment algorithm is automatically started; Step 2.2: Calculate the number of tokens that can be adjusted to ensure that the total number of tokens after adjustment does not exceed the originally set flow limit and complies with the constraint of the maximum change rate of flow control; Step 2.3: Adjust token allocation in real time to prioritize request types with high traffic volume and ensure timely execution of key transaction operations.
5. The method for controlling the entrustment synchronization flow in a quantitative trading scenario according to claim 4 is characterized in that: The automatic start-up flow adjustment algorithm includes: Set the maximum traffic change rate for algorithm sub-order entrustment and algorithm sub-order entrustment synchronous query request , and the magnitude of change , each time the adjustment is made, the maximum flow rate increases or decreases , the sum of the maximum flow of each type of request after dynamic adjustment does not exceed the overall maximum flow of the shared token bucket.
6. The method for controlling the synchronization flow of entrustment in a quantitative trading scenario according to claim 4 is characterized in that: In step 2.2, the calculation of the adjustable number of tokens ensures that the total number of tokens after adjustment does not exceed the originally set flow limit, and at the same time complies with the constraints of the maximum change rate of flow control, including: If the token cannot be obtained, determine other sub-token buckets to reduce the change range After that, whether it exceeds the maximum flow value range; If it does not exceed, the token production rate of the current sub-token bucket is increased, and the token production speed of other sub-token buckets is reduced. The thread processing the current request gives up the CPU slice to wait. When the thread resumes execution, it produces a corresponding number of tokens according to the waiting time and the token production rate, and transfers them to the cache queue for judgment and processing. When the token production rate cannot be adjusted, if the current request is an algorithm sub-order delegation synchronization query, the full delegation synchronization will be triggered, otherwise the CPU shard will be released for waiting.
7. The method for controlling the entrustment synchronization flow in a quantitative trading scenario according to claim 1 is characterized in that: The automatic triggering of the full amount entrustment query instruction to query and obtain the latest status of all outstanding algorithmic orders includes the following steps: When full delegation synchronization is triggered, a full delegation synchronization request cache is first created, and a check is made to determine whether the minimum sending interval for full delegation synchronization requests is met. If not, full delegation synchronization is canceled.
8. The method for controlling the entrustment synchronization flow in a quantitative trading scenario according to claim 7 is characterized in that: The triggering of full entrustment synchronization includes: Traverse the entrustment synchronization request queue, extract the fund account information from the entrustment synchronization request and put it into the full entrustment synchronization request cache, and clear the entrustment synchronization request queue; Extract the fund account information from the entrustment synchronization request and put it into the full entrustment synchronization request cache, and clear the entrustment synchronization request queue.
9. The method for controlling the synchronization flow of entrustment in a quantitative trading scenario according to claim 8 is characterized in that: When triggering full entrustment synchronization, it also includes: Traverse the full delegation synchronization request cache and initiate a full delegation synchronization request; Traverse the entrustment records in the full entrustment synchronization response, update the positioning string of the full entrustment synchronization cache, and stop updating the positioning string when the first entrustment is in a non-final state; Traverse the entrustment records in the full entrustment synchronization response and reschedule all entrustments in a non-final state to the entrustment synchronization request queue.
10. A commission synchronization flow control system in a quantitative trading scenario, characterized in that: include: The quantitative trading system module is used to create sub-token buckets for algorithmic sub-order entrustment and algorithmic sub-order entrustment synchronous query with large traffic proportion according to the upper limit of traffic volume restricted by the trading counter for the quantitative trading system, and use one token bucket for other requests of the trading counter; A token generation module is used to initialize the maximum number of tokens in each token bucket, and to limit the traffic to the trading counter by the token generation rate determined by the maximum number of tokens; wherein each token bucket generates tokens in real time according to the maximum number of tokens, and stops generating tokens when the maximum number of tokens is reached; The token bucket traffic control system module is used to pop a request from the request queue, try to take out a token from the corresponding token bucket according to the request type, and send the request to the counter when the token is successfully taken out; when the token fails to be taken out, the maximum number of tokens is calculated and adjusted in real time to give priority to request types with tight traffic; The quantitative trading algorithm platform module is used to automatically trigger the full entrustment query instruction when the flow adjustment space is limited, query and obtain the latest status of all outstanding algorithm orders; The result processing module is used to filter out the entrustments that have become final based on the query results, cancel the corresponding entrustment synchronization query tasks, and release traffic resources.
