A market information update method and device
By directly updating the market information using memory addresses in the market order book, the update delay problem caused by linked list traversal is solved, and more efficient market information update and parallel processing capabilities are achieved.
Patent Information
- Application Number
- CN202210743479.2
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2022-06-27
- Publication Date
- 2025-06-20
- Estimated Expiration
- 2042-06-27
AI Technical Summary
In the prior art, market information is maintained in the form of a linked list in the market order book, resulting in the need to traverse the linked list when updating the order information by order, which increases the update delay.
By obtaining order information per transaction from the securities trading system, determining the number according to the code of the transaction target, generating a memory address that records the transaction price, transaction direction and number, directly updating the value stored in the memory address to avoid traversing the linked list.
It reduces the delay in market information update, improves the efficiency of update operations, enhances parallel processing capabilities, and reduces operation complexity.
Smart Images

Figure CN115271941B_ABST
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of data processing, and particularly to a method and device for updating market quotation information. Background Art
[0002] Since users with high-frequency trading requirements hope that market quotation information can be updated in a timely manner, and then dynamically adjust their trading strategies according to the continuously updated market quotation information, the securities trading system provides users with order-by-order information. The user device locally maintains a quotation order book for storing market quotation information, so that the user device can update the quotation order book according to the order-by-order information, and further enables the market quotation information to be continuously updated.
[0003] In the prior art, for each stock, the market quotation information of the stock is maintained in the form of a linked list in the quotation order book. In this way, every time the user device receives the order-by-order information of the stock, it needs to traverse the market quotation information stored in the linked list to determine the position of the market quotation information to be updated in the linked list, and then update the market quotation information stored at the above position according to the order-by-order information. However, as the linked list lengthens, the time required to traverse the linked list continuously increases, resulting in a large delay in updating market quotation information. Summary of the Invention
[0004] The purpose of the embodiments of the present invention is to provide a method and device for updating market quotation information to reduce the delay when updating market quotation information. The specific technical solutions are as follows:
[0005] In a first aspect, the embodiments of the present invention provide a method for updating market quotation information, the method including:
[0006] Obtaining order-by-order information from a securities trading system;
[0007] Obtaining the transaction price, transaction direction, and code of the transaction target included in the order-by-order information;
[0008] According to the code of the transaction target, determining the number of the transaction target, and generating a memory address recording the transaction price, transaction direction, and number of the transaction target according to the preset number of bit positions and preset relative position relationships respectively corresponding to the transaction price, transaction direction, and number of the transaction target;
[0009] Judging whether a value is stored in the memory address;
[0010] If so, updating the value stored in the memory address based on the order type and the transaction quantity included in the order-by-order information;
[0011] If not, storing the transaction quantity included in the order-by-order information into the memory address.
[0012] In one embodiment of the present invention, updating the value stored in the memory address based on the order type and the transaction quantity included in the per - order information includes:
[0013] If the order type included in the per - order information is a consignment type, adding the transaction quantity to the value stored in the memory address;
[0014] If the order type included in the per - order information is a transaction type, subtracting the transaction quantity from the value stored in the memory address.
[0015] In one embodiment of the present invention, the method further includes:
[0016] For each trading target with market information stored in the market order book, in different trading directions, determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target, and outputting the target trading prices and the trading volume stored in the target address, where the target address is: the address recording the target trading price.
[0017] In one embodiment of the present invention, when the trading direction is the buy direction, determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target includes:
[0018] Obtaining the first highest trading price and the first lowest trading price of the trading target in the buy direction;
[0019] Determining a first memory address according to the first highest trading price, the number of the trading target, and the buy direction, and determining a second memory address according to the first lowest trading price, the number of the trading target, and the buy direction;
[0020] Starting from the first memory address, performing a first operation step by step with a preset step size and decreasing addresses until determining a preset number of target trading prices with the highest user attention or the address is less than the second memory address, where the first operation includes: when the trading quantity stored at the address is greater than 0, determining the trading price recorded at the address as the target trading price.
[0021] In one embodiment of the present invention, when the trading direction is the sell direction, determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target includes:
[0022] Obtaining the second highest trading price and the second lowest trading price of the trading target in the sell direction;
[0023] Determine a third memory address according to the second lowest transaction price, the number of the transaction target, and the sell direction, and determine a fourth memory address according to the second highest transaction price, the number of the transaction target, and the sell direction;
[0024] Starting from the third memory address, perform a second operation address by address in the manner of increasing the address according to a preset step size until a preset number of target transaction prices with the highest user attention are determined or the address is greater than the fourth memory address, where the second operation includes: when the transaction quantity stored at the address is greater than 0, determine the transaction price recorded at the address as the target transaction price.
[0025] In one embodiment of the present invention, after obtaining the per - order information from the securities trading system, it further includes:
[0026] Determine a third highest price and a third lowest price at which the transaction target corresponding to the per - order information conducts transactions in the transaction direction included in the per - order information from the highest transaction price and the lowest transaction price cached locally;
[0027] When the transaction price included in the per - order information is higher than the third highest price, update the third highest price to the transaction price; when the transaction price is lower than the third lowest price, update the third lowest price to the transaction price.
[0028] In one embodiment of the present invention, the number of preset bit positions corresponding to the transaction price is determined according to the maximum transaction price and price precision supported by the securities trading system;
[0029] The number of preset bit positions corresponding to the transaction direction is determined according to the number of transaction directions;
[0030] The number of preset bit positions corresponding to the number of the transaction target is determined according to the maximum number of transaction targets concerned by users.
[0031] In a second aspect, an embodiment of the present invention provides a market information update device, and the device includes:
[0032] A per - order information obtaining module, configured to obtain per - order information from a securities trading system;
[0033] An order information obtaining module, configured to obtain the transaction price, the transaction direction, and the code of the transaction target included in the per - order information;
[0034] A memory address generation module, configured to determine the number of the transaction target according to the code of the transaction target, and generate a memory address recording the transaction price, the transaction direction, and the number of the transaction target according to the preset bit numbers respectively corresponding to the transaction price, the transaction direction, and the number of the transaction target, and the preset relative position relationship.
[0035] A numerical value judgment module, configured to judge whether a numerical value is stored in the memory address. If so, trigger the numerical value update module; if not, trigger the transaction quantity storage module.
[0036] A numerical value update module, configured to update the numerical value stored in the memory address based on the order type and the transaction quantity included in the per-order information.
[0037] A transaction quantity storage module, configured to store the transaction quantity included in the per-order information into the memory address.
[0038] In an embodiment of the present invention, the numerical value update module is specifically configured to: if the order type included in the per-order information is a commission type, accumulate the transaction quantity to the numerical value stored in the memory address; if the order type included in the per-order information is a transaction type, subtract the transaction quantity from the numerical value stored in the memory address.
[0039] In an embodiment of the present invention, the device further includes:
[0040] A transaction information output module, configured to, for each transaction target with market information stored in the market order book, in different transaction directions, determine a preset number of target transaction prices with the highest user attention from the transaction prices recorded in the address storing the number of the transaction target, and output the target transaction prices and the trading volume stored in the target address, where the target address is the address recording the target transaction price.
[0041] In an embodiment of the present invention, when the transaction direction is the buy direction, the transaction information output module is specifically configured to: obtain the first highest transaction price and the first lowest transaction price of the transaction target in the buy direction; determine a first memory address according to the first highest transaction price, the number of the transaction target, and the buy direction, and determine a second memory address according to the first lowest transaction price, the number of the transaction target, and the buy direction; starting from the first memory address, perform a first operation step by step at a preset step length and with the address decreasing until a preset number of target transaction prices with the highest user attention are determined or the address is less than the second memory address, where the first operation includes: when the trading volume stored in the address is greater than 0, determining the transaction price recorded in the address as the target transaction price.
[0042] In one embodiment of the present invention, when the trading direction is the selling direction, the trading information output module is specifically configured to obtain the second highest trading price and the second lowest trading price of the trading target in the selling direction; determine a third memory address according to the second lowest trading price, the number of the trading target, and the selling direction, and determine a fourth memory address according to the second highest trading price, the number of the trading target, and the selling direction; starting from the third memory address, perform a second operation address by address in the manner of increasing the address according to a preset step size until a preset number of target trading prices with the highest user attention are determined or the address is greater than the fourth memory address, where the second operation includes: when the trading quantity stored at the address is greater than 0, determining the trading price recorded at the address as the target trading price.
[0043] In one embodiment of the present invention, after the per-order information obtaining module, the following is further included:
[0044] A price determination module, configured to determine a third highest price and a third lowest price for trading the trading target corresponding to the per-order information in the trading direction included in the per-order information from the highest trading price and the lowest trading price cached locally.
[0045] A price update module, configured to update the third highest price to the trading price when the trading price included in the per-order information is higher than the third highest price, and update the third lowest price to the trading price when the trading price is lower than the third lowest price.
[0046] In one embodiment of the present invention, the preset number of bit positions corresponding to the trading price is determined according to the maximum trading price and price precision supported by the securities trading system; the preset number of bit positions corresponding to the trading direction is determined according to the number of trading directions; the preset number of bit positions corresponding to the number of the trading target is determined according to the maximum number of trading targets concerned by users.
[0047] In a third aspect, an embodiment of the present invention provides an electronic device, including a processor, a communication interface, a memory, and a communication bus, where the processor, the communication interface, and the memory complete mutual communication through the communication bus;
[0048] The memory is used to store a computer program;
[0049] The processor, when executing the program stored in the memory, implements the steps of the market information update method described in the first aspect above.
[0050] Fourthly, an embodiment of the present invention provides a computer-readable storage medium, in which a computer program is stored, and when the computer program is executed by a processor, the steps of the market information update method described in the first aspect above are implemented.
[0051] Fifthly, an embodiment of the present invention provides a computer program product containing instructions, which when running on a computer, causes the computer to execute the steps of the market information update method described in the first aspect above.
[0052] As can be seen from the above, when the solution provided by the embodiment of the present invention is applied to update the market, after obtaining the transaction price, transaction direction, and the code of the trading target included in the trade-by-trade order information from the securities trading system, the number of the trading target is determined according to the code of the trading target. Then, according to the preset number of bit positions and the preset relative position relationship corresponding to the transaction price, transaction direction, and the number of the trading target respectively, a memory address recording the transaction price, transaction direction, and the number of the trading target is generated. In this way, the position of the market information to be updated can be located according to the generated memory address. Therefore, the value stored in the above memory address can be directly updated by using the transaction quantity included in the trade-by-trade order information, thus realizing the update of the market order book. Compared with maintaining the market information of the trading target in the form of a linked list in the market order book, there is no need to traverse the market information stored in the linked list to determine the position of the market information to be updated in the linked list every time the trade-by-trade order information of this trading target is received, saving the time required for traversing the linked list when updating the market information, reducing the operation complexity when updating the market information, and further reducing the delay when updating the market information.
[0053] In addition, compared with maintaining the market information of the trading target in the form of a linked list in the market order book, in the solution provided by the embodiment of the present invention, the storage positions of each piece of market information are determined by the above memory address, and there is no link relationship between the memory addresses, which are independent of each other. Therefore, when processing the trade-by-trade order information of this trading target received, there is no need to wait for the previous trade-by-trade order information to be processed. That is, the update of the market information based on each trade-by-trade order information does not affect each other, improving the parallel processing ability when updating the market information and further reducing the delay when updating the market information.
[0054] Of course, it is not necessary for any product or method implementing the present invention to achieve all the above advantages simultaneously. BRIEF DESCRIPTION OF THE DRAWINGS
[0055] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the following will briefly introduce the accompanying drawings required for the description of the embodiments or the prior art. Obviously, the accompanying drawings in the following description are only some embodiments of the present invention, and those of ordinary skill in the art can also obtain other embodiments based on these drawings.
[0056] Figure 1 It is a schematic flowchart of a market information update method provided by an embodiment of the present invention;
[0057] Figure 2 It is a schematic flowchart of the first market information output method provided by an embodiment of the present invention;
[0058] Figure 3 It is a schematic diagram of the first target transaction price determination process provided by an embodiment of the present invention;
[0059] Figure 4 It is a schematic flowchart of the second market information output method provided by an embodiment of the present invention;
[0060] Figure 5 It is a schematic diagram of the second target transaction price determination process provided by an embodiment of the present invention;
[0061] Figure 6 It is a schematic diagram of a price level extraction process provided by an embodiment of the present invention;
[0062] Figure 7 It is a schematic structural diagram of a market information update device provided by an embodiment of the present invention;
[0063] Figure 8 It is a schematic structural diagram of the first market information output device provided by an embodiment of the present invention;
[0064] Figure 9 It is a schematic structural diagram of the second market information output device provided by an embodiment of the present invention;
[0065] Figure 10 It is a schematic structural diagram of an electronic device provided by an embodiment of the present invention. Detailed implementation manners
[0066] The following will clearly and completely describe the technical solutions in the embodiments of the present invention in conjunction with the accompanying drawings in the embodiments of the present invention. Obviously, the described embodiments are only some embodiments of the present invention, rather than all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those of ordinary skill in the art based on this application belong to the scope of protection of the present invention.
[0067] First, the application scenarios of the solutions provided by the embodiments of the present invention will be described.
[0068] The solution provided by the embodiments of the present invention can be applied to the scenario where an electronic device locally maintains a market order book for storing market quotation information.
[0069] In the prior art, for each trading target, the market quotation information of the trading target is maintained in the form of a linked list in the market order book. In this case, each time the per-trade order information of the trading target is received, it is necessary to traverse the market quotation information stored in the linked list, determine the position of the market quotation information to be updated in the linked list, and then update the market quotation information stored at the above position according to the per-trade order information. The following is an illustration with a specific example:
[0070] Referring to Table 1 below, it shows a schematic diagram of storing market quotation information in the form of a linked list.
[0071] Table 1
[0072] Memory Address Transaction Price Transaction Quantity Pointer Address 0x0 310 200 0x1 0x1 300 250 0x4 0x2 315 100 0x0 0x3 280 10 0x4 290 20 0x3
[0073] The first column in Table 1 represents the memory address storing the trading price and trading quantity of the trading target, the second and third columns respectively represent the trading price and trading quantity of the trading target, and the fourth column represents the next memory address pointed to by the memory address storing the trading price and trading quantity. For ease of description, hereinafter, a trading price of a trading target is referred to as a price level of the trading target, and a trading price of a trading target and the trading quantity corresponding to the trading price are referred to as a price level information of the trading target.
[0074] It can be seen that the memory address of the price level information of price level 315 points to the memory address of the price level information of price level 310, the memory address of the price level information of price level 310 points to the memory address of the price level information of price level 300, and so on. In this way, by using the method of the previous memory address pointing to the next address, the storage of price level information is sorted according to the size of the price levels.
[0075] Then, if the per-trade order information with a price level of 295 of the trading target is received, the user device needs to traverse the entire above-linked list to find the position where the price level information of price level 295 should be stored based on each price level in Table 1, and then store the price level information of price level 295 at the above position.
[0076] It can be seen that the user device needs to traverse the entire linked list to update the price level information. The time consumed for traversing the linked list is relatively long, and as the linked list continues to grow, the time required for traversing the linked list continuously increases, which easily leads to a large delay in updating the market quotation information.
[0077] In addition, for each piecemeal order information received, the user device needs to wait until the previous piecemeal order information is processed and stored in the linked list in sequence before it can process the next piecemeal order information. This causes the processing process of the piecemeal order information to be blocked, further increasing the delay when updating market information.
[0078] In view of the above situation, an embodiment of the present invention provides a method for updating market information to reduce the delay when updating market information.
[0079] The following details the method for updating market information provided by the embodiment of the present invention.
[0080] Participate Figure 1 , Figure 1 is a method for updating market information provided by an embodiment of the present invention. The above method includes the following steps S101 - step S106.
[0081] Step S101: Obtain piecemeal order information from the securities trading system.
[0082] The securities trading system can be the securities trading systems of various stock exchanges, and the above stock exchanges can be the Shanghai Stock Exchange, the Shenzhen Stock Exchange, etc.
[0083] The above piecemeal order information is the piecemeal order information of the trading targets concerned by the user. The piecemeal order information includes information such as the code of the trading target, the trading price, and the trading direction.
[0084] Specifically, the user can pre - determine several trading targets of their own concern. In this way, according to the code of the trading target concerned by the user, the order information with the code as the above code can be filtered out from the order information sent by the securities trading system as the above piecemeal order information.
[0085] Step S102: Obtain the trading price, trading direction, and the code of the trading target included in the piecemeal order information.
[0086] Step S103: According to the code of the trading target, determine the number of the trading target. Generate a memory address recording the trading price, trading direction, and the number of the trading target according to the preset number of bit positions and the preset relative position relationship corresponding to the trading price, trading direction, and the number of the trading target respectively.
[0087] The above code of the trading target is the code provided by the stock exchange for distinguishing trading targets. Since there are a large number of trading targets participating in transactions in the stock exchange, the number of digits of the above code is relatively long. While users generally only concern about several trading targets, for the convenience of maintenance, the number of the trading target can be determined according to the above code.
[0088] Specifically, the number of the trading target can be determined according to the corresponding relationship between the code of the preset trading target and the number of the trading target.
[0089] For example, the number of the trading target corresponding to the trading target with the code 600519 is 1, and the number of the trading target corresponding to the trading target with the code 300168 is 2, etc.
[0090] Next, the determination method of the preset number of bit positions corresponding to the above various types of information will be described.
[0091] Specifically, the preset number of bit positions corresponding to the above trading price is determined according to the maximum trading price supported by the securities trading system and the price precision; the preset number of bit positions corresponding to the above trading direction is determined according to the number of the above trading directions; the preset number of bit positions corresponding to the number of the trading target is determined according to the maximum number of trading targets concerned by the user.
[0092] For example, the maximum trading price supported by the securities trading system is 262.144. It can be seen that the price precision of the maximum trading price is 0.001. Since 2^18 = 262144, so, under the condition that each trading price within the range of the above maximum trading price can be recorded, the preset number of bit positions corresponding to the trading price can be 18; another example, the number of trading directions can be two, namely the buying direction and the selling direction, then the preset number of bit positions corresponding to the trading direction can be 1, and the 0 or 1 of this bit position represents the buying direction and the selling direction; similarly, if the maximum number of trading targets concerned by the user is 8, since 2^3 = 8, then the preset number of bit positions corresponding to the number of the trading target can be 3.
[0093] In this way, according to the information characteristics of information such as the trading price, the trading direction, and the number of the trading target, a suitable preset number of bit positions can be determined for the above information, so that the preset number of bit positions can accurately represent the above information.
[0094] Next, the preset relative position relationship corresponding to the above various types of information will be described.
[0095] Specifically, the preset relative position relationship corresponding to the above various types of information can be any relationship. For example, the relative position relationship where the trading price is first, the trading direction is second, and the number of the trading target is last. Of course, it can also be the relative position relationship where the number of the trading target is first, the trading direction is second, and the trading price is last, etc.
[0096] After generating the memory address according to the preset number of bit positions and the preset relative position relationship corresponding to the above various types of information, different bit positions of the above memory address respectively map the above trading price, trading direction, and trading target.
[0097] Taking the maximum transaction price of 262.144, the transaction directions of buying and selling, and the maximum number of trading targets of interest to the user being 8 as examples, the form of the memory address generated according to the corresponding preset number of bit positions and the preset relative position relationship can be as shown in Table 2 below.
[0098] Table 2
[0099] Memory Address Mapped Information [17:0] Transaction Price
[18] Transaction Direction [21:19] Transaction Target Number
[0100] The first column in Table 2 represents each bit position of the memory address, and the second column represents the information mapped by the bit positions of the memory address. It can be seen that the 18 bit positions of [17:0] in the memory address are used to map any transaction price within 262.144, the bit position of
[18] is used to map 2 transaction directions, and the bit positions of [21:19] are used to map the numbers of 8 trading targets. Thus, a one-to-one mapping between the transaction price and the memory address is achieved, and the sorted storage of the transaction price is realized by using the internal order of the memory address.
[0101] Of course, the form of the memory address generated according to the above preset number of bit positions and the preset relative position relationship is only an example, and the form of the above memory address can be determined according to the actual situation. For example, if the electronic device is byte-addressable and each byte read from the address is 8 bytes each time, then in order to facilitate the electronic device to read the memory address, the low three bits of the memory address can be made 0, as shown in Table 3 below:
[0102] Table 3
[0103] Memory Address Mapped Information [2:0] 0 [20:3] Transaction Price
[21] Transaction Direction [24:22] Transaction Target Number
[0104] It can be seen that 3 bit positions of [2:0] that are always 0 are added to the memory address shown in Table 3, which can facilitate the electronic device to read the memory address.
[0105] It should be noted that the above memory address can be the memory address in any memory with a relatively fast access rate. For example, the above memory address can be the address of RAM (Random Access Memory), or the address in DDR (Double Data Rate SDRAM).
[0106] Step S104: Determine whether the memory address stores a value. If yes, execute Step S105; if no, execute Step S106.
[0107] Step S105: Update the value stored in the memory address based on the order type and transaction quantity included in the per-order information.
[0108] If the memory address already stores a value, it means that the electronic device has already received the transaction target, transaction price, and transaction direction that are the same as those included in the above-mentioned per-order information. That is, the value stored in the memory address is the transaction quantity of the transaction target included in the previous per-order information. Therefore, since the transaction target included in the current per-order information is the same as the previous transaction target, it is necessary to update the value stored in the memory address based on the order type and transaction quantity included in the per-order information on the basis of the above-mentioned stored value.
[0109] Specifically, if the order type included in the per-order information is the entrustment type, the transaction quantity is added to the value stored in the memory address; if the order type included in the per-order information is the transaction type, the transaction quantity is subtracted from the value stored in the memory address.
[0110] Among them, if the order type included in the per-order information is the entrustment type, the transaction quantity included in the per-order information is the entrustment quantity, indicating that there is a new entrustment for the transaction target. Therefore, it is necessary to add the new entrustment quantity to the value stored in the above-mentioned memory address as the transaction quantity of the transaction target updated based on the per-order information; if the order type included in the per-order information is the transaction type, the transaction quantity included in the per-order information is the transaction quantity, indicating the quantity of the transaction that has been completed for the transaction target. It is necessary to subtract the quantity of the completed transaction from the value stored in the above-mentioned memory address as the transaction quantity of the transaction target updated based on the per-order information. In this way, the transaction quantity of the transaction target stored in the local market order book can be accurately updated based on different order types.
[0111] Step S106: Store the transaction quantity included in the per-order information into the memory address.
[0112] If there is no value stored in the memory address, it means that the electronic device receives for the first time the per-order information including the transaction target, transaction price, and transaction direction that are the same as the above-mentioned transaction target, transaction price, and transaction direction. Then, the transaction quantity included in the per-order information can be directly stored into the memory address.
[0113] As can be seen from the above, when updating the market quotation using the solution provided by the embodiments of the present invention, after obtaining the transaction price, transaction direction, and the code of the trading target included in the per-order information from the securities trading system, the number of the trading target is determined according to the code of the trading target. Then, based on the preset number of bit positions and the preset relative position relationship corresponding to the transaction price, transaction direction, and the number of the trading target respectively, a memory address recording the transaction price, transaction direction, and the number of the trading target is generated. In this way, the position of the market quotation information to be updated can be located according to the generated memory address. Therefore, the value stored in the above memory address can be directly updated using the transaction quantity included in the per-order information, thus realizing the update of the market order book. Compared with maintaining the market quotation information of the trading target in the form of a linked list in the market order book, there is no need to traverse the market quotation information stored in the linked list to determine the position of the market quotation information to be updated in the linked list every time the per-order information of the trading target is received, saving the time required for traversing the linked list when updating the market quotation information, reducing the operation complexity when updating the market quotation information, and further reducing the latency when updating the market quotation information.
[0114] In addition, compared with maintaining the market quotation information of the trading target in the form of a linked list in the market order book, in the solution provided by the embodiments of the present invention, the storage positions of each piece of market quotation information are determined by the above memory addresses, and there is no link relationship between the memory addresses, which are independent of each other. Therefore, when processing the per-order information of the trading target received, there is no need to wait for the previous per-order information processing to end. That is, the update of the market quotation information based on each per-order information does not affect each other, improving the parallel processing ability when updating the market quotation information and further reducing the latency when updating the market quotation information.
[0115] Moreover, since the solution provided by the embodiments of the present invention can update the market quotation information in parallel for each per-order information, that is, supports pipeline processing, it is more suitable to implement the solution provided by the embodiments of the present invention in a hardware manner. For example, the above hardware can be a CPU, an FPGA (Field Programmable Gate Array), a DSP (Digital Signal Processing) chip, or other hardware with data processing capabilities.
[0116] In one embodiment of the present invention, on the basis of Figure 1 the embodiment shown, a trading snapshot can also be synthesized locally based on the market quotation information stored in the market order book, so as to facilitate the user to view and refer to the above trading snapshot. The above trading snapshot can be an incremental trading snapshot or a full-volume trading snapshot.
[0117] In one embodiment of the present invention, on the basis of Figure 1Based on the illustrated embodiments, for each trading target with market information stored in the market order book, it is also possible to determine a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target in different trading directions, and output the target trading prices and the trading volumes stored in the target address.
[0118] Among them, the target address is: the address recording the target trading price.
[0119] The above-mentioned target trading prices and the trading volumes stored in the target address are the aforementioned price level information. That is, after maintaining the market order book locally based on the per-order information, for each trading target with market information stored in the market order book, it is also possible to output a preset number of price level information with the highest user attention in different trading directions for the user's reference.
[0120] The above-mentioned preset number can be determined according to the user's needs. For example, the above-mentioned preset number can be 5, 10, etc.
[0121] Referring to Table 4 and Table 5 below, they respectively show the forms of the price level information output for trading target S in the buy direction and the sell direction.
[0122] Table 4
[0123]
[0124] Table 5
[0125]
[0126]
[0127] As can be seen from Table 4 and Table 5, by respectively outputting the price level information of each trading target with market information stored in the market order book in the buy direction and the sell direction, it can be directly provided for the user's reference.
[0128] Specifically, the following method can be used to determine a preset number of target trading prices with the highest user attention.
[0129] In one implementation, for each trading target with market information stored in the market order book, when the trading direction is the buy direction, a preset number of target trading prices with the highest trading prices of the trading target can be obtained. For the specific implementation details, please refer to Figure 2 the illustrated embodiments, which will not be elaborated here for the time being.
[0130] In another implementation, for each trading target with market information stored in the market order book, when the trading direction is the sell direction, a preset number of target trading prices with the lowest trading prices of the trading target can be obtained. For the specific implementation details, please refer toFigure 3 The embodiments shown are not described in detail here for the time being.
[0131] For each trading target with market information stored in the market order book, in different trading directions, from the trading prices recorded at the address storing the number of the trading target, determine a preset number of target trading prices with the highest user attention, and output the target trading prices and the trading volumes stored in the target addresses. That is, in different trading directions, the gear information with high user attention is output. Such output gear information can be intuitively provided for users to refer to, facilitating users to adjust their trading strategies according to the above gear information.
[0132] As can be seen from the foregoing embodiments, for each trading target with market information stored in the market order book, in different trading directions, different methods can be used to determine a preset number of target trading prices with the highest user attention. The following will be described through Figure 2 and Figure 3 the embodiments shown respectively illustrate different determination methods for a preset number of target trading prices with the highest user attention.
[0133] In Figure 1 the basis of the embodiments shown, for each trading target with market information stored in the market order book, when the trading direction is the buying direction, a preset number of target trading prices with the highest trading prices of the trading target can be obtained, and then output the preset number of target trading prices for users to view. In view of the above situation, the embodiments of the present invention provide a first market information output method.
[0134] Refer to Figure 2 , Figure 2 which is the first market information output method provided by the embodiments of the present invention. The above method includes the following steps S201 - step S204.
[0135] Step S201: For each trading target with market information stored in the market order book, obtain the first highest trading price and the first lowest trading price of the trading target in the buying direction.
[0136] Among them, the above first highest trading price and first lowest trading price can be cached locally and updated in real time. The specific implementation details will be described in subsequent embodiments and are not described in detail here for the time being.
[0137] Step S202: Determine the first memory address according to the first highest trading price, the number of the trading target, and the buying direction, and determine the second memory address according to the first lowest trading price, the number of the trading target, and the buying direction.
[0138] Specifically, the above-mentioned first highest transaction price, the number of the transaction target, and the buy direction can be used to generate a first memory address according to the preset number of bit positions and the preset positional relationship. Similarly, a second memory address can be obtained based on the first lowest transaction price, the number of the transaction target, and the buy direction.
[0139] Step S203: Starting from the first memory address, perform a first operation address by address in the manner of decreasing addresses according to a preset step size until a preset number of target transaction prices with the highest user attention are determined or the address is less than the second memory address.
[0140] Among them, the first operation includes: when the transaction quantity stored at the address is greater than 0, determining the transaction price recorded at the address as the target transaction price.
[0141] The above-mentioned preset step size can be determined according to the position of the bit representing the transaction price in the memory address.
[0142] For example, if the form of the memory address is as shown in Table 2 above, and the [0-17] bits of the memory address are used to map the memory address, then in order to ensure that the transaction price can be decreased by decreasing the address, the preset step size can be 1.
[0143] Another example, if the form of the memory address is as shown in Table 3 above, and the [3-20] bits of the memory address are used to map the memory address, then in order to ensure that the transaction price can be decreased by decreasing the address, the preset step size can be 8.
[0144] The following explains the first operation.
[0145] Since the transaction price is recorded in the memory address, and the first memory address is the memory address corresponding to the first highest transaction price, decreasing according to the preset step size on the basis of the first memory address, the obtained address after decreasing is also the address corresponding to the transaction price obtained by decreasing on the basis of the first highest transaction price.
[0146] Among them, if the transaction quantity stored at the obtained address after decreasing is greater than 0, it means that the address stores a transaction quantity, and the gear information corresponding to the transaction price recorded at the address needs to be output, so the above-mentioned transaction price is determined as the target transaction price; on the contrary, if the transaction quantity stored at the obtained address after decreasing is equal to 0 or is empty, it means that the address does not store a transaction quantity, and the gear information corresponding to the transaction price recorded at the address does not need to be output, so the transaction price is not determined as the target transaction price.
[0147] Among them, if it is determined that the preset number of target transaction prices with the highest user attention is obtained, it means that the required target transaction prices have been determined, so the first operation is stopped; if the obtained address after decrement is less than the second memory address, it means that all addresses storing the transaction quantity of the transaction target have been executed the first operation, so the first operation is stopped.
[0148] Taking the form of memory addresses as shown in Table 2 above as an example, in combination with Figure 3 the process of determining the target transaction price according to the solution provided in this embodiment will be described.
[0149] Refer to Figure 3 , which is a schematic diagram of the first target transaction price determination process provided by the embodiment of the present invention.
[0150] From Figure 3 it can be seen that starting from the first memory address, decrement by 1 as the step size, and for each obtained address after decrement, determine whether the transaction price stored in the address is greater than 0. Determine the transaction price recorded in the memory address where the stored transaction price is greater than 0 as the target transaction price, for example: the first memory address, the first memory address - 1, etc.; skip the memory address where the stored transaction price is not greater than 0 and do not determine the transaction price stored in it as the target transaction price, for example, the first memory address - 3.
[0151] Of course, it can be seen that the obtained address after decrement is within the range of the first memory address and the second memory address.
[0152] Step S204: Output the target transaction price and the transaction quantity stored in the target address.
[0153] Among them, the target address is: the address recording the target transaction price.
[0154] That is, the gear information with high user attention is output.
[0155] When the trading direction is buying, since the transaction price is recorded in the memory address and the first memory address is the memory address corresponding to the first highest transaction price, so on the basis of the first memory address, decrement according to the preset step size. The obtained address is the address corresponding to the transaction price decremented on the basis of the first highest transaction price. Therefore, after performing the first operation on the obtained address after decrement, the preset number of target transaction prices with the highest transaction price can be accurately determined in the order from high to low of the transaction price.
[0156] In Figure 1Based on the illustrated embodiments, for each trading target with market information stored in the market order book, when the trading direction is the selling direction, a preset number of target trading prices with the lowest trading prices of the trading target can be obtained, and then the preset number of target trading prices can be output for the user to view. In view of the above situation, the embodiments of the present invention provide a second method for outputting market information.
[0157] See Figure 4 , Figure 4 which is the second method for outputting market information provided by the embodiments of the present invention. The above method includes the following steps S401 - step S404.
[0158] Step S401: For each trading target with market information stored in the market order book, obtain the second highest trading price and the second lowest trading price of the trading target in the selling direction.
[0159] Among them, the second highest trading price and the second lowest trading price can be cached locally and updated in real time. The specific implementation details are described in the subsequent embodiments and will not be elaborated here for the time being.
[0160] Step S402: Determine the third memory address according to the second lowest trading price, the number of the trading target, and the selling direction, and determine the fourth memory address according to the second highest trading price, the number of the trading target, and the selling direction.
[0161] Specifically, the second highest trading price, the number of the trading target, and the selling direction can be respectively used to generate the third memory address according to the preset number of bit positions and the preset positional relationship. Similarly, the fourth memory address can be obtained according to the second lowest trading price, the number of the trading target, and the selling direction.
[0162] Step S403: Starting from the third memory address, perform the second operation step by step with an increasing address according to the preset step size until the preset number of target trading prices with the highest user attention is determined or the address is greater than the fourth memory address.
[0163] Among them, the second operation includes: when the trading quantity stored at the address is greater than 0, determine the trading price recorded at the address as the target trading price.
[0164] The determination method of the above preset step size has been described in step S204 of the foregoing Figure 2 illustrated embodiments and will not be elaborated here again.
[0165] The following describes the second operation.
[0166] Since the trading price is recorded in the memory address and the third memory address is the memory address corresponding to the second highest trading price, incrementing from the second memory address by a preset step size, the obtained address is the address corresponding to the trading price obtained by incrementing from the second highest trading price.
[0167] Among them, if the trading quantity stored at the obtained address after incrementing is greater than 0, it means that there is a trading quantity stored at this address, and the price range information corresponding to the trading price recorded at this address needs to be output. Therefore, the above trading price is determined as the target trading price; conversely, if the trading quantity stored at the obtained address after incrementing is empty or equal to 0, it means that there is no trading quantity stored at this address, and the price range information corresponding to the trading price recorded at this address does not need to be output. Therefore, this trading price is not determined as the target trading price.
[0168] Among them, if the preset number of target trading prices with the highest user attention is determined, it means that the required target trading prices have been determined. Therefore, the second operation is stopped; if the obtained address after incrementing is less than the second memory address, it means that all addresses storing the trading quantity of this trading target have been executed the first operation. Therefore, the second operation is stopped.
[0169] Next, taking the form of memory addresses as shown in Table 2 above as an example, combined with Figure 5 explain the process of determining the target trading price according to the solution provided in this embodiment.
[0170] See Figure 5 , which is a schematic diagram of the second process for determining the target trading price provided by the embodiment of the present invention.
[0171] From Figure 5 it can be seen that starting from the third memory address, increment by 1 as the step size. For each obtained address after incrementing, determine whether the trading price stored at the address is greater than 0. Determine the trading price recorded at the memory address where the stored trading price is greater than 0 as the target trading price, for example: the third memory address, the third memory address + 1, etc.; skip the memory address where the stored trading price is not greater than 0, and do not determine the trading price stored in it as the target trading price, for example, the third memory address + 3.
[0172] Of course, it can be seen that the obtained address is within the range of the third memory address and the fourth memory address.
[0173] Step S404: Output the target trading price and the trading volume stored at the target address.
[0174] Among them, the target address is: the address recording the target trading price.
[0175] When the trading direction is selling, since the trading price is recorded in the memory address and the third memory address is the memory address corresponding to the second highest trading price, incrementing based on the third memory address by a preset step size, the obtained address is the address corresponding to the trading price incremented based on the second highest trading price. Therefore, after performing the second operation on the incremented address, the preset number of target trading prices with the highest trading prices can be accurately determined in descending order of trading price.
[0176] The following describes the method for real-time updating the first highest trading price and the first lowest trading price, as well as real-time updating the second highest trading price and the second lowest trading price.
[0177] In one implementation, the third highest price and the third lowest price at which the trading target corresponding to the per-order information trades in the trading direction included in the per-order information can be determined from the highest trading price and the lowest trading price cached locally; when the trading price included in the per-order information is higher than the third highest price, update the third highest price to the trading price, and when the trading price is lower than the third lowest price, update the third lowest price to the trading price.
[0178] Among them, the highest trading price and the lowest trading price cached locally include the above-mentioned first highest trading price and the first lowest trading price, as well as the second highest trading price and the second lowest trading price.
[0179] Specifically, for the per-order information, first determine the third highest price and the third lowest price at which the trading target corresponding to the per-order information trades in the trading direction included in the per-order information.
[0180] For example, if the trading target corresponding to the per-order information is in the buying direction, then the third highest price and the third lowest price in the buying trading direction are the aforementioned first highest trading price and the first lowest trading price respectively; if the trading target corresponding to the per-order information is in the selling direction, then the third highest price and the third lowest price in the selling trading direction are the aforementioned second highest trading price and the second lowest trading price respectively.
[0181] Then, determine whether the trading price included in the order information is higher than the third highest price. If so, it means that the trading price included in the per-order information is already greater than the highest price in the trading direction included in the per-order information. Therefore, the third highest price can be updated to the above-mentioned trading price; and determine whether the trading price included in the order information is lower than the third lowest price. If so, it means that the trading price included in the per-order information is already less than the lowest price in the trading direction included in the per-order information. Therefore, the third lowest price can be updated to the trading price.
[0182] In this way, the highest transaction price and the lowest transaction price in the local cache can be continuously updated according to the transaction price included in the information of each order, so that the target transaction price can be accurately determined based on the highest transaction price and the lowest transaction price subsequently.
[0183] The following is shown in the form of a memory address as described in Table 2 above, in combination with Figure 6 , a gear information output process provided by an embodiment of the present invention will be described.
[0184] Refer to Figure 6 , which is a schematic diagram of a gear information output process provided by an embodiment of the present invention.
[0185] In the figure, taking the buy direction as an example, the output process of the gear information in the buy direction is shown. The following will be specifically described in combination with Step S601 - Step S609 Figure 6 the gear information output process shown.
[0186] Step S601: The timer triggers a gear information output instruction.
[0187] The frequency of the above-mentioned timer triggering the gear information output instruction can be determined according to the user's needs. For example, it can trigger the gear information output instruction once every 200 ms, etc.
[0188] Step S602: Determine the memory address of the first buy gear.
[0189] The first buy gear corresponds to the aforementioned first highest price. Since the first buy gear will be updated locally in real time, the above-mentioned first buy gear can be directly read, and the memory address of the first buy gear can be determined according to the first buy gear.
[0190] Step S603: Read the entrusted quantity stored in the memory address.
[0191] Step S604: Temporarily store the entrusted quantity read from the transaction price recorded in the memory address.
[0192] Step S605: Subtract 1 from the memory address and read the entrusted quantity stored in the new memory address.
[0193] Step S606: Determine whether the read entrusted quantity is greater than 0. If it is, execute Step S607. If not, execute Step S605.
[0194] If the entrusted quantity read from the obtained memory address after subtracting 1 from the memory address is equal to 0 or is empty, it means that there is no entrusted quantity stored in this memory address. Therefore, skip this address and continue to execute Step S605, subtract 1 from the memory address, and read the entrusted quantity stored in the new memory address.
[0195] Step S607: Temporarily store the transaction price recorded in the memory address and the read order quantity.
[0196] The above-mentioned order quantity corresponds to the aforementioned transaction quantity.
[0197] If the order quantity read from the obtained memory address after subtracting 1 from the memory address is greater than 0, it indicates that there is an order quantity stored at this memory address. Then, the transaction price recorded in this memory address and the read order quantity can be temporarily stored, that is, the level information of the level corresponding to this address is temporarily stored.
[0198] Step S608: Determine whether the number of temporarily stored transaction prices is greater than 5 or whether the memory address is less than the lowest-level address. If so, execute Step S609; if not, execute Step S605.
[0199] The above-mentioned lowest-level address corresponds to the aforementioned first lowest transaction price.
[0200] Specifically, if the number of temporarily stored transaction prices is greater than 5, it means that the level information of the required quantity has been read. Therefore, Step S609 can be executed to output the temporarily stored level information; if the obtained memory address after decrementing is less than the lowest-level address, it means that all levels of this transaction target have been traversed. Therefore, the process needs to end and the temporarily stored level information is output.
[0201] Step S609: Output all temporarily stored transaction prices and the transaction quantities corresponding to the transaction prices.
[0202] That is, all temporarily stored level information is output.
[0203] The output process of the level information in the sell direction can be obtained based on the above process and will not be elaborated here.
[0204] As can be seen from the above, when updating the market quotation using the solution provided by the embodiments of the present invention, after obtaining the transaction price, transaction direction, and the code of the trading target included in the order-by-order information from the securities trading system, the number of the trading target is determined according to the code of the trading target. Then, according to the preset number of bit positions and the preset relative position relationship corresponding to the transaction price, transaction direction, and the number of the trading target respectively, a memory address recording the transaction price, transaction direction, and the number of the trading target is generated. In this way, the position of the market quotation information to be updated can be located according to the generated memory address. Therefore, the value stored in the above memory address can be directly updated using the transaction quantity included in the order-by-order information, thus realizing the update of the market quotation order book. Compared with maintaining the market quotation information of the trading target in the form of a linked list in the market quotation order book, there is no need to traverse the market quotation information stored in the linked list to determine the position of the market quotation information to be updated in the linked list every time the order-by-order information of the trading target is received, saving the time required for traversing the linked list when updating the market quotation information, reducing the operation complexity when updating the market quotation information, and further reducing the latency when updating the market quotation information.
[0205] In addition, compared with maintaining the market quotation information of the trading target in the form of a linked list in the market quotation order book, in the solution provided by the embodiments of the present invention, the storage positions of each piece of market quotation information are determined by the above memory addresses, and there is no link relationship between the memory addresses, and they are independent of each other. Therefore, when processing the order-by-order information of the trading target received, there is no need to wait for the previous order-by-order information to be processed. That is, the update of the market quotation information based on each order-by-order information does not affect each other, improving the parallel processing ability when updating the market quotation information and further reducing the latency when updating the market quotation information.
[0206] Corresponding to the above market quotation information update method, the present invention also provides a market quotation information update device.
[0207] See Figure 7 , Figure 7 which is a market quotation information update device provided by the embodiments of the present invention. The above device includes the following modules 701 - module 706.
[0208] An order-by-order information acquisition module 701, configured to acquire order-by-order information from a securities trading system;
[0209] A trading information acquisition module 702, configured to acquire the transaction price, transaction direction, and the code of the trading target included in the order-by-order information;
[0210] A memory address generation module 703 is configured to determine the number of the transaction target according to the code of the transaction target, and generate a memory address recording the transaction price, the transaction direction, and the number of the transaction target according to the preset number of bit positions and the preset relative position relationship corresponding to the transaction price, the transaction direction, and the number of the transaction target respectively;
[0211] A numerical value judgment module 704 is configured to judge whether a numerical value is stored in the memory address. If so, trigger the numerical value update module; if not, trigger the transaction quantity storage module;
[0212] A numerical value update module 705 is configured to update the numerical value stored in the memory address based on the order type and the transaction quantity included in the per-order information;
[0213] A transaction quantity storage module 706 is configured to store the transaction quantity included in the per-order information into the memory address.
[0214] As can be seen from the above, when applying the solution provided by the embodiment of the present invention to update the market quotation, after obtaining the transaction price, the transaction direction, and the code of the transaction target included in the per-order information from the securities trading system, the number of the transaction target is determined according to the code of the transaction target, and then a memory address recording the transaction price, the transaction direction, and the number of the transaction target is generated according to the preset number of bit positions and the preset relative position relationship corresponding to the transaction price, the transaction direction, and the number of the transaction target respectively. In this way, the position of the market quotation information to be updated can be located according to the generated memory address. Therefore, the numerical value stored in the above memory address can be directly updated by using the transaction quantity included in the per-order information, thus realizing the update of the market quotation order book. Compared with maintaining the market quotation information of the transaction target in the form of a linked list in the market quotation order book, it is not necessary to traverse the market quotation information stored in the linked list to determine the position of the market quotation information to be updated in the linked list every time the per-order information of the transaction target is received, saving the time required for traversing the linked list when updating the market quotation information, reducing the operation complexity when updating the market quotation information, and further reducing the delay when updating the market quotation information.
[0215] In addition, compared with maintaining the market quotation information of the transaction target in the form of a linked list in the market quotation order book, in the solution provided by the embodiment of the present invention, the storage positions of each piece of market quotation information are determined by the above memory address, and there is no link relationship between the memory addresses, which are independent of each other. Therefore, when processing the per-order information of the received transaction target, it is not necessary to wait for the processing of the previous per-order information to end. That is, the update of the market quotation information based on each per-order information does not affect each other, improving the parallel processing ability when updating the market quotation information and further reducing the delay when updating the market quotation information.
[0216] In one embodiment of the present invention, the numerical value updating module 705 is specifically configured to: if the order type included in the per-order information is a commission type, accumulate the transaction quantity for the numerical value stored at the memory address; if the order type included in the per-order information is a transaction type, subtract the transaction quantity from the numerical value stored at the memory address.
[0217] In this way, based on different order types, the transaction quantity of the transaction target stored in the local market order book can be accurately updated.
[0218] In one embodiment of the present invention, the device further includes:
[0219] A transaction information output module, which is configured to, for each transaction target for which market information is stored in the market order book, in different trading directions, determine a preset number of target transaction prices with the highest user attention from the transaction prices recorded at the address storing the number of the transaction target, and output the target transaction prices and the trading volume stored at the target address, where the target address is the address recording the target transaction price.
[0220] For each transaction target for which market information is stored in the market order book, in different trading directions, determining a preset number of target transaction prices with the highest user attention from the transaction prices recorded at the address storing the number of the transaction target, and outputting the target transaction prices and the trading volume stored at the target address, that is, outputting the order information with high user attention in different trading directions. The order information output in this way can be intuitively provided for the user's reference, facilitating the user to adjust their trading strategy according to the above order information.
[0221] In one embodiment of the present invention, the preset number of bits corresponding to the transaction price is determined according to the maximum transaction price supported by the securities trading system and the price precision;
[0222] The preset number of bits corresponding to the trading direction is determined according to the number of trading directions;
[0223] The preset number of bits corresponding to the number of the transaction target is determined according to the maximum number of transaction targets concerned by the user.
[0224] In this way, according to the information characteristics of information such as the transaction price, trading direction, and number of the transaction target, a suitable preset number of bits can be determined for the above information, so that the preset number of bits can accurately represent the above information.
[0225] See Figure 8 , Figure 8 which is the first market information output device provided by the embodiment of the present invention. The above device includes the following modules 801 - module 804.
[0226] The first transaction price acquisition module 801 is configured to obtain, for each trading target with market information stored in the market order book, the first highest transaction price and the first lowest transaction price of the trading target in the buy direction;
[0227] The first memory address determination module 802 is configured to determine a first memory address according to the first highest transaction price, the number of the trading target, and the buy direction, and determine a second memory address according to the first lowest transaction price, the number of the trading target, and the buy direction;
[0228] The first target transaction price determination module 803 is configured to perform a first operation address by address in a manner of decreasing addresses at a preset step length starting from the first memory address until a preset number of target transaction prices with the highest user attention are determined or the address is less than the second memory address. The first operation includes: when the transaction quantity stored at the address is greater than 0, determining the transaction price recorded at the address as the target transaction price.
[0229] The transaction information output sub-module 804 is configured to output the target transaction price and the trading volume stored at the target address, where the target address is the address recording the target transaction price.
[0230] When the trading direction is buy, since the transaction price is recorded in the memory address and the first memory address is the memory address corresponding to the first highest transaction price, therefore, decreasing at a preset step length based on the first memory address, the obtained address is also the address corresponding to the transaction price decreasing based on the first highest transaction price. Therefore, after performing the first operation on the decreasing obtained address, the preset number of target transaction prices with the highest transaction price can be accurately determined in the order from high to low of the transaction price.
[0231] See Figure 9 , Figure 9 This is the second market information output device provided by the embodiment of the present invention. The above device includes the following modules 901 - module 904.
[0232] The second transaction price acquisition module 901 is configured to obtain, for each trading target with market information stored in the market order book, the second highest transaction price and the second lowest transaction price of the trading target in the sell direction;
[0233] The second memory address determination module 902 is configured to determine a third memory address according to the second lowest transaction price, the number of the trading target, and the sell direction, and determine a fourth memory address according to the second highest transaction price, the number of the trading target, and the sell direction;
[0234] The second target transaction price determination module 903 is configured to perform a second operation address by address starting from the third memory address in a manner of increasing the address according to a preset step size until a preset number of target transaction prices with the highest user attention are determined or the address is greater than the fourth memory address. Wherein, the second operation includes: when the transaction quantity stored at the address is greater than 0, determining the transaction price recorded at the address as the target transaction price.
[0235] The transaction information output sub-module 904 is configured to output the target transaction price and the trading volume stored at the target address, where the target address is the address where the target transaction price is recorded.
[0236] When the trading direction is selling, since the transaction price is recorded in the memory address and the third memory address is the memory address corresponding to the second highest transaction price, increasing the address based on the third memory address according to the preset step size means the obtained address is the address corresponding to the transaction price increased on the basis of the second highest transaction price. Therefore, after performing the second operation on the incremented address, the preset number of target transaction prices with the highest transaction price can be accurately determined in the order from high to low of the transaction price.
[0237] In an embodiment of the present invention, after the per-order information acquisition module, it further includes:
[0238] The price determination module is configured to determine the third highest price and the third lowest price at which the transaction target corresponding to the per-order information conducts transactions in the trading direction included in the per-order information from the highest transaction price and the lowest transaction price cached locally;
[0239] The price update module is configured to update the third highest price to the transaction price when the transaction price included in the per-order information is higher than the third highest price, and update the third lowest price to the transaction price when the transaction price is lower than the third lowest price.
[0240] In this way, the highest transaction price and the lowest transaction price cached locally can be continuously updated according to the transaction price included in the per-order information, so that the target transaction price can be accurately determined based on the highest transaction price and the lowest transaction price subsequently.
[0241] An embodiment of the present invention further provides an electronic device, as Figure 10 shown, including a processor 1001, a communication interface 1002, a memory 1003, and a communication bus 1004. Among them, the processor 1001, the communication interface 1002, and the memory 1003 communicate with each other through the communication bus 1004.
[0242] A memory 1003 for storing computer programs;
[0243] A processor 1001, when executing the programs stored on the memory 1003, implements the market information update method provided by the embodiments of the present invention.
[0244] The communication bus mentioned in the above electronic device may be a Peripheral Component Interconnect (PCI) bus, an Extended Industry Standard Architecture (EISA) bus, or the like. This communication bus can be divided into an address bus, a data bus, a control bus, etc. For the sake of representation, only a thick line is used in the figure, but it does not mean that there is only one bus or one type of bus.
[0245] The communication interface is used for communication between the above electronic device and other devices.
[0246] The memory may include a Random Access Memory (RAM), or may also include a Non-Volatile Memory (NVM), such as at least one disk memory. Optionally, the memory may also be at least one storage device located far from the aforementioned processor.
[0247] The above-mentioned processor may be a general-purpose processor, including a Central Processing Unit (CPU), a Network Processor (NP), etc.; it may also be a Digital Signal Processor (DSP), an Application Specific Integrated Circuit (ASIC), a Field-Programmable Gate Array (FPGA), or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components.
[0248] In another embodiment provided by the present invention, a computer-readable storage medium is also provided. The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, it implements the market information update method provided by the embodiments of the present invention.
[0249] In another embodiment provided by the present invention, a computer program product containing instructions is also provided. When it runs on a computer, it causes the computer to execute the market information update method provided by the embodiments of the present invention.
[0250] In the above embodiments, it can be implemented in whole or in part by software, hardware, firmware, or any combination thereof. When implemented using software, it can be implemented in whole or in part in the form of a computer program product. The computer program product includes one or more computer instructions. When the computer program instructions are loaded and executed on a computer, the processes or functions described in the embodiments of the present invention are generated in whole or in part. The computer can be a general-purpose computer, a special-purpose computer, a computer network, or other programmable devices. The computer instructions can be stored in a computer-readable storage medium or transmitted from one computer-readable storage medium to another. For example, the computer instructions can be transmitted from one website, computer, server, or data center to another website, computer, server, or data center by wire (such as coaxial cable, optical fiber, digital subscriber line (DSL)) or wireless (such as infrared, wireless, microwave, etc.). The computer-readable storage medium can be any available medium that can be accessed by a computer or a data storage device such as a server or a data center that includes one or more integrated available media. The available medium can be a magnetic medium (such as a floppy disk, a hard disk, a magnetic tape), an optical medium (such as a DVD), or a semiconductor medium (such as a solid state disk (SSD)).
[0251] It should be noted that, in this document, relational terms such as first and fourth are only used to distinguish one entity or operation from another entity or operation, and do not necessarily require or imply any actual relationship or order between these entities or operations. Moreover, the term "comprising", "including", or any other variation thereof is intended to cover non-exclusive inclusion, so that a process, method, article, or device that includes a series of elements includes not only those elements but also other elements that are not explicitly listed, or also includes elements that are inherent to such process, method, article, or device. Without further limitation, an element defined by the statement "including a..." does not exclude the existence of additional identical elements in the process, method, article, or device that includes the element.
[0252] Each embodiment in this specification is described in a related manner. For the same or similar parts among the embodiments, reference can be made to each other. Each embodiment focuses on the differences from other embodiments. In particular, for the embodiments of the device, electronic device, and computer storage medium, since they are basically similar to the method embodiments, the description is relatively simple, and the relevant parts can refer to the partial description of the method embodiments.
[0253] The above are only the preferred embodiments of the present invention and are not intended to limit the protection scope of the present invention. Any modifications, equivalent replacements, improvements, etc. made within the spirit and principle of the present invention are all included within the protection scope of the present invention.
Claims
1. A market information update method, characterized in that, The method includes: Obtaining the per - order information from the securities trading system; Obtaining the trading price, trading direction, and the code of the trading target included in the per - order information; According to the code of the trading target, determining the number of the trading target, and generating a memory address recording the trading price, trading direction, and the number of the trading target according to the preset number of bit positions corresponding to the trading price, trading direction, and the number of the trading target respectively, and the preset relative position relationship, wherein there is a one - to - one mapping between the trading price and the memory address, and the size of the memory address reflects the size of the trading price stored in the memory address; Judging whether there is a value stored in the memory address; If yes, updating the value stored in the memory address based on the order type and the trading quantity included in the per - order information; If no, storing the trading quantity included in the per - order information into the memory address.
2. The method according to claim 1, characterized in that, The updating the value stored in the memory address based on the order type and the trading quantity included in the per - order information includes: If the order type included in the per - order information is the entrustment type, adding the trading quantity to the value stored in the memory address; If the order type included in the per - order information is the transaction type, subtracting the trading quantity from the value stored in the memory address.
3. The method according to claim 1 or 2, characterized in that, The method further includes: For each trading target with market information stored in the market order book, in different trading directions, determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target, and outputting the target trading prices and the trading volume stored in the target address, wherein the target address is: the address recording the target trading price.
4. The method according to claim 3, characterized in that, When the trading direction is the buy direction, the determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target includes: Obtaining the first highest trading price and the first lowest trading price of the trading target in the buy direction; Determining a first memory address according to the first highest trading price, the number of the trading target, and the buy direction, and determining a second memory address according to the first lowest trading price, the number of the trading target, and the buy direction; Starting from the first memory address, performing a first operation address - by - address in the manner of decreasing address according to a preset step size until a preset number of target trading prices with the highest user attention are determined or the address is less than the second memory address, wherein the first operation includes: when the trading volume stored at the address is greater than 0, determining the trading price recorded at the address as the target trading price.
5. The method according to claim 3, characterized in that, When the trading direction is the sell direction, the determining a preset number of target trading prices with the highest user attention from the trading prices recorded at the address storing the number of the trading target includes: Obtaining the second highest trading price and the second lowest trading price of the trading target in the sell direction; Determine a third memory address according to the second lowest transaction price, the number of the transaction target, and the selling direction, and determine a fourth memory address according to the second highest transaction price, the number of the transaction target, and the selling direction; Starting from the third memory address, perform a second operation address by address in the manner of increasing the address according to a preset step length until a preset number of target transaction prices with the highest user attention are determined or the address is greater than the fourth memory address. The second operation includes: when the transaction quantity stored at the address is greater than 0, determine the transaction price recorded at the address as the target transaction price.
6. The method according to claim 4 or 5, characterized in that, After obtaining the per-order information from the securities trading system, it further includes: Determine the third highest price and the third lowest price at which the transaction target corresponding to the per-order information conducts transactions in the transaction direction included in the per-order information from the highest transaction price and the lowest transaction price cached locally; When the transaction price included in the per-order information is higher than the third highest price, update the third highest price to the transaction price; when the transaction price is lower than the third lowest price, update the third lowest price to the transaction price.
7. The method according to claim 1 or 2, characterized in that, The preset number of bit positions corresponding to the transaction price is determined according to the maximum transaction price supported by the securities trading system and the price precision; The preset number of bit positions corresponding to the transaction direction is determined according to the number of the transaction directions; The preset number of bit positions corresponding to the number of the transaction target is determined according to the maximum number of transaction targets concerned by the user.
8. A market information update device, characterized in that, The device includes: A per-order information acquisition module, configured to acquire per-order information from a securities trading system; A transaction information acquisition module, configured to acquire the transaction price, the transaction direction, and the code of the transaction target included in the per-order information; A memory address generation module, configured to determine the number of the transaction target according to the code of the transaction target, and generate a memory address recording the transaction price, the transaction direction, and the number of the transaction target according to the preset number of bit positions corresponding to the transaction price, the transaction direction, and the number of the transaction target respectively and the preset relative position relationship. There is a one-to-one mapping between the transaction price and the memory address, and the size of the memory address reflects the size of the transaction price stored at the memory address; A numerical judgment module, configured to judge whether a numerical value is stored at the memory address. If yes, trigger a numerical value update module; if not, trigger a transaction quantity storage module; A numerical value update module, configured to update the numerical value stored at the memory address based on the order type included in the per-order information and the transaction quantity; A transaction quantity storage module, configured to store the transaction quantity included in the per-order information into the memory address.
9. An electronic device, characterized in that, It includes a processor, a communication interface, a memory, and a communication bus. Among them, the processor, the communication interface, and the memory complete mutual communication through the communication bus; The memory is used to store computer programs; The processor, when executing the programs stored on the memory, implements the method steps described in any one of claims 1-7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method steps described in any one of claims 1-7 are implemented.
Citation Information
Patent Citations
Snapshot market distribution method and device, equipment and storage medium
CN112965860A
FPGA acceleration board card and market data processing method thereof
CN114328348A