Method, system and device for simulating and replaying market data
By parsing and repartitioning financial market data in the financial market, it solves the problems of untimely data transmission and inconsistent timestamps, achieves fast reading and parallel distribution, and improves the efficiency and data authenticity of investment research and strategy backtesting.
Patent Information
- Application Number
- CN202311120326.3
- Authority / Receiving Office
- CN · China
- Patent Type
- Patents(China)
- Current Assignee / Owner
- Filing Date
- 2023-08-31
- Publication Date
- 2024-09-06
- Estimated Expiration
- 2043-08-31
AI Technical Summary
The existing technology's transmission of financial market data in the financial market is not timely and efficient enough, resulting in a reduction in the efficiency of investment research and strategy backtesting, and it is difficult for the market data consumer to maintain the consistency of multi-dimensional time series data timestamps, affecting the authenticity of business data. and effectiveness.
By receiving the replay market request message initiated by the message middleware, parsing the key information to be replayed, querying the sharding information of the time series database, locating the distributed data nodes, reading the time series data and writing it into the flow data table, and forming a unified basis based on the timestamp feature alignment. Time series indexing, repartitioning, and pushing data to messaging middleware.
It achieves fast reading of time series data and parallel distribution of the same timeline, improves the timeliness and efficiency of data transmission, ensures the consistency of multi-dimensional time series data timestamps, and improves the efficiency and data of investment research and strategy backtesting businesses. authenticity.
Smart Images

Figure CN117076570B
Abstract
Description
Technical Field
[0001] The present invention relates to the technical field of financial market data processing, and in particular to a method, system and device for simulating and replaying market market data. Background Art
[0002] Financial market data is a basic data element that reflects the level of activity in the financial market. The use of financial market data is involved in investment research, strategy backtesting, simulated trading, and real trading in the financial market. In investment research and strategy backtesting, the common practice in the market is to send historical market data to the market data consumer by reading files or pushing messages. The market data consumer is equipped with a simulated matching service or data calculation service to apply the pushed data to the business processing logic.
[0003] During the entire business processing process, market data of multiple dimensions need to be compared, deduced and calculated horizontally. The existing solution is to concurrently read or push message data through multi-process / multi-threading methods, but this type of method still has shortcomings. On the one hand, during the business processing process, the transmission of relevant data is not timely and efficient, resulting in reduced efficiency of investment research and strategy backtesting business; on the other hand, when the market data consumer conducts horizontal comparison, deduction and calculation of market data, it is difficult to maintain the consistency of multi-dimensional time series data timestamps, which makes it difficult to provide real and effective business data support for investment research and strategy backtesting business. Summary of the invention
[0004] The present invention aims at the shortcomings of the prior art and provides a method, system and device for simulating and replaying market quotation data.
[0005] In order to solve the above technical problems, the present invention is solved by the following technical solutions:
[0006] A method for simulating and replaying market data comprises the following steps:
[0007] Receive and parse the market replay request message initiated by the message middleware to obtain key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0008] Based on the key information to be replayed, query the corresponding shard information in the time series database and locate the corresponding distributed data nodes;
[0009] The distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index;
[0010] Repartition the data content to be pushed based on a preset repartition rule and a unified time series index to obtain a repartition key value;
[0011] The data content to be pushed in the message queue is pushed to the message middleware based on the repartition key value.
[0012] As an implementable method, the method of querying the corresponding shard information in the time series database and locating the corresponding distributed data node based on the key information to be replayed includes the following steps:
[0013] Extract the key information to be replayed to obtain relevant metadata and parse it to obtain the corresponding sharding information, query statements and query condition information, and extract the content corresponding to the partition key based on the sharding information;
[0014] The query statement is rewritten based on the distributed SQL standard to obtain a new query statement, and the query scope of the time series data is determined based on the new query statement, and then the corresponding distributed data node is determined.
[0015] As an implementable method, the time series data is aligned according to timestamp information of multiple categories of time series data to form a unified time series index, including the following steps:
[0016] Store various types of time series data in a time series database in sequence;
[0017] According to the request message, obtain the time series data corresponding to the request message;
[0018] According to timestamp information of multiple categories of time series data, the time series data is reordered in the memory table to create a unified time series index.
[0019] As an implementable method, the following steps are also included:
[0020] A time series index table detection period is preset, and an elastic balancing index is set within the detection period. If the data is uneven within a certain period, adjustments are made based on the elastic balancing index.
[0021] As an implementable method, the aligning the time series data according to the timestamp information of multiple categories of time series data to form a unified time series index also includes the following steps:
[0022] Before aligning the time series data according to the timestamp information of the multiple types of time series data to form a unified time series index, a skip list index is generated according to the timestamp information of the multiple types of time series data.
[0023] As an implementable method, pushing the to-be-pushed data content in the message queue to the message middleware based on the repartition key value includes the following steps:
[0024] Preset processing items and obtain the cursor position of the message corresponding to the processing item in real time. The messages after the cursor position have never been obtained.
[0025] Compare the position of the data content to be pushed and the cursor position, if the position of the data content to be pushed is after the cursor position, generate the state information to be pushed, and store the state information to be pushed in the cache;
[0026] The data content to be pushed is pushed to the middleware. When the processing is successful and the processing result is returned, the message processing status information of the data content to be pushed in the cache is deleted.
[0027] As an implementable method, it further includes determining whether the data content to be pushed has been completely pushed to the message middleware, including the following steps:
[0028] The message processing status information in the deleted cache is recorded in real time, and the message processing status information in the deleted cache is compared with the status information to be pushed. If they are consistent, it means that all pushes have been completed.
[0029] A system for simulating and replaying market data, comprising a data analysis module, a data processing module and a data publishing module;
[0030] The data analysis module is used to receive and analyze the market replay request message initiated by the message middleware to obtain the key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0031] The data processing module queries the corresponding sharding information in the time series database and locates the corresponding distributed data node based on the key information to be replayed; the distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and at the same time, realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index; repartitions the data content to be pushed based on the preset repartitioning rule and the unified time series index to obtain a repartitioning key value;
[0032] The data publishing module pushes the data content to be pushed in the message queue to the message middleware based on the repartition key value.
[0033] A device for simulating and replaying market data, characterized in that it includes a memory, a processor, and a computer program stored in the memory and executable on the processor, wherein when the processor executes the computer program, the following method is implemented:
[0034] Receive and parse the market replay request message initiated by the message middleware to obtain key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0035] Based on the key information to be replayed, query the corresponding shard information in the time series database and locate the corresponding distributed data node;
[0036] The distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index;
[0037] Repartition the data content to be pushed based on a preset repartition rule and a unified time series index to obtain a repartition key value;
[0038] The data content to be pushed in the message queue is pushed to the message middleware based on the repartition key value.
[0039] A readable storage medium stores computer instructions, wherein the readable storage medium stores instructions for executing the following method:
[0040] Receive and parse the market replay request message initiated by the message middleware to obtain key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0041] Based on the key information to be replayed, query the corresponding shard information in the time series database and locate the corresponding distributed data node;
[0042] The distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index;
[0043] Repartition the data content to be pushed based on a preset repartition rule and a unified time series index to obtain a repartition key value;
[0044] The data content to be pushed in the message queue is pushed to the message middleware based on the repartition key value.
[0045] The present invention has significant technical effects due to the adoption of the above technical solution:
[0046] The present invention realizes fast reading of time series data and parallel distribution of time series data on the same time axis through a method of repartitioning the database based on repartition rules and reading time series data into a memory stream data table, so as to solve the problems that the transmission of relevant data in the current business processing process is not timely and efficient, resulting in reduced efficiency of investment research and strategy backtesting business, and the market data consumer end is difficult to maintain the consistency of multi-dimensional time series data timestamps when performing horizontal comparison, deduction and calculation of market data. BRIEF DESCRIPTION OF THE DRAWINGS
[0047] Figure 1 A schematic diagram of a flow chart of a method for simulating and replaying market data according to the present invention;
[0048] Figure 2 The present invention is a structural schematic diagram of a system for simulating and replaying market quotation data. DETAILED DESCRIPTION
[0049] The following will be combined with the drawings in the embodiments of the present invention to clearly and completely describe the technical solutions in the embodiments of the present invention. Obviously, the described embodiments are only part of the embodiments of the present invention, not all of the embodiments. Based on the embodiments of the present invention, all other embodiments obtained by ordinary technicians in this field without creative work are within the scope of protection of the present invention.
[0050] Embodiment 1:
[0051] A method for simulating and replaying market data, such as Figure 1 As shown, the following steps are included:
[0052] S100, receiving and parsing a market replay request message initiated by a message middleware, and obtaining key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0053] S200, based on the key information to be replayed, query the corresponding shard information in the time series database and locate the corresponding distributed data node;
[0054] S300, the distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and at the same time, realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index;
[0055] S400, repartitioning the data content to be pushed based on a preset repartitioning rule and a unified time series index to obtain a repartitioning key value;
[0056] S500: Push the data content to be pushed in the message queue to the message middleware based on the repartition key value.
[0057] In step 200, based on the key information to be replayed, querying the corresponding shard information in the time series database and locating the corresponding distributed data node includes the following steps:
[0058] Extract the key information to be replayed to obtain relevant metadata and parse it to obtain the corresponding sharding information, query statements and query condition information, and extract the content corresponding to the partition key based on the sharding information;
[0059] The query statement is rewritten based on the distributed SQL standard to obtain a new query statement, and the query scope of the time series data is determined based on the new query statement, and then the corresponding distributed data node is determined.
[0060] In S300, the time series data is aligned according to the timestamp information of multiple categories of time series data to form a unified time series index, including the following steps:
[0061] Store various types of time series data in a time series database in sequence;
[0062] According to the request message, obtain the time series data corresponding to the request message;
[0063] According to timestamp information of multiple categories of time series data, the time series data is reordered in the memory table to create a unified time series index.
[0064] When creating a unified time series index, in order to keep data uniform, in one embodiment, a time series index table detection period is preset, and an elastic balance index is set within the detection period. If data is uneven within a period, adjustments are made based on the elastic balance index.
[0065] In addition, in one embodiment, before aligning the time series data according to the timestamp information of multiple types of time series data to form a unified time series index, a skip table index is first generated according to the timestamp information of multiple types of time series data. The skip table index can accelerate the rapid jump and retrieval speed of multiple types of time series data. When the amount of data is very large, the number of queries can be reduced based on the skip table index to reduce the workload. When the time series data is aligned based on the timestamp information of multiple types of time series data to form a unified time series index, the time series data that needs to be repartitioned can be locked more quickly through the skip table index + time series index table, and then pushed to the subscription entity.
[0066] In step S500, the method of pushing the data content to be pushed in the message queue to the message middleware based on the repartition key value includes the following steps:
[0067] Preset processing items and obtain the cursor position of the message corresponding to the processing item in real time. The messages after the cursor position have never been obtained.
[0068] Compare the position of the data content to be pushed and the cursor position, if the position of the data content to be pushed is after the cursor position, generate the state information to be pushed, and store the state information to be pushed in the cache;
[0069] The data content to be pushed is pushed to the middleware. When the processing is successful and the processing result is returned, the message processing status information of the data content to be pushed in the cache is deleted.
[0070] Of course, the whole process also includes the step of determining whether the data content to be pushed has been completely pushed to the message middleware, specifically: real-time recording of the message processing status information in the deleted cache, and comparing the message processing status information in the deleted cache with the status information to be pushed. If they are consistent, it means that all pushes have been completed.
[0071] Of course, in one embodiment, the data content to be pushed is realigned based on the timestamp feature of the time series data, which actually also includes classifying the timestamp based on the timestamp feature. However, in general, the timestamp type is a fixed number of bits, for example, 11 bits or 13 bits, so simple classification can be performed. In this embodiment, there is no requirement for the classification method, and the main purpose is to classify the timestamp based on the timestamp feature to obtain the classification result.
[0072] The present invention realizes fast reading of time series data and parallel distribution of time series data on the same time axis through a method of repartitioning the database based on repartition rules and reading time series data into a memory stream data table, so as to solve the problems that the transmission of relevant data in the current business processing process is not timely and efficient, resulting in reduced efficiency of investment research and strategy backtesting business, and the market data consumer end is difficult to maintain the consistency of multi-dimensional time series data timestamps when performing horizontal comparison, deduction and calculation of market data.
[0073] Embodiment 2:
[0074] A system that simulates and replays market data, such as Figure 2 As shown, it includes a data parsing module 100, a data processing module 200 and a data publishing module 300;
[0075] The data analysis module 100 is used to receive and analyze the market replay request message initiated by the message middleware to obtain the key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data;
[0076] The data processing module 200 queries the corresponding sharding information in the time series database and locates the corresponding distributed data node based on the key information to be replayed; the distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and at the same time, realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index; repartitions the data content to be pushed based on the preset repartitioning rule and the unified time series index to obtain a repartitioning key value;
[0077] The data publishing module 300 pushes the to-be-pushed data content in the message queue to the message middleware based on the repartition key value.
[0078] As for the device embodiment, since it is basically similar to the method embodiment, the description is relatively simple, and the relevant parts can be referred to the partial description of the method embodiment.
[0079] The various embodiments in this specification are described in a progressive manner, and each embodiment focuses on the differences from other embodiments. The same or similar parts between the various embodiments can be referenced to each other.
[0080] It should be understood by those skilled in the art that the embodiments of the present invention may be provided as methods, devices, or computer program products. Therefore, the present invention may take the form of a complete hardware embodiment, a complete software embodiment, or an embodiment combining software and hardware. Moreover, the present invention may take the form of a computer program product implemented on one or more computer-usable storage media (including but not limited to disk storage, CD ROM, optical storage, etc.) containing computer-usable program code.
[0081] The present invention is described with reference to the flowcharts and / or block diagrams of the method, terminal device (system), and computer program product according to the present invention. It should be understood that each process and / or block in the flowchart and / or block diagram, as well as the combination of the processes and / or blocks in the flowchart and / or block diagram, can be implemented by computer program instructions. These computer program instructions can be provided to a processor of a general-purpose computer, a special-purpose computer, an embedded processor, or other programmable data processing terminal device to generate a machine, so that the instructions executed by the processor of the computer or other programmable data processing terminal device generate instructions for implementing the processes in the flowchart and / or block diagram. Figure 1 A process or multiple processes and / or boxes Figure 1 A device that provides the functions specified in a block or multiple blocks.
[0082] These computer program instructions may also be stored in a computer readable memory capable of directing a computer or other programmable data processing terminal device to operate in a specific manner, so that the instructions stored in the computer readable memory produce a manufactured product including an instruction device, which implements the process Figure 1 A process or multiple processes and / or boxes Figure 1 A function specified in one or more boxes.
[0083] These computer program instructions can also be loaded onto a computer or other programmable data processing terminal device so that a series of operating steps are executed on the computer or other programmable terminal device to produce a computer-implemented process, thereby providing instructions for executing on the computer or other programmable terminal device to implement the process. Figure 1 A process or multiple processes and / or boxes Figure 1 The steps for the functions specified in one or more boxes.
[0084] In addition, it should be noted that the shapes and names of the parts of the specific embodiments described in this specification may be different. Any equivalent or simple changes made based on the structure, features and principles described in the patent concept of the present invention are included in the protection scope of the patent of the present invention. The technicians in the technical field of the present invention can make various modifications or supplements to the specific embodiments described or replace them in a similar manner, as long as they do not deviate from the structure of the present invention or exceed the scope defined by the claims, they should all fall within the protection scope of the present invention.
Claims
1. A method for simulating and replaying market data. It is characterized in that The following steps are involved: Receive and parse the market replay request message initiated by the message middleware to obtain key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data; Based on the key information to be replayed, query the corresponding shard information in the time series database and locate the corresponding distributed data nodes; The distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index; Repartition the data content to be pushed based on a preset repartition rule and a unified time series index to obtain a repartition key value; Pushing the data content to be pushed in the message queue to the message middleware based on the repartition key value; The time series data are aligned according to the timestamp information of multiple categories of time series data to form a unified time series index, including the following steps: Store various types of time series data in a time series database in sequence; According to the request message, obtain the time series data corresponding to the request message; According to timestamp information of multiple categories of time series data, the time series data are reordered in the memory table to create a unified time series index; The following steps are also included: Preset the time series index table detection period, set the elastic balance index within the detection period, and if the data is uneven within a certain period, adjust it based on the elastic balance index; The following steps are also included: Before aligning the time series data according to the timestamp information of the multiple types of time series data to form a unified time series index, generating a skip table index according to the timestamp information of the multiple types of time series data; The method of pushing the data content to be pushed in the message queue to the message middleware based on the repartition key value includes the following steps: Preset processing items and obtain the cursor position of the message corresponding to the processing item in real time. The messages after the cursor position have never been obtained. Compare the position of the data content to be pushed and the cursor position, if the position of the data content to be pushed is after the cursor position, generate the state information to be pushed, and store the state information to be pushed in the cache; The data content to be pushed is pushed to the middleware. When the processing is successful and the processing result is returned, the message processing status information of the data content to be pushed in the cache is deleted.
2. The method for simulating and replaying market data according to claim 1, It is characterized in that Based on the key information to be replayed, querying the corresponding shard information in the time series database and locating the corresponding distributed data node includes the following steps: Extract the key information to be replayed to obtain relevant metadata and parse it to obtain the corresponding sharding information, query statements and query condition information, and extract the content corresponding to the partition key based on the sharding information; The query statement is rewritten based on the distributed SQL standard to obtain a new query statement, and the query scope of the time series data is determined based on the new query statement, and then the corresponding distributed data node is determined.
3. The method for simulating and replaying market data according to claim 1, It is characterized in that It also includes determining whether the data content to be pushed has been pushed to the message middleware, including the following steps: The message processing status information in the deleted cache is recorded in real time, and the message processing status information in the deleted cache is compared with the status information to be pushed. If they are consistent, it means that all pushes have been completed.
4. A system for simulating and replaying market data, It is characterized in that It includes data analysis module, data processing module and data publishing module; The data analysis module is used to receive and analyze the market replay request message initiated by the message middleware to obtain the key information to be replayed corresponding to the market replay request message, wherein the key information to be replayed includes at least one time series data; The data processing module queries the corresponding sharding information in the time series database and locates the corresponding distributed data node based on the key information to be replayed; the distributed data node reads the data content to be pushed stored in a distributed format corresponding to the time series data in the time series database, writes the data content to be pushed into the stream data table, and at the same time, realigns the data content to be pushed based on the timestamp feature of the time series data to form a unified time series index; repartitions the data content to be pushed based on the preset repartitioning rule and the unified time series index to obtain a repartitioning key value; The data publishing module pushes the data content to be pushed in the message queue to the message middleware based on the repartition key value; The time series data are aligned according to the timestamp information of multiple categories of time series data to form a unified time series index, including the following steps: Store various types of time series data in a time series database in sequence; According to the request message, obtain the time series data corresponding to the request message; According to timestamp information of multiple categories of time series data, the time series data are reordered in the memory table to create a unified time series index; The following steps are also included: Preset the time series index table detection period, set the elastic balance index within the detection period, and if the data is uneven within a certain period, adjust it based on the elastic balance index; The following steps are also included: Before aligning the time series data according to the timestamp information of the multiple types of time series data to form a unified time series index, generating a skip table index according to the timestamp information of the multiple types of time series data; The method of pushing the data content to be pushed in the message queue to the message middleware based on the repartition key value includes the following steps: Preset processing items and obtain the cursor position of the message corresponding to the processing item in real time. The messages after the cursor position have never been obtained. Compare the position of the data content to be pushed and the cursor position, if the position of the data content to be pushed is after the cursor position, generate the state information to be pushed, and store the state information to be pushed in the cache; The data content to be pushed is pushed to the middleware. When the processing is successful and the processing result is returned, the message processing status information of the data content to be pushed in the cache is deleted.
5. A device for simulating and replaying market data, It is characterized in that The method comprises a memory, a processor and a computer program stored in the memory and executable on the processor, wherein the processor implements the method according to any one of claims 1 to 3 when executing the computer program.
6. A readable storage medium storing computer instructions, It is characterized in that The readable storage medium stores a method for executing any one of claims 1 to 3.
