Testing method, device, electronic device and storage medium for snapshot market data

By obtaining and analyzing the exchange's market data, generating more comprehensive snapshot market data, and comparing it with the data pushed by the terminal, the problem of insufficient testing accuracy in the existing technology is solved and the profitability of the high-frequency trading system is improved.

CN114238209BActive Publication Date: 2024-12-13SHANGHAI FUDAN KINGSTAR COMPUTER CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202111354172.5
Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2021-11-16
Publication Date
2024-12-13
Estimated Expiration
2041-11-16

AI Technical Summary

Technical Problem

The existing technology cannot accurately test the snapshot market data generated by the order book, resulting in the high-frequency trading system being unable to accurately obtain real-time transaction and entrustment information, which in turn affects the profit level.

Method used

By obtaining the exchange's market data, analyzing and matching the market by transaction, generating more comprehensive first snapshot market data, and comparing it with the second snapshot market data pushed by the terminal to determine the test results, thereby improving the accuracy of the test.

Benefits of technology

The use of more comprehensive snapshot market data for testing improves the accuracy and testing accuracy of snapshot market data generated by the order book, ensuring that the high-frequency trading system can obtain more accurate real-time information, thereby improving profitability.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN114238209B_ABST
    Figure CN114238209B_ABST
Patent Text Reader

Abstract

The present application is applicable to the field of data processing technology, and provides a test method, device, electronic device and storage medium for snapshot market data. The test method for snapshot market data includes: obtaining market data from an exchange, parsing the market data, obtaining transaction-by-transaction market data, matching transaction-by-transaction market data, obtaining first snapshot market data, comparing the first snapshot market data with the second snapshot market data pushed by the terminal, and determining the test result of the second snapshot market data based on the comparison result. Since the first snapshot market data obtained is a more comprehensive snapshot market data, the first snapshot market data is used to test the second snapshot market data, thereby improving the accuracy of the test.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present application belongs to the field of data processing technology, and in particular relates to a testing method, device, electronic device and storage medium for snapshot market data. Background Art

[0002] The profitability of a high-frequency trading system is largely determined by the speed of the buying and selling information in the captured snapshots. At present, the update frequency of the exchange snapshot is generally 3 seconds. Many transactions and orders occur in these 3 seconds, and these transactions and orders cannot be fully reflected in the captured snapshots. Therefore, the high-frequency trading system cannot accurately obtain real-time transaction and order information based on the captured snapshots, and thus cannot achieve a higher level of profitability. Based on the above market, the order book came into being.

[0003] The order book runs on the terminal and is used to generate snapshot market data. Currently, the snapshot market data pushed by the exchange is generally used to verify the accuracy of the snapshot market data generated by the order book. However, the snapshot market data pushed by the exchange is only a part of the data pushed by the order book, so the snapshot market data generated by the order book cannot be accurately tested. Summary of the invention

[0004] In view of this, the embodiments of the present application provide a method, device, electronic device and storage medium for testing snapshot market data, which use more comprehensive data to test the snapshot market data to improve the test accuracy.

[0005] A first aspect of an embodiment of the present application provides a method for testing snapshot market data, including:

[0006] Get market data from the exchange;

[0007] Analyze the market data to obtain transaction-by-transaction market information;

[0008] Matching the transaction-by-transaction market data to obtain the first snapshot market data;

[0009] The first snapshot market data is compared with the second snapshot market data pushed by the terminal, and a test result of the second snapshot market data is determined according to the comparison result.

[0010] In a possible implementation, comparing the first snapshot market data with the second snapshot market data pushed by the terminal includes:

[0011] The first snapshot market data is stored in a first list according to a preset format, the second snapshot market data is stored in a second list according to the preset format, and the first list is compared with the second list.

[0012] In a possible implementation, the terminal pushes the second snapshot market data in a UDP message format, and after obtaining the first snapshot market data, the method further includes:

[0013] The first snapshot market data is forged into a UDP message.

[0014] In a possible implementation, after forging the first snapshot market data into a UDP message, the method further includes:

[0015] If it is detected that the terminal interrupts the push of the second snapshot market data, the forged UDP message is stored in the terminal.

[0016] In a possible implementation, before comparing the first snapshot market data with the second snapshot market data pushed by the terminal, the method further includes:

[0017] The operating parameters of the terminal are configured so that the terminal parses the received market data according to a set method to obtain the second snapshot market data.

[0018] In a possible implementation, parsing the market data to obtain transaction-by-transaction market information includes:

[0019] Extracting valid data from the market data;

[0020] Splicing the valid data to obtain spliced ​​data;

[0021] The spliced ​​data is analyzed to obtain the transaction-by-transaction market information.

[0022] In a possible implementation, matching the tick-by-tick market conditions to obtain first snapshot market data includes:

[0023] Get the static files of the exchange;

[0024] Determine the calculation method for each field in the cache list;

[0025] According to the calculation method of each field in the cache list, read the corresponding data from the static file and the tick-by-tick market information and perform calculations, and write the calculation results into the cache list;

[0026] The cache list that records the preset conditions is used as the first snapshot market data.

[0027] A second aspect of an embodiment of the present application provides a device, including:

[0028] Acquisition module, used to obtain market data from the exchange;

[0029] An analysis module is used to analyze the market data to obtain transaction-by-transaction market information;

[0030] A matching module, used for matching the transaction-by-transaction market data to obtain first snapshot market data;

[0031] The comparison module is used to compare the first snapshot market data with the second snapshot market data pushed by the terminal, and determine the test result of the second snapshot market data according to the comparison result.

[0032] In a possible implementation, the comparison module is specifically used to:

[0033] The first snapshot market data is stored in a first list according to a preset format, the second snapshot market data is stored in a second list according to the preset format, and the first list is compared with the second list.

[0034] In a possible implementation, the terminal pushes the second snapshot market data in the format of a UDP message, and the matching module is further used to:

[0035] The first snapshot market data is forged into a UDP message.

[0036] In a possible implementation, the matching module is further used to:

[0037] If it is detected that the terminal interrupts the push of the second snapshot market data, the forged UDP message is stored in the terminal.

[0038] In a possible implementation, the comparison module is specifically used to:

[0039] The operating parameters of the terminal are configured so that the terminal parses the received market data according to a set method to obtain the second snapshot market data.

[0040] In a possible implementation, the parsing module is specifically used to:

[0041] Extracting valid data from the market data;

[0042] Splicing the valid data to obtain spliced ​​data;

[0043] The spliced ​​data is analyzed to obtain the transaction-by-transaction market information.

[0044] In a possible implementation, the matching module is specifically used to:

[0045] Get the static files of the exchange;

[0046] Determine the calculation method for each field in the cache list;

[0047] According to the calculation method of each field in the cache list, read the corresponding data from the static file and the tick-by-tick market information and perform calculations, and write the calculation results into the cache list;

[0048] The cache list that records the preset conditions is used as the first snapshot market data.

[0049] A third aspect of an embodiment of the present application provides an electronic device, including 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 method for testing snapshot market data as described in the first aspect above is implemented.

[0050] A fourth aspect of an embodiment of the present application provides a computer-readable storage medium, wherein the computer-readable storage medium stores a computer program, and when the computer program is executed by a processor, the method for testing snapshot market data as described in the first aspect above is implemented.

[0051] A fifth aspect of an embodiment of the present application provides a computer program product. When the computer program product is run on an electronic device, the electronic device executes the method for testing snapshot market data described in any one of the first aspects.

[0052] Compared with the prior art, the beneficial effects of the embodiments of the present application are as follows: by acquiring the market data of the exchange, parsing the market data, obtaining the transaction-by-transaction market data, matching the transaction-by-transaction market data, and obtaining the first snapshot market data. Therefore, the first snapshot market data is more comprehensive snapshot market data. Then, the first snapshot market data is compared with the second snapshot market data pushed by the terminal, and the test result of the second snapshot market data is determined according to the comparison result. Among them, the order book runs on the terminal, and the second snapshot market data pushed by the terminal is the snapshot market data generated by the order book. Since the second snapshot market data is tested with more comprehensive snapshot market data, the accuracy of the test is improved. BRIEF DESCRIPTION OF THE DRAWINGS

[0053] In order to more clearly illustrate the technical solutions in the embodiments of the present application, the drawings required for use in the embodiments or the description of the prior art are briefly introduced below.

[0054] Figure 1 This is a schematic diagram of the implementation flow of a method for testing snapshot market data provided by an embodiment of the present application;

[0055] Figure 2 is a schematic diagram of a test system provided in an embodiment of the present application;

[0056] Figure 3 It is a flowchart of the execution script provided in the embodiment of the present application;

[0057] Figure 4 It is a schematic diagram of a testing device for snapshot market data provided in an embodiment of the present application;

[0058] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application. DETAILED DESCRIPTION

[0059] In the following description, specific details such as specific system structures, technologies, etc. are provided for the purpose of illustration rather than limitation, so as to provide a thorough understanding of the embodiments of the present application. However, it should be clear to those skilled in the art that the present application may also be implemented in other embodiments without these specific details. In other cases, detailed descriptions of well-known systems, devices, circuits, and methods are omitted to prevent unnecessary details from obstructing the description of the present application.

[0060] It should be understood that when used in this specification and the appended claims, the term "comprising" indicates the presence of described features, integers, steps, operations, elements and / or components, but does not exclude the presence or addition of one or more other features, integers, steps, operations, elements, components and / or groups thereof.

[0061] It should also be understood that the terms used in this application specification are only for the purpose of describing specific embodiments and are not intended to limit the application. As used in this application specification and the appended claims, unless the context clearly indicates otherwise, the singular forms "a", "an" and "the" are intended to include plural forms.

[0062] In addition, in the description of the present application, the terms "first", "second", etc. are only used to distinguish the description and cannot be understood as indicating or implying relative importance.

[0063] Currently, the snapshot market data pushed by the exchange is generally used to verify the snapshot market data generated by the order book. However, the snapshot market data pushed by the exchange is only a part of the data pushed by the order book. Therefore, it is impossible to accurately test the snapshot market data generated by the order book.

[0064] To this end, an embodiment of the present application provides a method for testing snapshot market data, by acquiring the market data of the exchange, parsing the market data, obtaining the transaction-by-transaction market data, matching the transaction-by-transaction market data, and obtaining the first snapshot market data. Therefore, the first snapshot market data is more comprehensive snapshot market data. Then, the first snapshot market data is compared with the second snapshot market data pushed by the terminal, and the test result of the second snapshot market data is determined according to the comparison result. Among them, the order book runs on the terminal, and the second snapshot market data pushed by the terminal is the snapshot market data generated by the order book. Since the second snapshot market data is tested with more comprehensive snapshot market data, the accuracy of the test is improved.

[0065] The following is an exemplary description of the testing method for the snapshot market data provided in this application.

[0066] Please see attached Figure 1 , a method for testing snapshot market data provided by an embodiment of the present application includes:

[0067] S101: Obtain market data from the exchange.

[0068] The test method for snapshot market data provided in the embodiment of the present application is executed on an electronic device, which may be a desktop computer, a notebook, a palm computer, a mobile phone, etc.

[0069] The exchange's market data includes transaction-by-transaction market data, order-by-order market data, etc.

[0070] For example, the market data obtained from the Shenzhen Stock Exchange include: spot (stocks, funds, bonds, etc.) centralized bidding transaction transaction quotation, option centralized bidding transaction transaction quotation, bond general pledged repurchase matching transaction transaction quotation, bond spot transaction matching transaction quotation, bond spot transaction click transaction quotation, bond spot transaction intention declaration transaction quotation, bond spot transaction bidding transaction quotation, bond spot transaction matching transaction large-amount transaction quotation, spot centralized bidding transaction quotation, option centralized bidding transaction quotation, bond general pledged repurchase matching transaction quotation, bond spot transaction matching transaction quotation, bond spot transaction click transaction quotation, bond spot transaction intention declaration transaction quotation, bond spot transaction bidding transaction quotation, bond spot transaction matching transaction large-amount transaction quotation and other data.

[0071] For another example, the market data obtained from the Shanghai Stock Exchange include: bond transaction-by-transaction market data, auction transaction-by-transaction market data, auction entrustment market data and other data.

[0072] S102: Analyze the market data to obtain transaction-by-transaction market information.

[0073] In a possible implementation, the electronic device obtains market data in the form of a data packet, and the data packet includes invalid market data that defines the data packet type or message type. Therefore, after obtaining the market data, valid data is extracted from the market data, and then the valid data is spliced ​​to obtain spliced ​​data, and the spliced ​​data is parsed to obtain the market data for each transaction, which can improve the parsing efficiency of the market data. For example, the message structure of the data packet of the Shenzhen Stock Exchange is a message header, a message body, and a message tail. The message header defines the message type of the message, that is, the market category and the message length, and the message tail is the checksum of the message. The message body is the business data corresponding to the market category, and the business data is the valid data and the payload of each message in the data packet. For another example, the market data of the Shanghai Stock Exchange is a STEP message encapsulated according to the Securities Trading Exchange Protocol (STEP). The message structure of each STEP message includes a message header, a message body, and a message tail. The message header defines the type and length of the message, and the message body includes one or more fast data of the same message type, which is valid data and also a payload.

[0074] Specifically, for the transmission control protocol (TCP) message generated by the market data of the exchange, the message acquisition time, the effective load of the transport layer, and the message sequence number of the data frame of the physical layer of each TCP message are determined according to the format of the TCP message, and each TCP message is stored in a data dictionary with the message sequence number and the message acquisition time as the key value and the value as the effective load. After that, the data dictionary is traversed in a loop, and the message sequence number of the next TCP message of the current TCP message is determined according to the relationship between the message sequence numbers of each TCP message. For example, the message sequence number of the next TCP message is the sum of the message sequence number of the current TCP message and the number of bytes of the effective load of the current TCP message. After determining the message sequence number of each TCP message, according to the message sequence number, the values ​​corresponding to the two adjacent message sequence numbers are spliced, that is, the effective loads of the two adjacent TCP messages are spliced. After all the effective loads are spliced, the spliced ​​effective load string is put into the cache list, and the data in the cache list is parsed to obtain the quotation by transaction.

[0075] For the User Datagram Protocol (UDP) message generated by the market data of the exchange, the flag of the network layer is determined according to the data format of the UDP message, and whether the UDP message is sub-packeted is determined according to the flag. If the UDP message is not sub-packeted, the payload of the transport layer is obtained, and the payload is stored in the cache list in sequence according to the sequence number of the UDP message. If the UDP message is sub-packeted, the payload of the transport layer and the identification number corresponding to the UDP message of the network layer are obtained, and the data is stored in a data dictionary with the identification number as the key value and the value as the flag and the payload. After the storage of the payload is completed, for the UDP message with the same identification number, the value of the next flag of the current flag is determined according to the relationship between the values ​​of the flags corresponding to each UDP message. For example, the value of the next flag = the value of the current flag + the number of bytes of the payload of the current UDP message / 8. After determining the value of each flag, the payload corresponding to the values ​​of two adjacent flags is spliced. After that, the payloads of adjacent identification numbers are spliced, and the spliced ​​payloads are stored in the cache list, and the data in the cache list is parsed to obtain the quotation of each transaction.

[0076] For STEP messages, the payload is spliced ​​according to the sequence number corresponding to each STEP message, the spliced ​​payload is stored in a cache list, and the data in the cache list is parsed to obtain the transaction-by-transaction market information.

[0077] In one possible implementation, for the market data of the Shenzhen Stock Exchange, the data in the cache list is parsed to obtain the transaction-by-transaction market data, specifically including: reading a payload of a preset configuration size from the cache list each time, if the cache length of the read payload is greater than or equal to the length in the message header, and the message type is transaction-by-transaction or step-by-step entrustment, then according to the preset data structure corresponding to the Shenzhen Stock Exchange, the corresponding data is obtained from the payload, and the corresponding data is placed in the list of the transaction-by-transaction queue.

[0078] In one possible implementation, for the market data of the Shanghai Stock Exchange, the data in the cache list is parsed to obtain the transaction data, specifically including: reading a payload of a preset configuration size from the cache list each time, if the cache length of the read payload is greater than or equal to the length in the message header, and the message type is transaction data, then according to the preset data structure corresponding to the Shanghai Stock Exchange, the corresponding data is obtained from the payload, and the corresponding data is placed in the list for writing the transaction queue.

[0079] S103: Matching the transaction-by-transaction market data to obtain first snapshot market data.

[0080] Specifically, according to the data content of each field in the cache list, the corresponding data in the tick-by-tick market data is written into the cache list, and the cache list after writing is completed is the first snapshot market data.

[0081] In a possible implementation, after obtaining the tick-by-tick market information, the electronic device obtains the static file of the exchange, which refers to the basic information file about the transaction subject sent by the exchange to the securities company and the market participants before the opening of each trading day. The static file includes the static file of securities information and the static file of reference information of spot centralized bidding transaction business. The static file of securities information includes the basic information of all securities listed on the exchange except for some special businesses, and the static file of reference information of spot centralized bidding transaction business includes the bidding information of securities.

[0082] After obtaining the static file, the electronic device determines the calculation method of each field in the cache list, reads and calculates the corresponding data from the static file and the quotes according to the calculation method of each field in the cache list, and writes the calculation results into the cache list.

[0083] Specifically, first create a snapshot market data list, determine the structure of the snapshot market data, that is, determine the fields in the snapshot market data list and the calculation method of the fields. Among them, the fields are message sequence number, original message sequence number, transaction time, transaction price, security code source, yesterday's closing price, T-1 day fund net value, buy and sell ten levels, and buy and sell ten levels of entrustment queue. The calculation method of each field can be determined by the order book business. The message sequence number is a user-defined auto-increment sequence number, and the original message sequence number is taken from the message sequence number in the transaction quotation; the transaction time and transaction price are taken from the transaction time and transaction price in the transaction quotation data; the security code source, yesterday's closing price and T-1 day fund net value are taken from the security code source, yesterday's closing price and T-1 day fund net value in the security code information data dictionary; the sources of the ten buy and sell data are the entrustment price, entrustment quantity, transaction quantity, transaction price and buy and sell party entrustment index of the transaction quotation, and the range of the ten buy and sell entrustment prices is determined by the security category, security status, auction limit price parameter, parameter type, whether there is a price increase or decrease limit, base price type, price increase or decrease limit type, increase range, decrease range, increase limit price, decrease limit price, whether there is a valid auction range limit, valid range limit type and valid range. The buying and selling levels of different securities categories have different values. For example, the securities category of the Shenzhen Stock Exchange's main board stocks is 1, the securities category of the Shenzhen Stock Exchange's ChiNext stocks is 3, the securities category of the Shenzhen Stock Exchange's bond stocks is 6, and so on. The buying and selling levels of each securities category have different values.

[0084] After that, create the snapshot basic market data dictionary, buy order data dictionary, and sell order data dictionary. Among them, the snapshot basic market data dictionary is a data dictionary whose key value is the stock code and whose value is the snapshot market data structure. The buy order data dictionary is a data dictionary whose key value is the stock code, whose value is the order number and the order price and order quantity corresponding to the order number. The sell order data dictionary is a data dictionary whose key value is the stock code, whose value is the order number and the order price and order quantity corresponding to the order number.

[0085] Afterwards, create an order sequence number list and an order quantity list, obtain the transaction quotation from the list of the transaction quotation queue, if the transaction quotation obtained is the transaction quotation data, then insert the order sequence number of the transaction quotation data into the order sequence number list, and insert the order quantity into the order quantity list, if the transaction quotation obtained is the transaction quotation data, if the buy and sell order sequence number of the transaction quotation exists in the order sequence number list, then delete the corresponding order sequence number in the order sequence number list, and delete the corresponding data in the order quantity list simultaneously.

[0086] After the creation of each data dictionary and list is completed, the tick-by-tick quotes are read from the list of the tick-by-tick quotes queue. The tick-by-tick quotes include the tick-by-tick transaction quotes data and the tick-by-tick entrustment quotes data. The tick-by-tick entrustment quotes data include the stock code, message record number, channel code, buy and sell direction, order category, entrustment price, entrustment quantity, and entrustment time. The tick-by-tick transaction quotes data include the stock code, channel code, message record number, buyer entrustment index, seller entrustment index, transaction category, transaction price, transaction quantity, and transaction time.

[0087] The static files of securities information and the static files of spot centralized bidding transaction business reference information are lists. Read the securities code, securities code source, English abbreviation, securities category, yesterday's closing price, securities status, par value, T-1 day fund net value, discounted issue price, accrued interest, and pricing party from the static files of securities information. Read the securities code, securities code source, price level, bidding limit parameter, parameter type, whether there is a limit on price increase or decrease, base price type, price limit type, increase range, decrease range, increase limit, decrease limit, whether there is a valid bidding range limit, valid range limit type, and valid range base from the static files of spot centralized bidding transaction business reference information. Put the values ​​corresponding to each field read into the securities code information data dictionary with the securities code as the key and the values ​​including the securities code source, English abbreviation, securities category, yesterday's closing price, securities status, par value, T-1 day fund net value, discounted issue price, price level, auction limit parameter, parameter type, whether there is a limit on price increase or decrease, base price type, increase or decrease limit type, increase range, decrease range, increase limit price, decrease limit price, whether there is a valid auction range limit, valid range limit type, and valid range base.

[0088] After the data is read, the value corresponding to the security code in the list of the transaction queue is obtained in the snapshot basic market data dictionary. If the data dictionary with the key value of the security code does not exist, a new key value with the security code and the value of the snapshot basic market data structure is added to the snapshot basic market data dictionary for the security code. According to the security code information data dictionary, the security code source, yesterday's closing price, and T-1 day fund net value in the value corresponding to the key value of the security code are updated.

[0089] After that, the type of the obtained tick-by-tick market data is determined. If the obtained tick-by-tick market data is the tick-by-tick entrustment market data, the original message sequence number, the ten buy and sell levels, and the entrustment queues of the ten buy and sell levels in the snapshot basic market data dictionary with the key value corresponding to the value of the securities code are updated according to the calculation method of the corresponding field of the snapshot market data, and the key value and the value corresponding to the key value are stored in the market cache list, and then the buy entrustment data dictionary and the sell entrustment data dictionary are updated. If the obtained tick-by-tick market data is the tick-by-tick transaction market data, the original message sequence number, the ten buy and sell levels, the entrustment queues of the ten buy and sell levels, the transaction price, and the transaction time in the snapshot basic market data dictionary with the key value corresponding to the value of the securities code are updated according to the calculation method of the corresponding field of the snapshot market data, and the key value and the value corresponding to the key value are stored in the market cache list, and then the buy entrustment data dictionary and the sell entrustment data dictionary are updated.

[0090] After the data dictionary and each list are updated, a cache list corresponding to the first snapshot market data is established. The fields in the cache list include message sequence number, original message sequence number, transaction time, transaction price, securities code, securities code source, yesterday's closing price, T-1 day fund net value, ten buy and sell levels, and ten buy and sell entrustment queues. According to the fields in the cache list, the corresponding data is obtained from the updated data dictionary and list, and the obtained data is written into the cache list, so that a piece of snapshot market data is obtained by matching a piece of quotation. Among them, the current piece of quotation is the basis for matching the next piece of quotation of the same securities code. If the amount of snapshot market data in the cache list reaches the set value, it is determined that the cache list meets the preset conditions, and the cache list is used as the first snapshot market data. The cache list can be stored as a file in csv format.

[0091] S104: Compare the first snapshot market data with the second snapshot market data pushed by the terminal, and determine a test result of the second snapshot market data according to the comparison result.

[0092] Specifically, the order book runs on the terminal and is used to generate second snapshot market data according to the market data. By comparing the first snapshot market data with the second snapshot market data, the difference between the second snapshot market data and the first snapshot market data is determined, so as to test the second snapshot market data and determine whether the second snapshot market data is comprehensive, thereby determining whether the order book can generate comprehensive snapshot market data.

[0093] In a possible implementation, the first snapshot market data is stored in a first list according to a preset format, and the second snapshot market data is stored in a second list according to a preset format, and the first list and the second list are compared to improve the testing speed of the second snapshot market.

[0094] In one possible implementation, the terminal pushes the second snapshot market data in the format of a UDP message. In order to keep consistent with the second snapshot market data, the electronic device forges the first snapshot market data into a UDP message after generating the first snapshot market data, and then parses the UDP message corresponding to the first snapshot market data and the UDP message corresponding to the second snapshot market data in the same format, and tests the second snapshot market data according to the parsed structure.

[0095] In one embodiment, forging the first snapshot market data into a UDP message includes forging Ethernet, forging the transport layer, and generating a UDP message. Among them, forging Ethernet means obtaining the corresponding Ethernet data based on the configured UDP message. Forging the transport layer requires first determining the data structure of the transport layer, that is, determining the fields in the transport layer, and then writing the corresponding data in the first snapshot market into the transport layer. Among them, the fields in the transport layer include an IP header, a UDP header, and a valid load. Forge the IP header according to the configured source IP address, destination IP address, and UDP header. Forge the UDP header according to the configured source IP port, destination IP port, valid load, and UDP header structure. The key values ​​of the snapshot basic market data dictionary and their corresponding values ​​are transcoded in a fixed format to obtain a valid load. After determining the data corresponding to each field in the transport layer, the Ethernet data and the data of the transport layer are combined into a complete UDP message.

[0096] In the above embodiment, by acquiring the market data of the exchange, parsing the market data, obtaining the transaction-by-transaction market data, matching the transaction-by-transaction market data, and obtaining the first snapshot market data. Therefore, the first snapshot market data is more comprehensive snapshot market data. Then, the first snapshot market data is compared with the second snapshot market data pushed by the terminal, and the test result of the second snapshot market data is determined according to the comparison result. Among them, the order book runs on the terminal, and the second snapshot market data pushed by the terminal is the snapshot market data generated by the order book. Since the second snapshot market data is tested with more comprehensive snapshot market data, the accuracy of the test is improved.

[0097] In one possible implementation, the test method for snapshot market data provided in the embodiment of the present application is implemented by executing multiple scripts. Specifically, the scripts run in the embodiment of the present application include python scripts and shell scripts. The python script includes a parsing and matching script and a data comparison script. The parsing and matching script is used to parse the market data, obtain the quotation by quotation, match the quotation by quotation, and obtain the first snapshot market data, that is, execute the above steps S101 to S103. In one embodiment, the parsing and matching script is also used to forge UDP messages. The data comparison script is used to compare the first snapshot market data and the second snapshot market data, that is, execute the above step S104. The shell script is used to call the python script to test the second snapshot market data. The electronic device also runs a gitlab code maintenance and management module, which is used to store the python script and the shell script in gitlab, perform version maintenance on the python script and the shell script, and facilitate subsequent iterative modifications.

[0098] In one possible implementation, Figure 2 As shown, the test method for snapshot market data provided in the embodiment of the present application is applied to a test system, and the test system includes a sending end 21, a terminal 22 and a receiving end 23. The market data is pushed by the sending end 21, and the sending end 21 can be a market gateway. The market system and hardware for running the order book are installed on the terminal 22. Among them, the hardware can be a field programmable gate array (FPGA, Field Programmable Gate Array). The sending end 21 is used to send market data to the market system and hardware. The sending end 21 is also used to send static files to the market system, and then the market system sends the static files to the hardware. Run the order book on the hardware to generate the second snapshot market data. The receiving end 23 is used to receive the second snapshot market data. The python script runs on the receiving end 23, and can also run on other electronic devices that communicate with the terminal 22 and the receiving end 23, and is used to generate the first snapshot market data and test the second snapshot market data.

[0099] Specifically, after running the shell script, the market system obtains the static file of the exchange from the sending port of the sending end 21 and sends the static file to the hardware. The order book running on the hardware reads data from the static file, and after obtaining the market data of the exchange through the market system, the second snapshot market data is obtained by matching the market data and the data read from the static file, and then a UDP data packet is generated according to the second snapshot market data, and the UDP data packet is multicast through the receiving port of the receiving end 23. After the receiving end 23 obtains the UDP data packet through the receiving port, it is parsed into a file in a preset format. After that, the python script is run to obtain the first snapshot market, and the file is compared with the file corresponding to the first snapshot market to obtain the test result of the second snapshot market data.

[0100] In a possible implementation, before executing the shell script, it is necessary to configure the operating parameters of the terminal so that the terminal parses the received market data in a set manner to obtain the second snapshot market data, thereby improving the testing efficiency of the hardware on the terminal.

[0101] Specifically, the operating parameters of the terminal include the target address of the IP layer of the data packet, the source address of the IP layer of the data packet, the target port of the TCP layer of the data packet, the source port of the TCP layer of the data packet, and the directory where the hardware script is located. After completing the configuration of each operating parameter, the shell script is executed according to the configuration items of each operating parameter. Specifically, the configuration items of each operating parameter modify the hardware reset script, and execute the hardware reset script, so that the hardware on the terminal only parses the target address, source address, target port, source port and the written target address, source address, target port, source port. The consistent message. In one embodiment, after executing the reset script, the message information in the hardware cache is cleared to avoid interference with the test results caused by historical data.

[0102] like Figure 3 As shown, in a possible implementation, before executing the shell script, in addition to configuring the terminal's operating parameters, it is also necessary to configure the parameters of the sender and the receiver. After completing the configuration items of each parameter, execute the shell script. Among them, the parameters of the sender include the sending port, the receiving port, the directory where the data packet is located, the directory where the market system is located, and the directory where the static file is located. The parameters of the receiving end include the directory where the receiving end is located, the target address of the IP layer of the forged UDP, the source address of the IP layer of the forged UDP, the target port of the TCP layer of the forged UDP, the source port of the TCP layer of the forged UDP, the maximum transmission unit (MTU) length of the sending port, and the directory where the python script is located.

[0103] like Figure 3As shown in the figure, after completing the configuration of each parameter, the process of executing the shell script is as follows: according to the configuration item of the directory where the python script is located, the latest python script can be obtained; according to the configuration item of the directory where the static file is located, the static file date can be modified to the current date; according to the configuration item of the sending port MTU length, the MTU length of the sending port can be modified, so that the messages in the UDP data packet generated by the hardware can be played back.

[0104] According to the configuration items corresponding to the directory where the market system is located, the directory where the static files are located, and the playback port, the market system configuration can be modified, and the historical logs of the market system can be deleted. Among them, modifying the market system configuration specifically refers to modifying the static file address and the sending port IP of the market system. After that, start the market system. After the market system is started, the static file is read from the market gateway and the information in the static file is written to the hardware. At the same time, the shell script determines whether the market system has been started according to the log file newly added to the market system. If it is detected that the log file is written with "exanic_acquire_handlesuccess" or "FPGA initialization successful" related logs, it means that the market system has been started. After the market system is started, it is determined whether the receiving end has been successfully started. Otherwise, it means that the market system has not been successfully started, and the newly added log file of the market system is re-detected.

[0105] The receiving end log can be deleted according to the configuration items of the directory where the receiving end is located. After deleting the receiving end log, start the receiving end. After obtaining the return information of the successful start of the receiving end, determine that the receiving end has been successfully started. After the receiving end is successfully started, according to the configuration items of the directory where the python script is located and the directory where the data packet is located, modify the data packet directory in the python script and execute the parsing and matching script in the python script. If the return information of the successful start of the receiving end is not obtained, re-check whether the return message of the successful start is received.

[0106] While executing the parsing and matching script in the Python script, the data packet is replayed at the sending port according to the configuration items of the sending port and the directory where the data packet is located.

[0107] After that, according to the configuration items in the directory where the hardware script is located, the hardware configuration script is executed to read the values ​​of each hardware register, and the hardware is judged whether the analysis is normal according to the export data value of the hardware register. If the export data value of the hardware register is zero, it is determined that the hardware analysis is abnormal. According to the market system name, the name of the receiving end, the parsing and matching script name, and the playback data packet name, each process on the terminal is closed in turn, and the execution is restarted from the execution of the hardware reset script. If the export data value of the hardware register is not zero, it is determined that the hardware analysis is normal. According to the playback data packet name and the parsing and matching script name, the playback data packet process and the parsing and matching process are monitored every 5 seconds. If the playback data packet process and the parsing and matching process do not exist, the data comparison script in the python script is run, and the comparison results are written to the file of the receiving end.

[0108] In a possible implementation, if it is detected that the terminal interrupts the information of pushing the second snapshot market data, the forged UDP message is stored in the terminal, so that the next time the script is run, the stored UDP message can be directly used without repeating the previous steps to improve the parsing and matching efficiency. Specifically, the market data received by the market system is the market data of the exchange for a whole day. When obtaining the data packet corresponding to the market data, if an instruction to interrupt the broadcast packet (that is, the terminal interrupts the push of the data packet corresponding to the second snapshot market data) is detected, the shell script stops playing back the data packet according to the name of the playback data packet. At the same time, the UDP data packet forged by the parsing and matching script in the python script is written to the register of the hardware. After determining that the UDP data packet is written to the register of the hardware, the shell script continues to play back the data packet at the sending port according to the sending port and the directory where the data packet is located in the configuration item. If the interrupt instruction is not detected, the shell script continues to monitor whether the playback data packet process and the parsing and matching process exist.

[0109] It should be understood that the size of the serial numbers of the steps in the above embodiments does not mean the order of execution. The execution order of each process should be determined by its function and internal logic, and should not constitute any limitation on the implementation process of the embodiments of the present application.

[0110] Corresponding to the testing method of snapshot market data described in the above embodiment, Figure 4 A structural block diagram of a testing device for snapshot market data provided in an embodiment of the present application is shown. For ease of explanation, only the parts related to the embodiment of the present application are shown.

[0111] like Figure 4 As shown, the test device for snapshot market data includes:

[0112] The acquisition module 41 is used to obtain the market data of the exchange;

[0113] The parsing module 42 is used to parse the market data to obtain the market information;

[0114] A matching module 43 is used to match the transaction-by-transaction market conditions to obtain first snapshot market data;

[0115] The comparison module 44 is used to compare the first snapshot market data with the second snapshot market data pushed by the terminal, and determine the test result of the second snapshot market data according to the comparison result.

[0116] In a possible implementation, the comparison module 44 is specifically used for:

[0117] The first snapshot market data is stored in a first list according to a preset format, the second snapshot market data is stored in a second list according to the preset format, and the first list is compared with the second list.

[0118] In a possible implementation, the terminal pushes the second snapshot market data in the format of a UDP message, and the matching module 43 is further used to:

[0119] The first snapshot market data is forged into a UDP message.

[0120] In a possible implementation, the matching module 43 is further used for:

[0121] If it is detected that the terminal interrupts the information of pushing the second snapshot market data, the forged UDP message is stored in the terminal.

[0122] In a possible implementation, the comparison module 44 is specifically used for:

[0123] The operating parameters of the terminal are configured so that the terminal parses the received market data according to a set method to obtain the second snapshot market data.

[0124] In a possible implementation, the parsing module 42 is specifically used for:

[0125] Extracting valid data from the market data;

[0126] Splicing the valid data to obtain spliced ​​data;

[0127] The spliced ​​data is analyzed to obtain the transaction-by-transaction market information.

[0128] In a possible implementation, the matching module 43 is specifically used for:

[0129] Get the static files of the exchange;

[0130] Determine the calculation method for each field in the cache list;

[0131] According to the calculation method of each field in the cache list, read the corresponding data from the static file and the tick-by-tick market information and perform calculations, and write the calculation results into the cache list;

[0132] The cache list that records the preset conditions is used as the first snapshot market data.

[0133] It should be noted that the information interaction, execution process, etc. between the above-mentioned devices / units are based on the same concept as the method embodiment of the present application. Their specific functions and technical effects can be found in the method embodiment part and will not be repeated here.

[0134] Figure 5 It is a schematic diagram of the structure of an electronic device provided in an embodiment of the present application.

[0135] like Figure 5 As shown, the electronic device of this embodiment includes: a processor 51, a memory 52, and a computer program 53 stored in the memory 52 and executable on the processor 51. When the processor 51 executes the computer program 53, the steps in the above-mentioned snapshot market data testing method embodiment are implemented, such as Figure 1 Alternatively, when the processor 51 executes the computer program 53, the functions of each module / unit in the above-mentioned device embodiments are realized, for example Figure 4 The functions of the acquisition module 41 to the comparison module 44 are shown.

[0136] Exemplarily, the computer program 53 may be divided into one or more modules / units, which are stored in the memory 52 and executed by the processor 51 to complete the present application. The one or more modules / units may be a series of computer program instruction segments capable of completing specific functions, which are used to describe the execution process of the computer program 53 in the electronic device.

[0137] Those skilled in the art will understand that Figure 5 These are merely examples of electronic devices and do not constitute a limitation of the electronic device. The electronic device may include more or fewer components than those shown in the figure, or a combination of certain components, or different components. For example, the electronic device may also include input and output devices, network access devices, buses, etc.

[0138] The processor 51 may be a central processing unit (CPU), or other general-purpose processors, digital signal processors (DSP), application-specific integrated circuits (ASIC), field-programmable gate arrays (FPGA) or other programmable logic devices, discrete gate or transistor logic devices, discrete hardware components, etc. A general-purpose processor may be a microprocessor or any conventional processor, etc.

[0139] The memory 52 may be an internal storage unit of the electronic device, such as a hard disk or memory of the electronic device. The memory 52 may also be an external storage device of the electronic device, such as a plug-in hard disk, a smart media card (SMC), a secure digital (SD) card, a flash card, etc. equipped on the electronic device. Further, the memory 52 may also include both an internal storage unit and an external storage device of the electronic device. The memory 52 is used to store the computer program and other programs and data required by the electronic device. The memory 52 may also be used to temporarily store data that has been output or is to be output.

[0140] The technicians in the relevant field can clearly understand that for the convenience and simplicity of description, only the division of the above-mentioned functional units and modules is used as an example for illustration. In practical applications, the above-mentioned function allocation can be completed by different functional units and modules as needed, that is, the internal structure of the device can be divided into different functional units or modules to complete all or part of the functions described above. The functional units and modules in the embodiment can be integrated in a processing unit, or each unit can exist physically separately, or two or more units can be integrated in one unit. The above-mentioned integrated unit can be implemented in the form of hardware or in the form of software functional units. In addition, the specific names of the functional units and modules are only for the convenience of distinguishing each other, and are not used to limit the scope of protection of this application. The specific working process of the units and modules in the above-mentioned system can refer to the corresponding process in the aforementioned method embodiment, which will not be repeated here.

[0141] The units described as separate components may or may not be physically separated, and the components shown as units may or may not be physical units, that is, they may be located in one place or distributed on multiple network units. Some or all of the units may be selected according to actual needs to achieve the purpose of the solution of this embodiment.

[0142] If the integrated module / unit is implemented in the form of a software functional unit and sold or used as an independent product, it can be stored in a computer-readable storage medium. Based on this understanding, the present application implements all or part of the processes in the above-mentioned embodiment method, and can also be completed by instructing the relevant hardware through a computer program. The computer program can be stored in a computer-readable storage medium, and the computer program can implement the steps of the above-mentioned various method embodiments when executed by the processor. Among them, the computer program includes computer program code, and the computer program code can be in source code form, object code form, executable file or some intermediate form. The computer-readable medium may include: any entity or device capable of carrying the computer program code, recording medium, U disk, mobile hard disk, disk, optical disk, computer memory, read-only memory (ROM, Read-Only Memory), random access memory (RAM, Random Access Memory), electrical carrier signal, telecommunication signal and software distribution medium, etc.

[0143] Those of ordinary skill in the art will appreciate that the units and algorithm steps of each example described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, or a combination of computer software and electronic hardware. Whether these functions are performed in hardware or software depends on the specific application and design constraints of the technical solution. Professional and technical personnel can use different methods to implement the described functions for each specific application, but such implementation should not be considered to be beyond the scope of this application.

[0144] The embodiments described above are only used to illustrate the technical solutions of the present application, rather than to limit them. Although the present application has been described in detail with reference to the aforementioned embodiments, a person skilled in the art should understand that the technical solutions described in the aforementioned embodiments may still be modified, or some of the technical features may be replaced by equivalents. Such modifications or replacements do not deviate the essence of the corresponding technical solutions from the spirit and scope of the technical solutions of the embodiments of the present application, and should all be included in the protection scope of the present application.

Claims

1. A method for testing snapshot market data, characterized in that: include: Get market data from the exchange; Analyze the market data to obtain transaction-by-transaction market information; Matching the transaction-by-transaction market data to obtain the first snapshot market data; comparing the first snapshot market data with the second snapshot market data pushed by the terminal, and determining a test result of the second snapshot market data according to the comparison result; The matching of the transaction-by-transaction market data to obtain the first snapshot market data includes: Get the static files of the exchange; Determine the calculation method for each field in the cache list; According to the calculation method of each field in the cache list, the corresponding data is read from the static file and the tick-by-tick market data, and the calculation is performed, and the calculation result is written into the cache list; wherein the cache list is a list created to store the first snapshot market data; the fields in the cache list include message sequence number, original message sequence number, transaction time, transaction price, securities code, securities code source, yesterday's closing price, T-1 day fund net value, ten buy and sell levels, and ten buy and sell level entrustment queues; The cache list that records satisfying preset conditions is used as the first snapshot market data; wherein the record is used to characterize the amount of snapshot market data in the cache list.

2. The method for testing snapshot market data according to claim 1, characterized in that: Comparing the first snapshot market data with the second snapshot market data pushed by the terminal includes: The first snapshot market data is stored in a first list according to a preset format, the second snapshot market data is stored in a second list according to the preset format, and the first list is compared with the second list.

3. The method for testing snapshot market data according to claim 1, characterized in that: The terminal pushes the second snapshot market data in the format of a UDP message. After obtaining the first snapshot market data, the method further includes: The first snapshot market data is forged into a UDP message.

4. The method for testing snapshot market data according to claim 3, characterized in that: After forging the first snapshot market data into a UDP message, the method further includes: If it is detected that the terminal interrupts the information of pushing the second snapshot market data, the forged UDP message is stored in the terminal.

5. The method for testing snapshot market data according to claim 1, characterized in that: Before comparing the first snapshot market data with the second snapshot market data pushed by the terminal, the method further includes: The operating parameters of the terminal are configured so that the terminal parses the received market data according to a set method to obtain the second snapshot market data.

6. The method for testing snapshot market data according to claim 1, characterized in that: The market data is parsed to obtain the transaction-by-transaction market data, including: Extracting valid data from the market data; Splicing the valid data to obtain spliced ​​data; The spliced ​​data is analyzed to obtain the transaction-by-transaction market information.

7. A testing device for snapshot market data, characterized in that: include: Acquisition module, used to obtain market data from the exchange; An analysis module is used to analyze the market data to obtain transaction-by-transaction market information; A matching module, used for matching the transaction-by-transaction market data to obtain first snapshot market data; a comparison module, configured to compare the first snapshot market data with the second snapshot market data pushed by the terminal, and determine a test result of the second snapshot market data according to the comparison result; The matching module is specifically used for: Get the static files of the exchange; Determine the calculation method for each field in the cache list; According to the calculation method of each field in the cache list, the corresponding data is read from the static file and the tick-by-tick market data, and the calculation is performed, and the calculation result is written into the cache list; wherein the cache list is a list created to store the first snapshot market data; the fields in the cache list include message sequence number, original message sequence number, transaction time, transaction price, securities code, securities code source, yesterday's closing price, T-1 day fund net value, ten buy and sell levels, and ten buy and sell level entrustment queues; The cache list that records satisfying preset conditions is used as the first snapshot market data; wherein the record is used to characterize the amount of snapshot market data in the cache list.

8. An electronic device comprising a memory, a processor, and a computer program stored in the memory and executable on the processor, characterized in that: When the processor executes the computer program, the method for testing snapshot market data according to any one of claims 1 to 6 is implemented.

9. A computer-readable storage medium storing a computer program, characterized in that: When the computer program is executed by a processor, the method for testing snapshot market data according to any one of claims 1 to 6 is implemented.