Position contract delivery method, electronic equipment and medium
By preprocessing position contracts and optimizing algorithms to determine the delivery order, the problems of incomplete delivery and low capital utilization have been solved, achieving efficient and orderly position contract delivery, avoiding vicious cycles, and improving delivery speed and capital utilization.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2026-02-02
- Publication Date
- 2026-03-10
AI Technical Summary
Existing position contract settlement methods suffer from problems such as incomplete settlement, low account fund utilization, slow settlement speed, and a tendency to fall into a vicious cycle.
By preprocessing multiple pending contract positions, determining the currency type and user group, monitoring thread status, allocating idle threads to each group, and delivering in an orderly manner according to currency priority and contract priority, the delivery order is determined by using a local optimization algorithm to avoid delivery confusion and infinite loops.
It has achieved orderly delivery, improved capital utilization, delivery speed and delivery scale, avoided incomplete delivery and vicious cycles, and improved delivery efficiency.
Smart Images

Figure CN121639211A_ABST
Abstract
Description
TECHNICAL FIELD
[0001] The present application relates to the technical field of information management, and in particular to a position contract settlement method, an electronic device and a medium. BACKGROUND
[0002] The position contract is a forward contract signed by a customer and a financial institution, which stipulates that the foreign currency exchange will be completed according to the locked exchange rate on the settlement day in the future. After creating the position contract, the system will batch process all position contracts with the settlement day on the same day, complete the fund transfer according to the locked exchange rate at the time of signing, without manual operation by the customer (i.e. automatically settle the contract on the same day as the settlement day).
[0003] In the existing settlement method, the position contracts to be settled on the same day are grouped and corresponding queues are generated, and independent threads are allocated to each queue to process the contracts to be settled in parallel. In the case where the queue size after each processing is smaller than the queue size before the processing and the queue is not empty, the above parallel settlement process is repeated until all queues are completely emptied, and the efficient settlement of the position contract is automatically completed.
[0004] Although the above settlement method is fast, it has the problem of incomplete settlement. SUMMARY
[0005] The present application aims to solve one of the technical problems in the related art to some extent. To this end, the present application provides a position contract settlement method, an electronic device for executing the position contract settlement method and a computer readable medium, which have the advantages and characteristics of orderly settlement, complete settlement, high account fund utilization rate, large settlement amount, fast settlement speed and prevention of settlement into a dead loop.
[0006] In order to achieve the above-mentioned purpose, as a first aspect of the present application, a position contract settlement method is provided, wherein the position contract settlement method comprises: preprocessing a plurality of position contracts to be settled to obtain a plurality of groups of processed position contracts to be settled of the same user corresponding to the currency type; obtaining the account amount of each currency and the settlement amount of the processed position contract to be settled of the same group; obtaining the resource usage state of a plurality of threads; wherein the thread is a user of CPU basic computing resources; allocating the thread in the idle state corresponding to each group, and updating the resource usage state of the thread to the occupied state when detecting that the allocation is completed; determining the currency priority of the settlement and the priority of the position contract to be settled corresponding to the currency according to the currency type of the same group, the account amount of the currency and the settlement amount of the processed position contract to be settled by using the thread in the occupied state; Delivery shall be made in accordance with the currency priority and the priority of the pending delivery positions; Upon detecting that the handover is complete, the resource usage status of the corresponding thread is updated to idle.
[0007] Optionally, the thread utilizing the occupancy status determines the priority of the currency to be settled and the priority of the corresponding pending delivery position contract based on the currency type, the account amount of the currency, and the pending delivery amount of the processed pending delivery position contract within the same group, including: Create a pending delivery ordered queue; wherein the size of the pending delivery ordered queue is greater than or equal to the total number of pending delivery position contracts included with the same user; Clear the aforementioned pending delivery queue; Determine the account amount for each currency type and the total amount of pending delivery contracts, including the processed pending delivery positions for that currency type; The ratio of the determined account amount to the total amount to be settled will be used as the settlement coverage for each currency type. The delivery coverage is sorted in descending order to obtain the currency priority for delivery; According to the priority of the currencies, the priority of the pending delivery positions for each currency is determined by a local optimization algorithm. Contracts with identified priorities are placed into the ordered queue of deliverable positions according to their priority.
[0008] Optionally, the objective function of the local optimization algorithm is a function that minimizes the difference between the account amount corresponding to the currency and the total amount of the selected contract positions to be delivered; the constraint condition of the local optimization algorithm is that the total amount of the selected contract positions to be delivered corresponding to the currency is less than or equal to the corresponding account amount. The step of determining the priority of the pending delivery positions for each currency using a local optimization algorithm, according to the priority order of the currencies, includes: For a currency that corresponds to the priority order of the currency, multiple pending delivery contracts are selected from all pending delivery contracts including that currency, according to the constraints, as the initial pending delivery contracts. Unselected pending delivery positions will be used as alternative pending delivery positions. The initial objective function is determined based on the initial undeliverable position contracts and the objective function; The initial objective function is optimized using the alternative pending delivery position contracts and the initial pending delivery position contracts to obtain the priority of the pending delivery position contracts for this currency.
[0009] Optionally, the evaluation index of the local optimization algorithm satisfies the following formula (1): beta =AMOUNT-SUM-SX(i)+SL(j)(1) Where beta is the evaluation index of the objective function, AMOUNT is the account amount corresponding to the currency, SUM is the total amount of currency sold in the selected pending delivery position contracts, SX(i) is the i-th contract in the initial pending delivery position contracts, and SL(j) is the j-th contract in the alternative pending delivery position contracts. The step of optimizing the initial objective function using the candidate pending delivery positions and the initial pending delivery positions to obtain the priority of the pending delivery positions for that currency includes: Select the i-th contract from the initial pending delivery positions; where 1≤i≤N_SX; N_SX is the number of initial pending delivery positions. The j-th contract is selected from the candidate deliverable positions according to the constraints described above; where 1 ≤ j ≤ N_SL; and N_SL is the number of candidate deliverable positions. Replace the j-th contract with the i-th contract, and determine the evaluation index of the i-th contract and N_SL j-th contracts respectively according to formula (1); If the predetermined number of cycles is within zero and the determined evaluation index is zero, the initial delivery position contract corresponding to the zero evaluation index will be used as the priority of the delivery position contract.
[0010] Optionally, the step of optimizing the initial objective function using the alternative pending delivery position contracts and the initial pending delivery position contracts to obtain the priority of the pending delivery position contracts for that currency further includes: Within a preset number of cycles and provided that the determined evaluation metric is not zero, the initial delivery position contract corresponding to the minimum value of the evaluation metric is used as the priority of the delivery position contract.
[0011] Optionally, the delivery queue stores delivery position contracts arranged according to the priority of the currency and the priority of the delivery position contracts; The delivery according to the currency priority and the priority of the pending delivery position contracts includes: Extract the deliverable position contracts according to the queue order of the aforementioned deliverable ordered queue; Delivery of the extracted pending position contracts.
[0012] Optionally, the preprocessing of multiple pending delivery position contracts to obtain multiple sets of processed pending delivery position contracts of the same user corresponding to the currency type includes: Based on the current date as the delivery date, extract the pending delivery position contracts with the same delivery date from the pending delivery position contract database; Identify user information in the pending delivery positions contracts with the same delivery date that have been extracted; Contracts with pending delivery positions that share the same user information are categorized into user classes, resulting in multiple processed contracts with pending delivery positions for each user class. Among these, contract contracts with pending delivery positions for the same user class share the same user information. Extract the currency type of the processed pending-delivery position contracts for the same user class; The pending delivery positions of the same currency type within the same user class are grouped together, resulting in multiple groups of processed pending delivery positions for the same user corresponding to the currency type.
[0013] Optionally, the position contract settlement method further includes: If the resource usage status of multiple threads is in an occupied state, then each group is assigned a thread with the corresponding occupied state based on the number of pending delivery contracts after processing and the resource utilization rate of each thread.
[0014] As a second aspect of the present invention, an electronic device is provided, comprising: One or more processors; A memory having stored one or more computer programs that, when executed by one or more processors, cause the one or more processors to implement the position contract settlement method provided according to the first aspect of the invention.
[0015] Furthermore, as a third aspect of the present invention, a computer-readable medium is provided having a computer program stored thereon, wherein the computer program, when executed by a processor, implements the position contract settlement method provided in the first aspect of the present invention.
[0016] This invention first preprocesses multiple pending-delivery position contracts to obtain multiple groups of processed pending-delivery position contracts for the same user, corresponding to different currency types. This ensures that all pending-delivery position contracts for the same user are settled as a single settlement unit based on currency type. Preprocessing avoids subsequent confusion between funds and pending-delivery position contracts across users, as well as cross-interference in settlements of different currency types for the same user, thus guaranteeing settlement accuracy. Second, by monitoring the usage status of threads, idle threads are allocated to each group, and the thread status is updated before and after task execution to maximize the utilization of threads to complete subsequent settlement tasks. Before settlement, the settlement order is determined in two steps: first, the currency priority of each group is determined; after determining the currency priority, the priority of single-currency pending-delivery contracts is determined for each currency. Finally, settlement is executed according to the determined priority order. This priority order ensures that account funds flow first to the contracts that "most consume the positions to be settled," maximizing the settlement scale and consuming most of the account funds, thus improving capital utilization and solving the problems of disordered settlement, low account capital utilization, and incomplete position settlement in traditional methods. Furthermore, by monitoring thread status and the completion status of settlement tasks, threads are released after settlement, preventing the settlement process from entering an infinite loop and ensuring the cyclical use of thread resources. Since each group has its own independent thread, multiple groups' positions can be settled in parallel, significantly improving settlement speed compared to single-threaded settlement.
[0017] These features and advantages of the present invention will be disclosed in detail in the following specific embodiments and accompanying drawings. The preferred embodiments or means of the present invention will be shown in detail in conjunction with the accompanying drawings, but are not intended to limit the technical solutions of the present invention. In addition, each of these features, elements and components appearing in the following text and drawings is a plurality of, and different symbols or numbers are used for convenience of representation, but all represent parts with the same or similar construction or function. Attached Figure Description
[0018] The present invention will be further described below with reference to the accompanying drawings: Figure 1 A flowchart of a position contract settlement method provided by the present invention; Figure 2 A flowchart illustrating one embodiment of step S150 of the position contract settlement method provided by the present invention; Figure 3 A flowchart illustrating one embodiment of step S156 of the position contract settlement method provided by the present invention; Figure 4 A flowchart illustrating one embodiment of step S156d of the position contract settlement method provided by the present invention; Figure 5 A flowchart illustrating the steps for determining priorities using a local optimization algorithm provided by this invention; Figure 6 A flowchart illustrating one embodiment of step S160 of the position contract settlement method provided by the present invention; Figure 7 A flowchart illustrating one embodiment of step S110 of the position contract settlement method provided by the present invention; Figure 8 The flowchart of the preprocessing implementation provided by the present invention; Figure 9 The task flow and status management diagram provided for this invention; Figure 10 A module diagram of an electronic device provided by the present invention; Figure 11 This invention provides a schematic diagram of a computer-readable medium.
[0019] Explanation of reference numerals in the attached figures Among them, 101 is the processor; 102 is the memory; 103 is the I / O interface; and 104 is the bus. Detailed Implementation
[0020] Embodiments of the present invention are described in detail below, examples of which are illustrated in the accompanying drawings, wherein the same or similar reference numerals denote the same or similar elements or elements having the same or similar functions throughout. The embodiments described are intended to explain the present invention and should not be construed as limiting the invention.
[0021] The terms "an embodiment," "example," or "trademark" used in this specification refer to a particular feature, structure, or characteristic described in connection with the embodiment itself that may be included in at least one embodiment disclosed in this invention. The phrase "in an embodiment" appearing in various places throughout the specification does not necessarily refer to the same embodiment.
[0022] Traditional contract settlement methods only consider settlement speed, neglecting settlement order and failing to pre-analyze the amount to be settled and account balances. This results in incomplete settlements. For example, a user might have two contracts to be settled: Contract 1: sell 1000 USD, buy 7000 CNH; Contract 2: sell 10000 USD, buy 70000 CNH; and an account balance of 10500 USD. Traditional settlement methods only consider that the amount to be settled for Contract 1 is less than that for Contract 2, prioritizing speed. Contract 1 is processed first, leaving 9500 USD in the account. Since this 9500 USD is less than the 10000 USD to be settled for Contract 2, insufficient funds prevent the settlement of Contract 2. Therefore, after settlement, a significant amount of USD remained, with a small difference from Contract 2, but Contract 2 could not be settled, resulting in a residual effective position. This is a typical case of incomplete settlement. Furthermore, the account balance for the specified currency was not fully utilized (insufficient account balance / low utilization rate), leading to a low settlement volume. This traditional disordered settlement method, which involves settling small amounts first and then large amounts, increases the number of failed retries when settling large contracts, resulting in low settlement efficiency.
[0023] In view of this, in order to solve the aforementioned problem of incomplete settlement, as a first aspect of the present invention, a method for settling position contracts is provided, such as... Figure 1 As shown, the settlement method for the position contract includes: In step S110, multiple pending delivery position contracts are preprocessed to obtain multiple sets of processed pending delivery position contracts of the same user corresponding to the currency type. In step S120, the account balances of each currency in the same group and the settlement amounts of the processed settlement positions are obtained. In step S130, the resource usage status of multiple threads is obtained; wherein, the threads are users of CPU basic computing resources; In step S140, threads in an idle state are assigned to each group. When the assignment is detected to be complete, the resource usage status of the threads is updated to an occupied state. In step S150, the thread in the occupied state determines the priority of the currency to be delivered and the priority of the corresponding vacant position contract based on the currency type, the account amount of the currency, and the amount of the pending delivery of the processed pending delivery position contract in the same group. In step S160, settlement is carried out according to the currency priority and the priority of the pending delivery position contracts; In step S170, if the handover is detected to be complete, the resource usage status of the corresponding thread is updated to idle.
[0024] This invention first preprocesses multiple pending-delivery position contracts to obtain multiple groups of processed pending-delivery position contracts for the same user, corresponding to different currency types. This ensures that all pending-delivery position contracts for the same user are settled as a single settlement unit based on currency type. Preprocessing avoids subsequent confusion between funds and pending-delivery position contracts across users, as well as cross-interference in settlements of different currency types for the same user, thus guaranteeing settlement accuracy. Second, by monitoring the usage status of threads, idle threads are allocated to each group, and the thread status is updated before and after task execution to maximize the utilization of threads to complete subsequent settlement tasks. Before settlement, the settlement order is determined in two steps: first, the currency priority of each group is determined; after determining the currency priority, the priority of single-currency pending-delivery contracts is determined for each currency. Finally, settlement is executed according to the determined priority order. This priority order ensures that account funds flow first to the contracts that "most consume the positions to be settled," maximizing the settlement scale and consuming most of the account funds, thus improving capital utilization and solving the problems of disordered settlement, low account capital utilization, and incomplete position settlement in traditional methods. Furthermore, by monitoring thread status and the completion status of settlement tasks, threads are released after settlement, preventing the settlement process from entering an infinite loop and ensuring the cyclical use of thread resources. Since each group has its own independent thread, multiple groups' positions can be settled in parallel, significantly improving settlement speed compared to single-threaded settlement.
[0025] The priority-based ordered settlement method provided by this invention clarifies the settlement path and maximizes the settlement scale during the settlement process, minimizing the consumption of most account funds. As an optional implementation of step S150, such as... Figure 2 As shown, the process of using an occupied thread to determine the priority of the currency to be settled and the priority of the corresponding pending position contract based on the currency type, the account balance of the currency, and the pending settlement amount of the processed pending position contract within the same group includes: In step S151, a pending delivery ordered queue is created; wherein the size of the pending delivery ordered queue is greater than or equal to the total number of pending delivery position contracts included with the same user; In step S152, the ordered queue to be delivered is cleared; In step S153, the account amount for each currency type and the total amount of the pending delivery contract including the processed pending delivery position contract of that currency type are determined. In step S154, the ratio of the determined total amount to be settled to the account amount is used as the settlement coverage for each currency type. In step S155, the delivery coverage is sorted in descending order to obtain the currency priority of the delivery; In step S156, according to the priority of the currencies, the priority of the pending delivery position contracts of each currency is determined by the local optimization algorithm. In step S157, the pending delivery position contracts with determined priorities are placed into the pending delivery ordered queue in order of priority.
[0026] It's important to reiterate the definition of settlement coverage: Settlement coverage alpha = SELL_AMOUNT / AMOUT, where SELL_AMOUNT is the sum of the pending settlement amounts for a particular cryptocurrency, and AMOUNT is the account balance for that cryptocurrency. A settlement coverage of 1 means that the current account balance for that cryptocurrency is sufficient to cover the settlement of all pending contracts for that cryptocurrency. Alpha < 1 indicates that the balance covers the total pending settlement amount, while alpha > 1 indicates that it does not. In this application, a settlement coverage less than 1 indicates a more sufficient fund guarantee balance for contract settlement under that cryptocurrency, meaning a higher degree of matching between the account balance and the total pending settlement amount. Prioritizing cryptocurrencies with higher settlement matching (lower settlement coverage) directly improves the completeness of settlement for a single cryptocurrency.
[0027] After determining the currency priority, a local optimization algorithm is used to determine the priority of the pending delivery positions for each currency. This ensures that, at settlement, priority is given to contracts with a high degree of matching between the account amount and the total amount to be delivered for the currency, and the contract combination with the best matching between the total amount of multiple pending delivery positions for a single currency and the account amount is settled first. The objective function of the local optimization algorithm is to minimize the difference between the account amount corresponding to the currency and the total amount of the selected pending delivery positions; the constraint condition of the local optimization algorithm is that the total amount of the selected pending delivery positions corresponding to the currency is less than or equal to the corresponding account amount; as an optional implementation of step S156, such as... Figure 3 As shown, the step of determining the priority of the pending delivery positions for each currency using a local optimization algorithm according to the priority order of the currencies includes: In step S156a, for the currency corresponding to the order of currency priority, multiple pending delivery contracts are selected from all pending delivery contracts including that currency according to the constraints, as the initial pending delivery contracts. In step S156b, the unselected pending delivery position contracts are selected as alternative pending delivery position contracts; In step S156c, the initial objective function is determined based on the initial undeliverable position contract and the objective function; In step S156d, the initial objective function is optimized using the alternative pending delivery position contracts and the initial pending delivery position contracts to obtain the priority of the pending delivery position contracts for that currency.
[0028] The evaluation metric for the local optimization algorithm used to determine the set of deliverable position contracts corresponding to a single currency at the time of delivery satisfies the following formula (1): beta =AMOUNT-SUM-SX(i)+SL(j)(1) In equation (1) above, beta is the evaluation index of the objective function, AMOUNT is the account amount corresponding to the currency, SUM is the total amount of currency sold in the selected pending delivery position contracts, SX(i) is the i-th contract in the initial pending delivery position contracts, and SL(j) is the j-th contract in the alternative pending delivery position contracts. It can be seen from the above that both the initial pending delivery position contracts and the alternative pending delivery position contracts are a set of contracts, each containing multiple contracts. As an optional implementation of step S156d, such as... Figure 4 As shown, the step of optimizing the initial objective function using the alternative pending delivery positions and the initial pending delivery positions to obtain the priority of the pending delivery positions for that currency includes: In step S156d1, the i-th contract in the initial pending delivery position is selected; where 1≤i≤N_SX; N_SX is the number of initial pending delivery position contracts; In step S156d2, the j-th contract is selected from the candidate deliverable position contracts according to the constraints; where 1≤j≤N_SL; N_SL is the number of candidate deliverable position contracts; In step S156d3, the j-th contract is replaced with the i-th contract, and the evaluation indicators of the i-th contract and N_SL j-th contracts are determined according to formula (1); In step S156d4, if the predetermined number of cycles is within the preset number of cycles and the determined evaluation index is zero, the initial delivery position contract corresponding to the zero evaluation index is used as the priority of the delivery position contract.
[0029] In addition, during the optimization process, if there is a situation where no evaluation index can be found within the preset number of iterations, the initial undeliverable position contract corresponding to the minimum value of the evaluation index in each optimization process will be used as the priority of the undeliverable position contract.
[0030] The following is an example and appendix. Figure 5 This application provides a detailed explanation of the specific and complete steps involved in determining the priority of pending delivery positions corresponding to a specific currency using a local optimization algorithm. For example, it details the priority of all pending delivery positions, including those of User 1 and USD.Figure 5 The set of pending delivery contracts (corresponding to the $1 USD sell order) determines the contracts to be delivered and their delivery order. The delivery currency is USD. The pending delivery contract set is SS. This set is first copied to SS1. The set of contracts randomly selected from SS1 (initial pending delivery contracts) are SX1-SXn in sequence, and the remaining unselected contract sets (alternate pending delivery contracts) are SL1-SLn in sequence. N is set to be less than or equal to 10, and each SX corresponds to one SL. Replacement optimization is performed on each SX. Taking SX1 and SL1 as examples, the evaluation index of the local optimization algorithm is beta = AMOUNT-SUM-SX1(i)+SL1(j). The physical meaning of beta is the difference between user 1's USD balance and the total amount of the replaced contracts after replacing the i-th contract in SX1 with the j-th contract in SL1. First, select a contract SX(i) from SX1 and calculate its beta value after replacing it with each contract SL1(j) in SL1. Then, select the SL1(j) with the smallest beta and swap it with SX1(i). Finally, repeat this process until beta = 0 (optimal) or beta reaches its minimum value and remains unchanged after 10 iterations, thus completing the optimization convergence process. The replaced SX1 is then used as the priority for the pending delivery position contract. After optimizing SX1, optimize SX2-SXn in the same way. The goal of iterative optimization is to make the total amount of USD in the expected selected SX1 as close as possible to the USD balance AMOUNT held by user 1, minimizing the objective function Min|AMOUNT-Sum|. Here's an additional explanation of the SX1 generation process: Randomly select a contract from SS1 and add it to SX, ensuring that AMOUNT ≥ Sum, where AMOUNT is the USD balance held by user 1 and Sum is the total amount of USD sold in the selected SX1. Then update SL1 (SL1 = SS - SX1). Repeat this step until SX1 is not empty and all pending contracts no longer meet the constraints. Then SX1 and its corresponding SL1 are generated. The generation methods for the other SXn and SLn groups are similar. Since USD has the highest priority (alpha) in determining currency priority, USD is selected as the group. The replaced SX1-SXn are placed sequentially into the pending-delivery ordered queue solu. After placement, SX1-SXn is cleared, and the corresponding SL1-SLn is updated. After delivery, the AMOUNT balance used for calculation is updated. Repeat this process until all contracts are placed into solu, and the alpha of the remaining groups is all greater than 1. Then, the remaining contracts are directly placed into solu in order. Finally, solu1 includes all pending-delivery positions of user 1 stored in order. The goal of the entire process is to prioritize processing groups of currencies whose settlement amounts are closest to the balance, to consume the balance to cover as many contracts as possible, and finally to ensure that no contracts are missed in order to settle as cleanly as possible.
[0031] As described above, the pending delivery queue stores all pending delivery position contracts corresponding to the user in delivery order. During the delivery process, as an optional implementation of step S160, such as... Figure 6 As shown, the delivery according to the priority of the currency and the priority of the pending delivery position contracts includes: In step S161, the contract positions to be delivered are extracted according to the queue order of the ordered queue to be delivered; In step S162, the extracted pending position contracts are delivered.
[0032] By placing all pending delivery contracts for the same user into an ordered queue according to currency priority (delivery coverage from largest to smallest) and the order of delivery, it ensures that contracts with high coverage currencies are always at the head of the queue for priority delivery. This eliminates the disorderly delivery problem of smaller contracts being delivered before larger ones, a problem inherent in traditional methods, ensuring clean delivery. Furthermore, contracts are pre-processed and enqueued based on priority in one go. Subsequent deliveries are then executed sequentially according to the queue order, eliminating the need for repeated filtering and sorting. This reduces system computational overhead and directly increases delivery speed. Additionally, since the pending delivery ordered queue is essentially a queue, it follows a first-in, first-out (FIFO) execution logic. Each contract is removed from the queue after execution. This not only avoids the repeated scheduling and execution of the same contract, but also fundamentally eliminates the possibility of dead loops.
[0033] To avoid confusion in position settlement from the data source and further ensure the accuracy of settlement, this application discloses a specific preprocessing method. As an optional implementation of step S110, such as... Figure 7 As shown, the preprocessing of multiple pending delivery position contracts to obtain multiple sets of processed pending delivery position contracts for the same user corresponding to the currency type includes: In step S111, based on the current date as the delivery date, the contract for delivery of the same delivery date is extracted from the contract for delivery position database; In step S112, user information is determined from the extracted contract positions with the same delivery date that are awaiting delivery. In step S113, pending position contracts with the same user information are divided into user classes to obtain multiple processed pending position contracts for user classes; wherein, pending position contracts of the same user class have the same user information. In step S114, the currency type of the processed pending position contracts of the same user class is extracted; In step S115, the pending delivery position contracts of the same currency type in the same user class are divided into the same group, resulting in multiple groups of processed pending delivery position contracts of the same user corresponding to the currency type.
[0034] Figure 8 This describes the specific implementation process of the above preprocessing. Taking User 1 as an example, the set of pending delivery position contracts for each currency corresponding to User 1 is obtained. The set of pending delivery position contracts for each currency corresponding to the other users is similar. Figure 8 The results for User 1 are shown below. Each user and currency group formed after this preprocessing is an independent computational task unit, which can be directly assigned to idle threads for parallel processing. Without the preprocessing method proposed in this invention, threads would need to sift through massive amounts of messy contracts, generating a large amount of invalid computation. This preprocessing allows threads to directly determine the settlement order, reducing the computational complexity of subsequent local optimization algorithms and shortening task execution time.
[0035] Considering that in practical applications, some threads might be in an occupied state and cannot be directly assigned to a preprocessing group, in such cases, when multiple threads are all in an occupied state, threads in an occupied state are assigned to each group based on the number of pending contracts after processing and the resource utilization rate of each thread. Specifically, the number of pending contracts for each group is obtained, and threads with lower resource utilization rates are assigned to groups with more contracts. Threads with high resource utilization are assigned to groups with fewer contracts. Resource utilization can be CPU utilization, memory utilization, or a weighted sum of both. This dynamic thread scheduling method avoids computational overload or idle resource issues, further improving resource utilization. Furthermore, it can leverage... Figure 9 This method better manages task flow and thread state. Figure 9 This is a flowchart illustrating the process and status management of position contract settlement tasks. It shows the status relationship between tasks and execution units throughout the entire process, from solving the task (determining the settlement order) to executing the settlement task. It includes four modules and two task flows. The four modules are: the Task Manager (managing pre-processed tasks for determining the settlement order); the CalculateAgent pool (storing CalculateAgent execution units for executing these tasks); the Settlement Task Manager (managing pending settlement tasks); and the SettleAgent pool (storing SettleAgent execution units for performing settlement operations). Solid lines represent completed states, and dashed lines represent unclaimed / idle states. The dashed line indicates the execution (solving / settling) status. Taking Task 2 as an example, when Task 2 is in the unclaimed state, it is assigned to the idle solving thread CalculateAgent. After CalculateAgent completes the solution for Task 2 (i.e., determines the settlement order and puts all pending settlement positions in Task 2 into the pending settlement queue), the task with the determined settlement order is transferred to the unclaimed tasks in the settlement task manager. Finally, the idle settlement thread SettleAgent completes the settlement of Task 2 in the settlement task manager. By using the above state flow and task management method, the task scheduling and state flow of position contract settlement can be made clearer, more controllable, and decoupled, directly improving the stability, efficiency, and maintainability of the system. As a second aspect of the present invention, an electronic device is provided, such as... Figure 10 As shown, it includes: One or more processors 101; The memory 102 stores one or more computer programs that, when executed by the one or more processors 101, cause the one or more processors 101 to implement the position contract settlement method provided according to the first aspect of the invention.
[0036] The tool may also include one or more I / O interfaces 103 connected between the processor 101 and the memory 102, configured to enable information interaction between the processor 101 and the memory 102.
[0037] The processor 101 is a device with data processing capabilities, including but not limited to a central processing unit 101 (CPU); the first memory 102 is a device with data storage capabilities, including but not limited to random access memory 102 (RAM, more specifically SDRAM, DDR, etc.), read-only memory 102 (ROM), electrically erasable programmable read-only memory 102 (EEPROM), and flash memory (FLASH); the I / O interface 103 (read-write interface) is connected between the processor 101 and the memory 102, enabling information interaction between the processor 101 and the memory 102, including but not limited to a data bus 104 (Bus).
[0038] In some embodiments, the processor 101, memory 102, and I / O interface 103 are interconnected via bus 104, and thus connected to other components of the computing device.
[0039] Furthermore, as a third aspect of the present invention, a computer-readable medium is also provided having a computer program stored thereon, such as... Figure 10As shown, when the computer program is executed by the processor, it implements the position contract settlement method provided in the first aspect of the present invention.
[0040] Those skilled in the art will understand that all or part of the processes in the methods of the above embodiments can be implemented by a computer program instructing related hardware. Accordingly, the computer program can be stored in a non-volatile computer-readable storage medium, and when executed, it can implement the methods of any of the above embodiments. Any references to memory, storage, databases, or other media used in the embodiments provided in this application can include non-volatile and / or volatile memory. Non-volatile memory may include read-only memory (ROM), programmable ROM (PROM), electrically programmable ROM (EPROM), electrically erasable programmable ROM (EEPROM), or flash memory. Volatile memory may include random access memory (RAM) or external cache memory. By way of illustration and not limitation, RAM is available in a variety of forms, such as static RAM (SRAM), dynamic RAM (DRAM), synchronous DRAM (SDRAM), dual data rate SDRAM (DDRSDRAM), enhanced SDRAM (ESDRAM), synchronous link DRAM (SLDRAM), RAMbus direct RAM (RDRAM), direct memory bus dynamic RAM (DRDRAM), and memory bus dynamic RAM (RDRAM).
[0041] The above are merely specific embodiments of the present invention, but the scope of protection of the present invention is not limited thereto. Those skilled in the art should understand that the present invention includes, but is not limited to, the contents described in the accompanying drawings and the specific embodiments above. Any modifications that do not depart from the functional and structural principles of the present invention will be included within the scope of the claims.
Claims
1. A method of settling a position contract, characterized by, The position contract delivery method comprises: Preprocessing a plurality of to-be-delivered position contracts to obtain a plurality of groups of processed to-be-delivered position contracts of the same user corresponding to currency types; Obtaining account amounts of each currency and to-be-delivered amounts of the processed to-be-delivered position contracts of the same group; Obtaining resource usage states of a plurality of threads; wherein the threads are users of CPU basic computing resources; Allocating threads in an idle state to each group, and updating the resource usage state of the thread to an occupied state when it is detected that the allocation is completed; Determining currency priorities for delivery and priorities of to-be-delivered position contracts corresponding to the currencies according to the currency types, the account amounts of the currencies and the to-be-delivered amounts of the processed to-be-delivered position contracts of the same group by using the thread in the occupied state; Delivering according to the currency priorities and the priorities of the to-be-delivered position contracts; Updating the resource usage state of the thread corresponding thereto to an idle state when it is detected that the delivery is completed.
2. The method of claim 1, wherein, The method for determining the currency priorities for delivery and the priorities of the to-be-delivered position contracts corresponding to the currencies according to the currency types, the account amounts of the currencies and the to-be-delivered amounts of the processed to-be-delivered position contracts of the same group by using the thread in the occupied state comprises: Creating a to-be-delivered ordered queue; wherein the size of the to-be-delivered ordered queue is greater than or equal to the total number of to-be-delivered position contracts included by the user; Emptying the to-be-delivered ordered queue; Determining the account amounts of each currency type and the total to-be-delivered amount of the processed to-be-delivered position contracts including the currency type; Taking the ratio of the determined total to-be-delivered amount to the account amount as the delivery coverage of each currency type; Ranking the delivery coverages in descending order to obtain the currency priorities for delivery; Determining the priorities of the to-be-delivered position contracts of each currency by using a local optimization algorithm according to the order of the currency priorities; Putting the to-be-delivered position contracts with the determined priorities into the to-be-delivered ordered queue in the order of the priorities.
3. The method of claim 2, wherein, The objective function of the local optimization algorithm is a minimization function of the difference between the account amount corresponding to the currency and the total amount of the selected to-be-delivered position contracts; and the constraint condition of the local optimization algorithm is that the total amount of the selected to-be-delivered position contracts corresponding to the currency is less than or equal to the corresponding account amount; The method for determining the priorities of the to-be-delivered position contracts of each currency by using the local optimization algorithm according to the order of the currency priorities comprises: Selecting a plurality of to-be-delivered position contracts from all to-be-delivered position contracts including the currency as initial to-be-delivered position contracts according to the constraint condition for the currency corresponding to the order of the currency priorities; Taking the to-be-delivered position contracts not selected as alternative to-be-delivered position contracts; Determining an initial objective function according to the initial to-be-delivered position contracts and the objective function; Optimizing the initial objective function by using the alternative to-be-delivered position contracts and the initial to-be-delivered position contracts to obtain the priorities of the to-be-delivered position contracts of the currency.
4. The method of claim 3, wherein, The evaluation index of the local optimization algorithm satisfies the following formula (1): beta = AMOUNT - SUM - SX(i) + SL(j) (1) Wherein, beta is an evaluation index of the objective function, AMOUNT is an account amount corresponding to the currency, SUM is a total amount of the sold currency in the selected delivery position contract, SX(i) is the i-th contract in the initial delivery position contract, and SL(j) is the j-th contract in the alternative delivery position contract; The optimization of the initial objective function by using the alternative delivery position contract and the initial delivery position contract to obtain the priority of the delivery position contract of the currency comprises: selecting the i-th contract in the initial delivery position contract; wherein, 1≤i≤N_SX; N_SX is the number of the initial delivery position contract; selecting the j-th contract from the alternative delivery position contract according to the constraint condition; wherein, 1≤j≤N_SL; N_SL is the number of the alternative delivery position contract; replacing the j-th contract with the i-th contract, and determining the evaluation index of the i-th contract and the N_SL j-th contracts according to formula (1); In the case that the determined evaluation index is zero within a preset number of cycles, the replaced initial delivery position contract corresponding to the zero evaluation index is taken as the priority of the delivery position contract.
5. The method of claim 4, wherein, The optimization of the initial objective function by using the alternative delivery position contract and the initial delivery position contract to obtain the priority of the delivery position contract of the currency further comprises: In the case that the determined evaluation index is not zero within a preset number of cycles, the replaced initial delivery position contract corresponding to the minimum value of the evaluation index is taken as the priority of the delivery position contract.
6. The method of claim 1 to 5, wherein, The delivery order queue stores the delivery position contracts arranged according to the currency priority and the delivery position contract priority; The delivery according to the currency priority and the delivery position contract priority comprises: extracting the delivery position contract according to the queue order of the delivery order queue; delivering the extracted delivery position contract.
7. The method of claim 1 to 5, wherein, The preprocessing of the multiple delivery position contracts to obtain multiple groups of processed delivery position contracts of the same user corresponding to the currency type comprises: extracting the delivery position contracts of the same delivery date from the delivery position contract database according to the current date as the delivery date; determining the user information in the extracted delivery position contracts of the same delivery date; dividing the delivery position contracts of the same user information into user classes to obtain multiple groups of processed delivery position contracts of the user classes; wherein, the user information of the delivery position contracts in the same user class is the same; extracting the currency type of the processed delivery position contracts of the same user class; dividing the delivery position contracts of the same currency type in the same user class into the same group to obtain multiple groups of processed delivery position contracts of the same user corresponding to the currency type.
8. The method of claim 1 to 5, wherein, The position contract delivery method further comprises: In the case that the acquired resource usage states of the plurality of threads are all in the occupied state, the threads corresponding to the occupied state are allocated to each group according to the number of processed position contracts to be delivered of each group and the resource occupation rate of each thread.
9. An electronic device, comprising: Comprise: One or more processors; A memory having one or more computer programs stored thereon, wherein when the one or more computer programs are executed by the one or more processors, the one or more processors implement the position contract delivery method according to any one of claims 1 to 8.
10. A computer readable medium having stored thereon a computer program, characterized in that, The computer program is executed by the processor to implement the position contract delivery method according to any one of claims 1 to 8. The computer program is executed by the processor to implement the position contract delivery method according to any one of claims 1 to 8.
Citation Information
Patent Citations
Computer-implemented method and system for flat multi-currency transactions
CN118628239A
Foreign exchange service position contract grouping and circulating delivery method and system
CN119295208A
Business data processing method and program product
CN120872555A
System and method for financial matching
US20140279371A1