Risk calculation method and risk calculation system
Through multi-threaded distributed parallel computing and automatic switching mechanism, the problem of insufficient risk calculation performance in the foreign exchange margin trading system is solved, efficient capital risk control is achieved, and risks for customers and financial institutions are reduced.
Patent Information
- Application Number
- CN202110595325.9
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2021-05-28
- Publication Date
- 2024-11-01
- Estimated Expiration
- 2041-05-28
AI Technical Summary
When the number of customers increases and market fluctuates, there are insufficient performance problems in the risk calculation process, resulting in a longer calculation of the calculation time and the inability to calculate the capital adequacy ratio in a timely manner, which affects risk control and increases customer losses and financial institutions' complaint risks. .
Using multi-threaded distributed parallel computing method, the management node generates risk instructions, and the distribution server distributes to multiple computing nodes for calculation. The routing information and heartbeat detection mechanism ensure efficient operation of the system, and automatically switches backup nodes when a failure occurs, improving System availability.
It significantly improves the computing speed and operation efficiency, ensures timely control of capital risks, reduces customer losses and financial institutions' complaint risks, and improves the performance and availability of the trading system.
Smart Images

Figure CN113313571B_ABST
Abstract
Description
Technical Field
[0001] The present application relates to the field of information technology, and in particular to a risk calculation method and a risk calculation system. Background Art
[0002] In the banking and financial market, the foreign exchange margin trading system can provide two-way transactions of long and short positions. After the customer deposits the margin to start trading, the risk measurement module of the foreign exchange margin trading system can continuously calculate the customer's capital adequacy ratio. When the capital adequacy ratio is insufficient, it will send a text message to notify the customer to add margin or control the risk by forced liquidation.
[0003] The traditional risk calculation process uses polling to calculate the capital adequacy ratio of all customers one by one. As the number of customers increases, the amount of calculation continues to increase, the calculation time becomes longer and longer, and finally timeouts and other performance problems occur. In addition, when the market fluctuates violently, the amount of calculation of the risk calculation module will increase dramatically. Due to insufficient performance, it may not be able to calculate the customer risk index in a timely and accurate manner, and it may not be able to notify the user of the existing risks in a timely manner, which will affect the subsequent customer margin call and forced liquidation operations, causing customers to trade at unfavorable prices, resulting in unnecessary losses, and increasing the risk of complaints against banks and other financial institutions. Summary of the invention
[0004] The present application provides a risk calculation method and a risk calculation system, which can generate calculation tasks for different risk scenarios and adopt multi-threaded distributed parallel calculation, which is conducive to improving the calculation speed and operation efficiency and facilitating timely financial risk control.
[0005] In a first aspect, a risk measurement method is provided, which can be applied to a system including a management node, a distribution server and multiple computing nodes, the method comprising: the management node obtains risk data generated when multiple users conduct foreign exchange transactions, generates multiple risk instructions based on the risk data of the multiple users, and sends the multiple risk instructions to the distribution server, the multiple risk instructions respectively including identification information of the multiple users; the distribution server receives the multiple risk instructions, and distributes the multiple risk instructions to all or part of the multiple computing nodes according to pre-generated routing information, the routing information including the correspondence between the multiple computing nodes and the identification information of the multiple users; all or part of the computing nodes receive the multiple risk instructions, and calculate risk assessment parameters of the multiple users according to the multiple risk instructions, the risk assessment parameters are used to evaluate the risk level of at least one user.
[0006] In combination with the first aspect, in certain implementations of the first aspect, all or part of the computing nodes receive multiple risk instructions, and calculate risk assessment parameters of multiple users based on the multiple risk instructions, including: a first computing node among all or part of the computing nodes receives a first risk instruction among the multiple risk instructions; the first computing node calculates the risk assessment parameter of the first user based on the first risk instruction using an algorithm corresponding to the type of the first risk instruction.
[0007] In combination with the first aspect, in certain implementations of the first aspect, the first risk instruction includes identification information of a first user among multiple users; before the first computing node calculates the risk assessment parameters of the first user based on the first risk instruction using an algorithm corresponding to the type of the first risk instruction, the method also includes: the first computing node determines, based on the identification information of the first user, whether the first risk instruction is a signing instruction or whether the first user has an instruction queue; if the first risk instruction is not a signing instruction or the first user already has an instruction queue, the first computing node inserts the first risk instruction into the instruction queue of the first user.
[0008] In combination with the first aspect, in some implementations of the first aspect, the method further includes: creating a new instruction queue for the first user.
[0009] In combination with the first aspect, in certain implementations of the first aspect, the system also includes a backup distribution server, and the above method also includes: the distribution server periodically sends a first heartbeat information of the distribution server to the management node; the management node receives the first heartbeat information from the distribution server and starts a first timer; if the management node does not receive a second heartbeat information from the distribution server before the first timer expires, the management node determines that the distribution server has failed; the management node switches multiple risk instructions from the distribution server to the backup distribution server.
[0010] In combination with the first aspect, in certain implementations of the first aspect, the system also includes a centralized monitoring node, and the above method also includes: the management node sends a first alarm message to the centralized monitoring node, and the first alarm message is used to indicate that a failure has occurred in the distribution server; the centralized monitoring node receives the first alarm message and displays a notification message to the operation and maintenance personnel, and the notification message is used to notify the operation and maintenance personnel to check the distribution server.
[0011] In combination with the first aspect, in certain implementations of the first aspect, the system also includes a backup computing node, and the above method also includes: a second computing node among the multiple computing nodes periodically sends the third heartbeat information of the second computing node to the management node; the management node receives the third heartbeat information from the second computing node and starts a second timer; if the management node does not receive the fourth heartbeat information from the second computing node before the second timer expires, the management node determines that the second computing node has failed; the management node notifies the distribution server to transfer the risk instruction sent to the second computing node to the backup computing node.
[0012] In combination with the first aspect, in certain implementations of the first aspect, the system also includes a centralized monitoring node, and the above method also includes: the management node sends a second alarm message to the centralized monitoring node, and the second alarm message is used to indicate that a failure has occurred in the second computing node; the centralized monitoring node receives the second alarm message and displays a notification message to the operation and maintenance personnel, and the notification message is used to notify the operation and maintenance personnel to check the second computing node.
[0013] In combination with the first aspect, in some implementations of the first aspect, the system further includes a standby management node, and the standby management node and the management node are automatically switched according to preset rules.
[0014] In combination with the first aspect, in certain implementations of the first aspect, the type of risk instruction includes at least one of the following: capital type, transaction type, time type, special type, or system type.
[0015] In combination with the first aspect, in certain implementations of the first aspect, the risk data includes at least one of the following: opening a position, closing a position, depositing or withdrawing funds, manual forced liquidation, automatic forced liquidation, real-time quotes, time intervals, overnight interest rate spreads, or contract signing.
[0016] In combination with the first aspect, in certain implementations of the first aspect, the type of risk instructions corresponding to risk data including opening a position, closing a position, manual forced liquidation or automatic forced liquidation is a transaction type; the type of risk instructions corresponding to risk data including deposits and withdrawals is a capital type; the type of risk instructions corresponding to risk data including real-time quotes is a quote type; the type of risk instructions corresponding to risk data including time intervals is a time type; the type of risk instructions corresponding to risk data including overnight interest rate spreads is a special type; and the type of risk instructions corresponding to risk data including contract signing is a system type.
[0017] In a second aspect, a risk measurement system is provided, which includes a management node, a distribution server, and multiple computing nodes. The management node is used to: obtain risk data generated when multiple users conduct foreign exchange transactions, generate multiple risk instructions based on the risk data of the multiple users, and send the multiple risk instructions to the distribution server, wherein the multiple risk instructions respectively include identification information of the multiple users; the distribution server is used to: receive the multiple risk instructions, and distribute the multiple risk instructions to all or part of the multiple computing nodes according to pre-generated routing information, wherein the routing information includes the corresponding relationship between the multiple computing nodes and the identification information of the multiple users; all or part of the multiple computing nodes are used to: receive the multiple risk instructions, and calculate the risk assessment parameters of the multiple users according to the multiple risk instructions, wherein the risk assessment parameters are used to evaluate the risk levels of the multiple users.
[0018] In combination with the second aspect, in certain implementations of the second aspect, the first computing node among all or part of the computing nodes is used to: receive a first risk instruction among multiple risk instructions; and calculate a risk assessment parameter of the first user based on the first risk instruction using an algorithm corresponding to the type of the first risk instruction.
[0019] In combination with the second aspect, in certain implementations of the second aspect, the first risk instruction includes identification information of a first user among multiple users; the first computing node is also used to: determine whether the first risk instruction is a signing instruction or whether the first user has an instruction queue based on the identification information of the first user; if the first risk instruction is not a signing instruction or the first user already has an instruction queue, insert the first risk instruction into the instruction queue of the first user.
[0020] In combination with the second aspect, in some implementations of the second aspect, the first computing node is further used to: create a new instruction queue for the first user.
[0021] In combination with the second aspect, in certain implementations of the second aspect, the system also includes a backup distribution server, and the distribution server is also used to: periodically send the first heartbeat information of the distribution server to the management node; the management node is also used to: receive the first heartbeat information from the distribution server and start the first timer; if the second heartbeat information from the distribution server is not received before the first timer expires, it is determined that the distribution server has failed; and multiple risk instructions are switched from the distribution server to the backup distribution server.
[0022] In combination with the second aspect, in certain implementations of the second aspect, the system also includes a backup computing node; the second computing node among the multiple computing nodes is used to: periodically send the third heartbeat information of the second computing node to the management node; the management node is also used to: receive the third heartbeat information from the second computing node, and start a second timer; if the fourth heartbeat information from the second computing node is not received before the second timer expires, it is determined that the second computing node has failed; and the distribution server is notified to transfer the risk instructions sent to the second computing node to the backup computing node.
[0023] In combination with the second aspect, in certain implementations of the second aspect, the system also includes a centralized monitoring node; the management node is also used to: send a second alarm message to the centralized monitoring node, the second alarm message is used to indicate that a failure has occurred in the second computing node; the centralized monitoring node is also used to: receive the second alarm message, and display a notification message to the operation and maintenance personnel, the notification message is used to notify the operation and maintenance personnel to check the second computing node.
[0024] In combination with the second aspect, in some implementations of the second aspect, the system further includes a standby management node, and the standby management node and the management node are automatically switched according to preset rules.
[0025] In conjunction with the second aspect, in certain implementations of the second aspect, the type of risk instruction includes at least one of the following: capital type, transaction type, time type, special type, or system type.
[0026] In combination with the second aspect, in certain implementations of the second aspect, the risk data includes at least one of the following: opening a position, closing a position, depositing or withdrawing funds, manual forced liquidation, automatic forced liquidation, real-time quotes, time intervals, overnight interest rate spreads, or contract signing.
[0027] In combination with the second aspect, in certain implementation methods of the second aspect, the type of risk instructions corresponding to risk data including opening a position, closing a position, manual forced liquidation or automatic forced liquidation is a transaction type; the type of risk instructions corresponding to risk data including deposits and withdrawals is a capital type; the type of risk instructions corresponding to risk data including real-time quotes is a quote type; the type of risk instructions corresponding to risk data including time intervals is a time type; the type of risk instructions corresponding to risk data including overnight interest rate spreads is a special type; and the type of risk instructions corresponding to risk data including contract signing is a system type.
[0028] The risk calculation method and risk calculation system provided in the embodiments of the present application generate risk instructions for multiple users from the risk data of multiple users, and distribute them to different computing nodes for distributed parallel computing, which can effectively improve the computing speed and operating efficiency, enhance the performance of the trading system, and thus realize capital risk control in a timely manner. BRIEF DESCRIPTION OF THE DRAWINGS
[0029] Figure 1 It is a schematic diagram of the architecture of a risk calculation system proposed in an embodiment of the present application;
[0030] Figure 2 is a schematic flow chart of a risk estimation method proposed in an embodiment of the present application;
[0031] Figure 3 is a schematic flow chart of another risk estimation method proposed in an embodiment of the present application;
[0032] Figure 4 It is a schematic flowchart of a processing method within a computing node proposed in an embodiment of the present application. DETAILED DESCRIPTION
[0033] The technical solution in this application will be described below in conjunction with the accompanying drawings.
[0034] The foreign exchange business of a bank refers to the exchange of one country's currency into another country's currency at a certain ratio, and this exchange ratio is called the exchange rate. For individual customers, there are two foreign exchange trading systems: 1) the real-time trading system, in which physical delivery is completed when foreign exchange is bought and sold, and short selling is not allowed; the foreign exchange margin trading system, in which customers can trade in both long and short directions after signing a contract and depositing a RMB or foreign currency margin of not less than a certain percentage of the nominal principal of the trading currency.
[0035] For the foreign exchange margin trading system, after the customer deposits the margin to start trading, the risk measurement module of the foreign exchange margin trading system can continuously calculate the customer's capital adequacy ratio and assess the risk level in order to carry out corresponding risk control. For example, when the capital adequacy ratio is insufficient, a text message will be sent to notify the customer to add margin or to control the risk by forced liquidation.
[0036] The traditional risk calculation process uses polling to calculate the capital adequacy ratio of all customers one by one. As the number of customers increases, the amount of calculation continues to increase, the calculation time becomes longer and longer, and finally timeouts and other performance problems occur. In addition, when the market fluctuates violently, the amount of calculation of the risk calculation module will increase dramatically. Due to insufficient performance, it may not be able to calculate the customer risk index in a timely and accurate manner, and it may not be able to notify the user of the existing risks in a timely manner, which will affect the subsequent customer margin call and forced liquidation operations, causing customers to trade at unfavorable prices, resulting in unnecessary losses, and increasing the risk of complaints against banks and other financial institutions.
[0037] In view of this, the embodiments of the present application provide a risk calculation method and a risk calculation system, which can generate calculation tasks for different risk scenarios and adopt multi-threaded distributed parallel calculation, which is conducive to improving the calculation speed and operation efficiency, and facilitating timely financial risk control.
[0038] To facilitate understanding, the relevant terms involved in the embodiments of the present application are first introduced.
[0039] 1. Going long: It refers to the trading behavior of buying a certain amount of stocks at the current price in anticipation of future price increases, and then selling them at a higher price after the price increases, thereby earning the difference profit. Going long is characterized by a trading method of buying first and then selling.
[0040] 2. Short selling: It is a trading method that sells stocks at the current price in anticipation of a future price drop, and then buys them back after the market drops to make a profit from the price difference. The characteristic of short selling is that it is a trading method of selling first and then buying.
[0041] 3. Margin: generally refers to a certain amount of funds invested by customers as margin, and foreign exchange transactions are carried out within the expanded investment amount range according to a certain leverage multiple. For example, customers holding positions need to pay funds as a reserve for the risk of trading profits and losses.
[0042] 4. Funding adequacy ratio: refers to the ratio between the total amount of funds in the customer's margin account that can be used as margin and the margin amount occupied by the customer for trading.
[0043] 5. Cloud computing: It is a type of distributed computing, which refers to decomposing huge data computing programs into countless small programs through the network "cloud", and then performing parallel processing and branching through a system composed of multiple servers, and finally merging the results obtained by the small programs and returning them to the user.
[0044] 6. Fourinone: It is a four-in-one distributed lightweight cloud computing platform that integrates four major distributed computing functions: distributed computing (hadoop), zookeeper, message queue (MQ), and distributed cache (memcache), and greatly simplifies and summarizes complex distributed computing applications.
[0045] 7. Risk instruction: It is a data structure that contains the data information needed to calculate the capital adequacy ratio in various scenarios where risks may occur. The format of risk instructions is different in different risk scenarios.
[0046] 8. Distributed scheduling: In a distributed system, the process of assigning risk instructions or computing tasks to different computing nodes for execution in a certain priority order based on a routing algorithm.
[0047] 9. Thread synchronization: Multithreading controls the execution order between threads through specific settings.
[0048] Combine the following Figures 1 to 4, a risk calculation system and a risk calculation method of an embodiment of the present application are introduced in detail.
[0049] Figure 1 The architecture diagram of a risk measurement system 100 provided in an embodiment of the present application is shown, and the risk measurement system 100 includes: a management node, a distribution server, and multiple computing nodes. Among them, the multiple computing nodes are described by taking the first computing node and the second computing node as an example. It should be understood that the multiple computing nodes should not be limited to the first computing node and the second computing node, and the number of computing nodes is only an example.
[0050] Exemplarily, the risk estimation system 100 may be a system constructed based on the fourinone open source cloud platform as a basic development framework.
[0051] The management node can monitor the heartbeat information of the distribution server, the first computing node and the second computing node to understand the operating status of the distribution server, the first computing node and the second computing node, and can better guide the distribution server to perform routing planning and routing redirection.
[0052] The distribution server may obtain instructions from the management node, and distribute the instructions to the first computing node and the second computing node according to the routing table.
[0053] The first computing node and the second computing node may parse and perform computation processing on the instruction.
[0054] Optionally, the risk estimation system 100 may further include a backup distribution server, which may be used to take over the tasks of the distribution server when the distribution server fails.
[0055] Optionally, the risk estimation system 100 may further include a backup computing node. The backup computing node may be used to take over the tasks of the first computing node or the second computing node when the first computing node or the second computing node fails.
[0056] Optionally, the risk calculation system 100 may further include a centralized monitoring platform. The centralized monitoring platform may be used to receive alarm information sent by the management node and send text messages to maintenance personnel to notify them of problems with the risk calculation system 100.
[0057] Optionally, the risk measurement system 100 may further include a standby management node. The standby management node may be used to take over the tasks of the management node when the management node fails. The standby management node and the management node may be automatically switched according to a preset rule. For example, the preset rule may be a zookeeper algorithm.
[0058] Optionally, in the above risk calculation system 100, when the load of a computing node among multiple computing nodes is too large, a new computing node can be started in the risk calculation system 100 and the distribution server can be restarted to expand the performance and realize dynamic scalability.
[0059] Based on the above-mentioned risk calculation system 100, an embodiment of the present application provides a risk calculation method. Figure 2 This is a schematic flow chart of a risk estimation method 200 provided in an embodiment of the present application. The method 200 can be applied to the above-mentioned risk estimation system 100, but the embodiment of the present application is not limited thereto.
[0060] The method 200 may include the following steps:
[0061] S201, a management node obtains risk data generated when multiple users conduct foreign exchange transactions, and generates multiple risk instructions according to the risk data of the multiple users, wherein the multiple risk instructions respectively include identification information of the multiple users.
[0062] When a user conducts foreign exchange transactions, certain operations performed may generate risks and cause asset damage. In the embodiment of the present application, the data generated by the operations that may generate risks when the user conducts foreign exchange transactions is referred to as risk data. For example, when a user conducts foreign exchange transactions in the page display part of the foreign exchange margin trading system, a risk operation is performed, and the management node can obtain the risk data generated by the risk operation.
[0063] Optionally, the risk data may include at least one of the following: opening a position, closing a position, depositing or withdrawing funds, manual liquidation, automatic liquidation, real-time quotes, time intervals, overnight interest rate spreads, or contract signing.
[0064] When multiple users conduct transactions on the foreign exchange margin trading system, the management node can obtain the risk data generated by the multiple users when conducting foreign exchange transactions. After the management node obtains the risk data generated by the risk operations of the multiple users, it generates multiple risk instructions according to the risk data of the multiple users. The risk instructions may include the data information required to calculate the risk assessment parameters under the risk. In addition, the risk instructions also include the user's identification information, which is used to distinguish the risk instructions of different users.
[0065] Under different risks, the data information required by the management node to calculate the risk assessment parameters is different, so under different risks, the data structure of the generated risk instructions is different.
[0066] Optionally, the type of risk instruction may include at least one of the following: capital type, transaction type, time type, special type, or system type.
[0067] Optionally, the type of risk instructions corresponding to risk data including opening a position, closing a position, manual forced liquidation or automatic forced liquidation is a transaction type; the type of risk instructions corresponding to risk data including deposits and withdrawals is a capital type; the type of risk instructions corresponding to risk data including real-time quotes is a quote type; the type of risk instructions corresponding to risk data including time intervals is a time type; the type of risk instructions corresponding to risk data including overnight interest rate spreads is a special type; and the type of risk instructions corresponding to risk data including contracts is a system type.
[0068] S202: The management node sends a plurality of risk instructions to the distribution server, and accordingly, the distribution server receives the plurality of risk instructions.
[0069] Optionally, the management node may also store multiple risk instructions in a risk instruction queue, and accordingly, the distribution server obtains the risk instruction from the risk instruction queue.
[0070] S203, the distribution server distributes the multiple risk instructions to all or part of the multiple computing nodes according to the pre-generated routing information, where the routing information includes the correspondence between the multiple computing nodes and the identification information of the multiple users.
[0071] The corresponding relationship in the routing information may be determined by the distribution server according to a routing algorithm.
[0072] After obtaining the risk instruction, the distribution server may determine the computing node corresponding to the identification information of the user in the risk instruction according to the identification information of the user in the risk instruction, and distribute the risk instruction to the corresponding computing node.
[0073] Optionally, if the distribution server cannot find the computing node corresponding to the identification information of the user in the routing information, the risk instruction may be distributed to the computing node that processes the least risk instructions among the multiple computing nodes through a load balancing method.
[0074] Optionally, if the distribution server cannot find the computing node corresponding to the identification information of the user in the routing information, the risk instruction can be distributed to multiple computing nodes in sequence by polling. For example, after the distribution server obtains the risk instruction 1, it distributes the risk instruction 1 to the computing node 2 corresponding to the identification information of the user in the risk instruction 1 according to the routing information. If the distribution server cannot find the computing node corresponding to the identification information of the user in the risk instruction 2 according to the routing information after obtaining the risk instruction 2, the distribution server distributes the risk instruction 1 to the computing node adjacent to the computing node 2 (computing node 1 or computing node 3).
[0075] S204, all or part of the computing nodes receive multiple risk instructions, and calculate risk assessment parameters of multiple users according to the multiple risk instructions, where the risk assessment parameters are used to evaluate the risk levels of the multiple users.
[0076] After receiving risk instructions from different users, different computing nodes collect corresponding data information and calculate the risk assessment parameters of the users in parallel. The risk assessment parameters can evaluate the risk level of the users to determine whether to send SMS to notify the users to add margin or to control the risk by forced liquidation. For example, the risk assessment parameter can be the capital adequacy ratio.
[0077] It should be understood that different types of risk instructions have different data structures and different data information required to calculate risk assessment parameters. Therefore, the computing node can calculate the user's risk assessment parameters using an algorithm corresponding to the type of risk instruction.
[0078] The risk calculation method provided in the embodiment of the present application generates risk instructions for multiple users from the risk data of multiple users, and distributes them to different computing nodes for distributed parallel computing, which can effectively improve the computing speed and operating efficiency, enhance the performance of the trading system, and thus realize capital risk control in a timely manner.
[0079] As an optional embodiment, the above method 200 may also include: the distribution server periodically sends the first heartbeat information of the distribution server to the management node; the management node receives the first heartbeat information from the distribution server and starts the first timer; if the management node does not receive the second heartbeat information from the distribution server before the first timer expires, the management node determines that the distribution server has failed; the management node switches multiple risk instructions from the distribution server to the backup distribution server.
[0080] The distribution server may send the first heartbeat information to the management node at regular intervals. For example, the distribution server may send the first heartbeat information to the management node every 3 seconds, and correspondingly, the management node may obtain the first heartbeat information of the distribution server every 3 seconds.
[0081] The time of the first timer may be preset by the management node. For example, the time of the timer may be 6 seconds. If the management node does not receive the second heartbeat information from the distribution server within 6 seconds after receiving the first heartbeat information, the management node may determine that the distribution server has failed; the management node switches multiple risk instructions from the distribution server to the backup distribution server.
[0082] When the standby distribution server monitors the configuration change, it will take over the work of the distribution server. That is, after the distribution server fails, the management node can use the standby distribution server to replace all functions of the distribution server and set the available flag of the distribution server to the standby distribution server.
[0083] Optionally, the management node may monitor the heartbeat information of the distribution server by scanning the message bus, and when an abnormality is found in the heartbeat information, the distribution server is switched to a backup distribution server.
[0084] It should be understood that the standby distribution server does not distribute tasks when the system starts running, and takes over all tasks of the failed distribution server when a distribution server fails.
[0085] The risk measurement method provided in the embodiment of the present application is that the management node can detect the working status of the distribution server through the heartbeat information of the distribution server, and set a backup distribution server. When the distribution server fails, the backup distribution server is used to replace the distribution server to ensure the normal operation of the system, which is conducive to improving the availability of the system and the performance of the trading system, thereby realizing timely financial risk control.
[0086] As an optional embodiment, the above method 200 may also include: the management node sends a first alarm message to the centralized monitoring node, the first alarm message is used to indicate that a failure has occurred in the distribution server; the centralized monitoring node receives the first alarm message and displays a notification message to the operation and maintenance personnel, the notification message is used to notify the operation and maintenance personnel to check the distribution server.
[0087] The risk estimation method provided in the embodiment of the present application can send a notification message to the operation and maintenance personnel after the centralized monitoring node receives the first alarm information, so that the operation and maintenance personnel can promptly discover the problems of the distribution server and repair the distribution server in a timely manner, which is beneficial to improving the availability of the system and the performance of the trading system, thereby realizing timely financial risk control.
[0088] As an optional embodiment, the above method 200 may also include: a second computing node among multiple computing nodes periodically sends the third heartbeat information of the second computing node to the management node; the management node receives the third heartbeat information from the second computing node and starts a second timer; if the management node does not receive the fourth heartbeat information from the second computing node before the second timer expires, the management node determines that the second computing node has failed; the management node notifies the distribution server to transfer the risk instructions sent to the second computing node to the backup computing node.
[0089] The second computing node may send the third heartbeat information of the second computing node to the management node at regular intervals. For example, the second computing node may send the third heartbeat information of the second computing node to the management node every 5 seconds, and correspondingly, the management node may obtain the third heartbeat information of the second computing node every 5 seconds.
[0090] The time interval for the second computing node to send the third heartbeat information to the management node and the time interval for the distribution server to send the first heartbeat information to the management node may be the same as or different from the time interval for the distribution server to send the first heartbeat information to the management node, which is not limited in the embodiment of the present application.
[0091] The time of the second timer may be preset by the management node. For example, the time of the timer may be 10 seconds. If the management node has not received the fourth heartbeat information from the second computing node within 10 seconds after receiving the third heartbeat information, the management node may determine that the second computing node has failed; the management node notifies the distribution server to transfer the risk instruction sent to the second computing node to the backup computing node.
[0092] After the second computing node fails, the management node can guide the distribution server to perform routing planning and routing redirection, that is, the management node can notify the distribution server to transfer all functions of the second computing node to the backup computing node.
[0093] Optionally, the management node may monitor the heartbeat information of the second computing node by scanning the message bus, and when it is found that the heartbeat information is abnormal, the second computing node is switched to a standby computing node.
[0094] It should be understood that when the system starts running, the standby computing node is not assigned any tasks, and when a computing node fails, it takes over all the tasks of the failed computing node.
[0095] The risk measurement method provided in the embodiment of the present application is that the management node can detect the working status of the second computing node through the heartbeat information of the second computing node, and set a backup computing node. When the second computing node fails, the backup computing node is used to replace the second computing node to ensure the normal operation of the system, which is conducive to improving the availability of the system and the performance of the trading system, thereby realizing timely financial risk control.
[0096] As an optional embodiment, the above method 200 also includes: the management node sends a second alarm information to the centralized monitoring node, the second alarm information is used to indicate that a failure has occurred in the second computing node; the centralized monitoring node receives the second alarm information and displays a notification message to the operation and maintenance personnel, the notification message is used to notify the operation and maintenance personnel to check the second computing node.
[0097] The risk estimation method provided in the embodiment of the present application can send a notification message to the operation and maintenance personnel after the centralized monitoring node receives the second alarm information, so that the operation and maintenance personnel can promptly discover the problem of the second computing node and repair the second computing node in a timely manner, which is beneficial to improving the availability of the system and the performance of the trading system, thereby realizing timely financial risk control.
[0098] The risk estimation method provided in the embodiment of the present application automatically switches the backup management node when the management node cannot meet the demand, which is beneficial to improving the availability of the system and the performance of the trading system, thereby realizing capital risk control in a timely manner.
[0099] Below, Figure 3 Taking the schematic flow chart of the risk calculation method 300 as an example, the risk calculation method provided by the embodiment of the present application is described in detail. The method 300 can be applied to the risk calculation system 100 described above.
[0100] like Figure 3 As shown, when the risk calculation system 100 is running, the risk calculation method 300 may include the following steps:
[0101] S301, the management node can obtain risk data such as contract signing, opening and closing positions (opening and closing positions), deposits and withdrawals (withdrawals and deposits), manual forced liquidation, real-time quotes, time intervals, overnight interest rate spreads, and automatic forced liquidation, and generate risk instructions based on the risk data.
[0102] Among them, the risk data of signing contracts, opening and closing positions, withdrawing funds and depositing funds can be generated when users sign contracts, open and close positions, and deposit and withdraw funds. The risk data of manual forced liquidation can be generated when the administrator manually performs forced liquidation operations. The quotation engine can generate risk data of real-time quotation, the end-of-day process can generate risk data of time intervals, and the end-of-day batch can generate risk data of overnight interest rate spreads. The management node can generate risk data of automatic forced liquidation by detecting the risk status of users.
[0103] The management node can generate risk instructions for signing contracts after obtaining the risk data of contracts; can generate risk instructions for opening and closing positions after obtaining the risk data of opening and closing positions; can generate risk instructions for deposits and withdrawals after obtaining the risk data of deposits and withdrawals; can generate risk instructions for manual forced liquidation after obtaining the risk data of manual forced liquidation; can generate risk instructions for quotations after obtaining the risk data of real-time quotations; can generate risk instructions for time after obtaining the risk data of time intervals; can generate risk instructions for overnight interest rate spreads after obtaining the risk data of overnight interest rate spreads; and can also generate risk instructions for automatic forced liquidation after obtaining the risk data of automatic forced liquidation.
[0104] After the management node generates a risk instruction, it can save the risk instruction in a risk instruction list.
[0105] S302, the distribution server may poll the risk instructions in the risk instruction list, and may distribute the risk instructions to the corresponding computing nodes according to the user's identification information (eg, the user's customer number) and routing information.
[0106] Specifically, when performing distributed scheduling, the distribution server can obtain the risk instruction sequence number range in the risk instruction queue table that should be processed by reading the risk instruction processing pointer table, and query the risk instruction based on this. For example, when performing distributed scheduling, the distribution server queries 1000 risk instructions each time, and can obtain 1000 risk instructions for processing by reading 0 to 999 in the risk instruction processing pointer table.
[0107] After the distribution server obtains the risk instruction, it can determine whether the user is in the routing table based on the user's identification information. If the user is in the routing table, the computing node where the user is located is directly determined based on the routing table; if the user is not in the routing table, the computing node corresponding to the newly added user is determined based on the load balancing algorithm or polling.
[0108] S303: After receiving the risk instruction, all or part of the computing nodes among the multiple computing nodes may store the received risk instruction in an instruction queue and perform instruction parsing.
[0109] Instruction parsing refers to the computing node determining whether the risk instruction is a signed instruction.
[0110] Exemplarily, if a first computing node among multiple computing nodes receives a first risk instruction, the first risk instruction includes identification information of a first user. The first computing node can determine whether the first risk instruction is a signing instruction or whether the first user is in the instruction queue based on the identification information of the first user.
[0111] It should be understood that the identification information of the first user is used to indicate that the first risk instruction is a risk instruction generated by the first user performing a risk operation.
[0112] If the first risk instruction is a contract instruction or the first user does not have an instruction queue, the first computing node may create a new instruction queue for the first user. The instruction queue for the first user is used to store risk instructions generated by the first user performing risk operations.
[0113] If the first risk instruction is not a contract instruction and the first user already has an instruction queue, the first computing node may insert the first risk instruction into the instruction queue of the first user.
[0114] S304, all or part of the computing nodes in the plurality of computing nodes perform distributed computing according to the analysis result, obtain the capital adequacy ratio, and assess the risk status of the user according to the capital adequacy ratio. If the risk status of the user is risky, the risk status of the user is saved in the risk user list.
[0115] For example, the first computing node can obtain the first risk instruction from the instruction queue of the first user, and based on the first risk instruction, collect corresponding data information, and collect information such as product parameters, user positions, and user funds, and use an algorithm corresponding to the type of the first risk instruction to calculate the first user's capital adequacy ratio.
[0116] Optionally, the risk user list may also store information such as the user's fund adequacy ratio and customer number.
[0117] The above criteria for assessing whether a user is in a risky state may be preset.
[0118] S305, the management node can detect the risk status of the user. If the risk status of the user is a forced liquidation status, automatic forced liquidation is triggered; if the risk status of the user is a follow-up insurance status, the user is notified to follow up insurance.
[0119] For example, the computing node can pre-set that when the capital adequacy ratio is less than or equal to 20%, the user's risk status is forced liquidation, and the management node needs to trigger automatic forced liquidation; when the capital adequacy ratio is greater than 20% but less than or equal to 50%, the user's risk status is insurance chasing status, and the management node needs to notify the user to perform insurance chasing operations. It should be understood that when the capital adequacy ratio is greater than 50%, the user's risk status is safe.
[0120] Optionally, the method 300 further includes:
[0121] S306, the management node can monitor the distribution server and the multiple computing nodes, obtain the running status of the distribution server and the multiple computing nodes, and then guide the distribution server to perform routing planning and routing redirection. For example, the management node can monitor the heartbeat information of the distribution server and the multiple computing nodes.
[0122] As an optional embodiment, the parsing and processing of the first risk instruction within the above-mentioned first computing node can be an N×N multi-threaded concurrent process. Threads can include user contract processing threads, instruction processing threads, various processor classes, result processing threads, and abnormal customer processing threads. Each type of thread can use its own thread pool to achieve concurrency. Among them, the user contract processing thread can be used to generate a risk instruction queue for each user under the product according to the contract instruction, and insert the non-contract instructions (other risk instructions except the contract instruction) of the user obtained into the user instruction queue; the instruction processing thread can be used to process the unprocessed instructions in the user risk instruction queue, and call various processor classes for processing; each processor class can be used to obtain the data information included in the risk instruction, and collect product parameters, user positions, user funds and other data, calculate the user's capital adequacy ratio and the user's floating profit and loss, and insert the result into the user result queue; the result processing thread can take out the calculation result from the user result queue and update the risk user table; the abnormal user processing thread performs abnormal risk instruction processing.
[0123] Figure 4 FIG. 4 is a schematic flow chart of a processing method 400 within a first computing node. Figure 4 As shown, the figure includes thread 1, thread 2, thread 3, thread 4 and thread 5, which respectively correspond to the above-mentioned user contract processing thread, instruction processing thread, various processor classes, result processing thread and abnormal customer processing thread.
[0124] The processing method 400 inside the first computing node may include the following steps:
[0125] S401, after receiving the first risk instruction from the distribution server, the first computing node can determine whether the first risk instruction is a signing instruction according to the identification information of the first user through thread 3 (for example, parse of each processor class).
[0126] Optionally, the first computing node may also determine whether the first user is in the instruction queue according to the identification information of the first user.
[0127] S402: If the first risk instruction is a signing instruction (or the first user does not have an instruction queue), insert it into a signing instruction queue. The signing instruction queue includes signing instructions of multiple users. For example, the signing instruction queue may be SING_QUEUE.
[0128] S403, the first computing node can take out the signing instruction from the signing instruction queue through thread 1 (for example, ComputeNodeSignThread), and create a new instruction queue for the first user based on the identification information of the first user in the signing instruction, and add the instruction queue of the first user to the total user instruction queue to update the total user instruction queue. The instruction queue of the first user is used to store the risk instructions of the first user.
[0129] S404: If the first risk instruction is not a contract instruction (or the first user has an instruction queue), the first risk instruction is inserted into the instruction queue of the first user according to the identification information of the first user in the first risk instruction, and the total user instruction queue is updated. The instruction queue of the first user is used to store the risk instructions of the first user, and the total user instruction queue is used to store the instruction queues of multiple users. For example, the total user instruction queue may be CUSTOMER_VIEW_CMD_QUEUES.
[0130] Optionally, the first computing node may query whether the first computing node includes threads for processing all risk instructions according to the risk instructions in the total user instruction queue through thread 3 (eg, parse of each processor class).
[0131] S405, the first computing node can select unprocessed risk instructions from the total user instruction queue through thread 2 (for example, ComputeNodeProcessorThread), and then process the risk instruction through thread 3 (for example, the process of each processor class), that is, calculate the user's capital adequacy ratio and determine whether the processing is successful.
[0132] S406: If the first computing node processes successfully, the computing result is inserted into a user result queue. For example, the user result queue may be CUSTOMER_VIEW_LOG_QUEUES.
[0133] S407, the first computing node may take out the computing result from the user result queue through thread 4 (eg, ComputeNodeLogThread), and if the computing result is a risk result, update the risk user table.
[0134] S408: If the first computing node fails to process the instruction successfully, thread 2 (eg, ComputeNodeProcessorThread) inserts the risk instruction into an abnormal user queue. For example, the abnormal user queue may be ERROR_CUS_SET.
[0135] Optionally, the first computing node takes out the risk instruction from the abnormal user queue through thread 5 (for example, ComputeNodeErrorCusThread) and processes the abnormal risk instruction.
[0136] As an optional embodiment, before the risk estimation system 100 is run, it is necessary to start the management node first, and then start the multiple computing nodes and the distribution server.
[0137] Exemplarily, the management node includes a message bus, which is similar to the MQ tree of a Map. When the computing nodes and distribution servers are started, they can first register the service through remote method invocation (RMI), and then save the detailed information of multiple computing nodes and distribution servers in the bus.
[0138] After the distribution server is started, the polling distribution process can be started. When the distribution process is initialized, a routing table (i.e., the above-mentioned routing information) can be generated according to the current number of computing nodes and the total number of users, and the routing table can be distributed to multiple computing nodes. It should be understood that the routing table includes the corresponding relationship between multiple computing nodes and multiple users. For example, the multiple computing nodes include computing node 1, computing node 2, and computing node 3, and the total number of users is 3000. The routing table generated by the distribution server can be that computing node 1 corresponds to 1000 users, computing node 2 corresponds to 500 users, and computing node 3 corresponds to 1000 users.
[0139] After receiving the routing table, the multiple computing nodes can be initialized according to the routing table, that is, query the funds and position information of the user that the computing node is responsible for processing, and load it into the memory.
[0140] After all computing nodes in the above distribution process have fed back the initialization completion information, risk instruction processing can be carried out.
[0141] It should be understood that the sequence numbers of the above processes do not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.
[0142] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.
[0143] Those skilled in the art can clearly understand that, for the convenience and brevity of description, the specific working processes of the systems, devices and units described above can refer to the corresponding processes in the aforementioned method embodiments and will not be repeated here.
[0144] In the several embodiments provided in the present application, it should be understood that the disclosed systems, devices and methods can be implemented in other ways. For example, the device embodiments described above are only schematic. For example, the division of units is only a logical function division. There may be other division methods in actual implementation. For example, multiple units or components can be combined or integrated into another system, or some features can be ignored or not executed. Another point is that the mutual coupling or direct coupling or communication connection shown or discussed can be through some interfaces, indirect coupling or communication connection of devices or units, which can be electrical, mechanical or other forms.
[0145] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.
[0146] In addition, each functional unit in each embodiment of the present application may be integrated into one processing unit, or each unit may exist physically separately, or two or more units may be integrated into one unit.
[0147] If the function is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the technical solution of the present application, 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, server, or network device, etc.) to perform all or part of the steps of the various embodiments of the present application. The aforementioned storage medium includes: U disk, mobile hard disk, read-only memory (ROM), random access memory (RAM), disk or optical disk, and other media that can store program codes.
[0148] The above are only specific implementations of the present application, but the protection scope of the present application is not limited thereto. Any technician familiar with the technical field can easily think of changes or substitutions within the technical scope disclosed in the present application, which should be included in the protection scope of the present application. Therefore, the protection scope of the present application should be based on the protection scope of the claims.
Claims
1. A risk calculation method, characterized in that: Applied to a system including a management node, a distribution server, and a plurality of computing nodes, the method includes: The management node obtains risk data generated when multiple users conduct foreign exchange transactions, generates multiple risk instructions according to the risk data of the multiple users, and stores the multiple risk instructions in a risk instruction queue; the distribution server obtains the risk instructions from the risk instruction queue, the multiple risk instructions respectively include identification information of the multiple users; and the multiple risk instructions respectively include data information required for calculating risk assessment parameters under corresponding risks; The distribution server receives the multiple risk instructions, and distributes the multiple risk instructions to all or part of the multiple computing nodes according to pre-generated routing information, wherein the routing information includes a correspondence between the multiple computing nodes and the identification information of the multiple users; All or part of the computing nodes receive multiple risk instructions, and according to the multiple risk instructions, calculate risk assessment parameters of multiple users in parallel, and the risk assessment parameters are used to evaluate the risk levels of the multiple users; Wherein, for any first computing node among all or part of the computing nodes, the first computing node receives a first risk instruction among the multiple risk instructions; the first risk instruction includes identification information of a first user among the multiple users; The first computing node determines, according to the identification information of the first user, whether the first risk instruction is a contract instruction or whether the first user has an instruction queue; If the first risk instruction is not a contract instruction and the first user already has an instruction queue, the first computing node inserts the first risk instruction into the instruction queue of the first user; The first computing node calculates the risk assessment parameter of the first user according to the first risk instruction using an algorithm corresponding to the type of the first risk instruction.
2. The method according to claim 1, characterized in that: Before the first computing node inserts the first risk instruction into the instruction queue of the first user, the method further includes: The first computing node creates a command queue for the first user.
3. The method according to claim 1, characterized in that The system also includes a backup distribution server; The method further comprises: The distribution server periodically sends first heartbeat information of the distribution server to the management node; The management node receives the first heartbeat information from the distribution server and starts a first timer; If the management node does not receive the second heartbeat information from the distribution server before the first timer times out, the management node determines that the distribution server fails; The management node switches the plurality of risk instructions from the distribution server to the backup distribution server.
4. The method according to claim 3, characterized in that The system also includes a centralized monitoring node; The method further comprises: The management node sends first alarm information to the centralized monitoring node, where the first alarm information is used to indicate that a failure occurs in the distribution server; The centralized monitoring node receives the first alarm information and displays a notification message to the operation and maintenance personnel, where the notification message is used to notify the operation and maintenance personnel to check the distribution server.
5. The method according to claim 1, characterized in that The system also includes a spare computing node; The method further comprises: A second computing node among the multiple computing nodes periodically sends third heartbeat information of the second computing node to the management node; The management node receives the third heartbeat information from the second computing node and starts a second timer; If the management node does not receive the fourth heartbeat information from the second computing node before the second timer times out, the management node determines that the second computing node fails; The management node notifies the distribution server to transfer the risk instruction sent to the second computing node to the backup computing node.
6. The method according to claim 5, characterized in that The system also includes a centralized monitoring node; The method further comprises: The management node sends second alarm information to the centralized monitoring node, where the second alarm information is used to indicate that a failure occurs in the second computing node; The centralized monitoring node receives the second alarm information and displays a notification message to the operation and maintenance personnel, where the notification message is used to notify the operation and maintenance personnel to check the second computing node.
7. The method according to claim 1, characterized in that The system also includes a standby management node, and the standby management node and the management node are automatically switched according to preset rules.
8. The method according to claim 1, characterized in that The type of the risk instruction includes at least one of the following: Funding, transaction, time, special, or system.
9. The method according to any one of claims 1 to 8, characterized in that The risk data includes at least one of the following: Opening, closing, depositing and withdrawing, manual liquidation, automatic liquidation, real-time quotes, time intervals, overnight interest rate spreads, or signing contracts.
10. The method according to claim 9, characterized in that The risk data corresponding to the risk instructions including opening, closing, manual forced liquidation or automatic forced liquidation are of the transaction type; The risk data including deposit and withdrawal corresponding to the risk instruction type is capital type; The risk instruction type corresponding to the risk data including real-time quotes is the quote type; The risk instruction type corresponding to the risk data including the time interval is the time type; The risk instructions corresponding to the risk data including overnight interest rate spread are of special type; The type of risk instructions corresponding to the contracted risk data is system class.
11. A risk calculation system, characterized in that: include: Management nodes, distribution servers, and multiple computing nodes; The management node is used to obtain risk data generated when multiple users conduct foreign exchange transactions, generate multiple risk instructions according to the risk data of the multiple users, and store the multiple risk instructions in a risk instruction queue, and the distribution server obtains the risk instructions from the risk instruction queue, wherein the multiple risk instructions respectively include identification information of the multiple users; and the multiple risk instructions respectively include data information required for calculating risk assessment parameters under corresponding risks; The distribution server is configured to receive the multiple risk instructions and distribute the multiple risk instructions to all or part of the multiple computing nodes according to pre-generated routing information, wherein the routing information includes a correspondence between the multiple computing nodes and the identification information of the multiple users; All or part of the plurality of computing nodes are used to receive the plurality of risk instructions, and calculate risk assessment parameters of the plurality of users in parallel according to the plurality of risk instructions, wherein the risk assessment parameters are used to evaluate the risk levels of the plurality of users; The first computing node among all or part of the computing nodes is used to: receive a first risk instruction among the multiple risk instructions; the first risk instruction includes identification information of a first user among the multiple users; Determining, according to the identification information of the first user, whether the first risk instruction is a contract signing instruction or whether the first user exists in an instruction queue; If the first risk instruction is not a contract instruction and the first user already has an instruction queue, the first computing node inserts the first risk instruction into the instruction queue of the first user; calculating, according to the first risk instruction, a risk assessment parameter of the first user using an algorithm corresponding to the type of the first risk instruction; The first risk instruction includes identification information of a first user among the multiple users.
12. The system according to claim 11, characterized in that The first computing node is further configured to: A new command queue for the first user is created.
13. The system according to claim 11, characterized in that The system also includes a backup distribution server; The distribution server is also used for: Periodically sending first heartbeat information of the distribution server to the management node; The management node is also used for: Receive first heartbeat information from the distribution server and start a first timer; If the second heartbeat information from the distribution server is not received before the first timer times out, it is determined that the distribution server fails; The plurality of risk instructions are switched from the distribution server to the backup distribution server.
14. The system according to claim 13, characterized in that The system also includes a centralized monitoring node; The management node is also used for: Sending first alarm information to the centralized monitoring node, wherein the first alarm information is used to indicate that a failure occurs in the distribution server; The centralized monitoring node is used for: The first alarm information is received, and a notification message is displayed to an operation and maintenance personnel, where the notification message is used to notify the operation and maintenance personnel to check the distribution server.
15. The system according to claim 11, characterized in that The system also includes a spare computing node; A second computing node among the plurality of computing nodes is used for: Periodically sending third heartbeat information of the second computing node to the management node; The management node is also used for: Receive third heartbeat information from the second computing node, and start a second timer; If the fourth heartbeat information from the second computing node is not received before the second timer times out, it is determined that the second computing node fails; The distribution server is notified to transfer the risk instruction sent to the second computing node to the standby computing node.
16. The system according to claim 15, characterized in that The system also includes a centralized monitoring node; The management node is used to: Sending second alarm information to the centralized monitoring node, where the second alarm information is used to indicate that a failure occurs in the second computing node; The centralized monitoring node is used for: The second alarm information is received, and a notification message is displayed to the operation and maintenance personnel, where the notification message is used to notify the operation and maintenance personnel to check the second computing node.
Citation Information
Patent Citations
Individual forward exchange transaction system
CN101587581A
High availability cluster computer system and fault treatment method thereof
CN102231681A
Method and system of real-time monitoring of transaction risk
CN105590216A
A systematic method for controlling and managing the spot transaction risk
CN109427011A
Data transmission method and apparatus
WO2015139633A1
Cited By
Foreign exchange transaction risk management method based on AI large model
CN120374266A
