Transaction algorithm backtesting method, device and storage medium

By generating transaction data using order book data and analyzing transaction operations, the problem of inaccurate backtesting of transaction algorithms in existing technologies is solved, achieving higher backtesting accuracy.

CN115564586BActive Publication Date: 2026-04-14SHENZHEN LEHIGH HONGKING TECH CO LTD
View PDF 1 Cites 0 Cited by

Patent Information

Authority / Receiving Office
CN · China
Patent Type
Patents(China)
Current Assignee / Owner
Filing Date
2022-09-28
Publication Date
2026-04-14

AI Technical Summary

Technical Problem

When using Bar data, existing backtesting methods for trading algorithms cannot accurately reproduce real-time trading information, resulting in inaccurate backtesting results.

Method used

Transaction data is generated using the first and second order books. Orders and transaction operations are analyzed using transaction algorithms. Transaction results are determined based on the order book data, thereby improving data accuracy.

Benefits of technology

By using order book data from multiple time points, including detailed information such as buy and ask prices, the discrepancy between backtesting results and live trading is reduced, improving the accuracy of trading algorithm backtesting.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN115564586B_ABST
    Figure CN115564586B_ABST
Patent Text Reader

Abstract

The application discloses a kind of transaction algorithm backtest method, transaction algorithm backtest equipment and storage medium, belong to financial technology field.Therein, the method includes: obtaining first order book, second order book and transaction algorithm, according to the first order book generation first transaction data;The first order book and the second order book are generated for adjacent time;According to the transaction algorithm analysis first transaction data, obtain first order and corresponding first transaction operation;According to the second order book and the first order book determine the transaction result of the first order, the transaction result includes whether the first transaction operation has been completed;According to the first order and the transaction result determine the backtest result of the transaction algorithm.The application realizes the accuracy of improving transaction algorithm backtest.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] This invention relates to the field of financial technology, and in particular to a backtesting method, backtesting equipment, and storage medium for trading algorithms. Background Technology

[0002] With the development of financial markets, a large number of quantitative trading algorithm strategies have emerged. Before using a trading algorithm, it is necessary to backtest it to determine its effectiveness. Currently, backtesting methods only support data from US bar charts (Bar). Since Bar data only includes price information and total trading volume within that period, it cannot accurately reproduce the information from live trading. This results in significant differences between backtesting and live trading data, leading to inaccurate backtesting results for trading algorithms.

[0003] The above content is only used to help understand the technical solution of the present invention and does not represent an admission that the above content is prior art. Summary of the Invention

[0004] The main objective of this invention is to provide a backtesting method, a backtesting device, and a storage medium for trading algorithms, aiming to improve the accuracy of backtesting trading algorithms.

[0005] To achieve the above objectives, the present invention provides a backtesting method for trading algorithms, the backtesting method comprising the following steps:

[0006] Obtain the first order book, the second order book, and the transaction algorithm; generate the first transaction data based on the first order book; the first order book and the second order book are generated at adjacent times.

[0007] The transaction data is analyzed according to the transaction algorithm to obtain the first order and the corresponding first transaction operation;

[0008] The transaction result of the first order is determined based on the second order book and the first order book, wherein the transaction result includes whether the first transaction operation has been completed;

[0009] The backtesting results of the transaction algorithm are determined based on the first order and the transaction results.

[0010] Optionally, the step of determining the transaction result of the first order based on the second order book includes:

[0011] Determine whether there is a second order that completes a transaction with the first order based on the second order book and the first order book;

[0012] When the second order exists, the transaction result of the first order is determined to be completed;

[0013] If the second order does not exist, the transaction result of the first order is determined to be incomplete.

[0014] Optionally, the step of determining whether there is a second order that completes a transaction with the first order based on the second order book and the first order book includes:

[0015] The order in the second order book that differs from the first order book is identified as the third order, and the data difference characteristics of the third order in the first order book and the second order book are determined.

[0016] Update the first transaction data based on the data difference characteristics and the third order;

[0017] According to the matching transaction principle, the orders in the first transaction data and the first order are matched and executed, and the results of the matching and execution are used to determine whether there is a second order that has completed the transaction with the first order.

[0018] Optionally, after the step of analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes:

[0019] Calculate the first liquidity based on the first transaction operation and the first transaction data, and determine the second liquidity required when the first transaction operation is executed;

[0020] When the ratio of the first liquidity to the second liquidity is greater than a preset ratio, the transaction result of the first order is determined to be the completion of the first transaction operation, and the backtesting result of the transaction algorithm is determined based on the first order and the transaction result.

[0021] When the ratio is less than or equal to the preset ratio, the transaction result of the first order is determined based on the second order book and the first order book. The transaction result includes the step of determining whether the first transaction operation has been completed.

[0022] Optionally, the step of calculating the first liquidity based on the first transaction operation and the first transaction data includes:

[0023] The target trading price range is determined based on the target trading price, trading direction, and preset fluctuation range of the first trading operation, wherein the trading direction includes buying or selling.

[0024] The target order is defined as an order whose transaction price is within the target transaction price range and whose transaction direction is opposite to that of the target transaction price.

[0025] The total number of the target orders is determined as the first liquidity.

[0026] Optionally, after the step of analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes:

[0027] Update the first transaction data according to the first transaction operation and the first order;

[0028] After the step of determining the transaction result of the first order based on the second order book and the first order book, the method further includes:

[0029] Determine the second order book as the new first order book, and obtain the third order book generated at the next moment as the new second order book;

[0030] Return to the step of analyzing the first transaction data according to the transaction algorithm and generating the first transaction operation.

[0031] Optionally, the step of updating the first transaction data according to the first transaction operation and the first order includes:

[0032] When the first transaction operation is a cancellation operation, the first order is deleted from the first transaction data;

[0033] When the first transaction operation is an order placement operation, the first order is added to the first transaction data.

[0034] Optionally, the step of determining the backtesting result of the transaction algorithm based on the first order and the transaction result includes:

[0035] When the transaction result is completed, calculate the first price ratio between the price of the first order and the average transaction price of the first transaction data, and use the first price ratio as the backtesting result;

[0036] When the transaction result is incomplete, calculate multiple first price differences between the price of the first order and multiple transaction prices of the first transaction data, and take the minimum value among the multiple first price differences as the backtest result.

[0037] In addition, to achieve the above objectives, the present invention also provides a trading algorithm backtesting device, the trading algorithm backtesting device comprising: a memory, a processor, and a trading algorithm backtesting program stored in the memory and executable on the processor, the trading algorithm backtesting program being configured to implement the steps of the trading algorithm backtesting method described in any of the above claims.

[0038] In addition, to achieve the above objectives, the present invention also provides a storage medium storing a transaction algorithm backtesting program, wherein the transaction algorithm backtesting program, when executed by a processor, implements the steps of the transaction algorithm backtesting method described in any of the above claims.

[0039] This invention proposes a backtesting method for a trading algorithm. The method includes: acquiring a first order book, a second order book, and a trading algorithm; generating first trading data based on the first order book; the first and second order books being generated at adjacent time points; analyzing the first trading data according to the trading algorithm to obtain a first order and its corresponding first trading operation; determining the trading result of the first order based on the second order book, the trading result including whether the first trading operation has been completed; and determining the backtesting result of the trading algorithm based on the first order and the trading result. Compared to existing backtesting methods using bar data, this application uses order book data from multiple time points, including not only price data but also data such as buy volume and ask volume, i.e., the quantity of buy orders and the size of sell orders for financial products. The data volume is large, and it includes detailed transaction data. The trading algorithm analyzes and performs trading operations based on order book data with the same data type as the order book data in live trading, resulting in more accurate data. This reduces the problem of large deviations in backtesting results due to inaccurate backtesting data. Furthermore, the backtesting result is determined based on the first order and the trading result, thereby improving the accuracy of the trading algorithm backtesting. Attached Figure Description

[0040] Figure 1 This is a schematic diagram of the hardware operating environment involved in an embodiment of the transaction algorithm backtesting device of the present invention;

[0041] Figure 2 This is a flowchart illustrating the first embodiment of the backtesting method for the trading algorithm of the present invention;

[0042] Figure 3 This is a flowchart illustrating the second embodiment of the backtesting method for the trading algorithm of the present invention;

[0043] Figure 4 This is a flowchart illustrating the third embodiment of the backtesting method for the trading algorithm of the present invention;

[0044] Figure 5 This is a flowchart illustrating the fourth embodiment of the backtesting method for the trading algorithm of the present invention;

[0045] Figure 6 This is a flowchart illustrating the fifth embodiment of the backtesting method for the trading algorithm of the present invention;

[0046] The realization of the objective, functional features and advantages of the present invention will be further explained in conjunction with the embodiments and with reference to the accompanying drawings. Detailed Implementation

[0047] It should be understood that the specific embodiments described herein are merely illustrative of the invention and are not intended to limit the invention.

[0048] Reference Figure 1 , Figure 1 This is a schematic diagram of the transaction algorithm backtesting device structure in the hardware operating environment involved in the embodiments of the present invention.

[0049] like Figure 1 As shown, the backtesting device for the transaction algorithm may include: a processor 1001, such as a central processing unit (CPU), a communication bus 1002, an interaction module 1003, a network interface 1004, and a memory 1005. The communication bus 1002 is used to enable communication between these components. The interaction module 1003 may include a display screen and an input unit such as a keyboard. Optionally, the interaction module 1003 may also include a standard wired interface or a wireless interface connected to the communication bus 1002. The network interface 1004 may optionally include a standard wired interface or a wireless interface (such as a Wi-Fi interface). The memory 1005 may be a high-speed random access memory (RAM) or a stable non-volatile memory (NVM), such as a disk drive. Optionally, the memory 1005 may also be a storage device independent of the aforementioned processor 1001.

[0050] Those skilled in the art will understand that Figure 1 The structure shown does not constitute a limitation on the backtesting device for the trading algorithm, and may include more or fewer components than shown, or combine certain components, or have different component arrangements.

[0051] like Figure 1 As shown, the memory 1005, which serves as a storage medium, may include an operating system, a data storage module, a network communication module, a user interface module, and a transaction algorithm backtesting program.

[0052] exist Figure 1 In the transaction algorithm backtesting device shown, the network interface 1004 is mainly used for data communication with other devices; the interaction module 1003 is mainly used for data interaction with the user; the processor 1001 and memory 1005 in the transaction algorithm backtesting device of the present invention can be set in the transaction algorithm backtesting device, and the transaction algorithm backtesting device calls the transaction algorithm backtesting program stored in the memory 1005 through the processor 1001 and executes the transaction algorithm backtesting method provided in the embodiment of the present invention.

[0053] This invention provides a backtesting method for trading algorithms, referring to... Figure 2 , Figure 2This is a flowchart illustrating the first embodiment of a backtesting method for a trading algorithm according to the present invention.

[0054] In this embodiment, the transaction algorithm backtesting method includes:

[0055] Step S10: Obtain the first order book, the second order book, and the transaction algorithm; generate first transaction data based on the first order book; the first order book and the second order book are generated at adjacent times.

[0056] The first and second order books here refer to Level-2 market data, including ten levels of price quotes, buy and sell queues, tick-by-tick trades, total order volume, and weighted average price. Orders at various prices and their corresponding quantities are generated based on the first order book. The second order book, adjacent to the first order book, can be obtained based on the order book data update frequency.

[0057] Step S20: Analyze the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation;

[0058] The trading algorithm can be either a passive or active trading algorithm. The trading algorithm performs the first trading operation based on the first trading data. Here, the first order can be a limit order, a market order, or a canceled order. The first order can be a buy order or a sell order, and is determined according to the trading algorithm.

[0059] Step S30: Determine the transaction result of the first order based on the second order book and the first order book, wherein the transaction result includes whether the first transaction operation has been completed;

[0060] The second order book here contains transaction data from adjacent time points, which can determine whether a transaction has been completed.

[0061] Step S40: Determine the backtesting result of the transaction algorithm based on the first order and the transaction result.

[0062] The metrics of the transaction algorithm can be determined based on the data corresponding to the first order and the transaction result, and the metrics can be used as the backtesting results of the transaction algorithm.

[0063] In this embodiment, compared to existing backtesting methods using Bar data, this application uses order book data from multiple time points. In addition to price data, it also includes data such as buy volume and ask volume, i.e., the quantity of buy prices and the size of sell prices for financial products. The data volume is large and has transaction details. The trading algorithm analyzes and operates based on order book data, and the data type is the same as that of the order book in live trading. The data is more accurate, thereby reducing the problem of large deviations in backtesting results due to inaccurate backtesting data. The backtesting result is determined based on the first order and the transaction result, thereby improving the accuracy of the trading algorithm backtesting.

[0064] Furthermore, based on the first embodiment, a second embodiment of the backtesting of the trading algorithm of the present invention is proposed. In this embodiment, reference is made to... Figure 3 The step of determining the transaction result of the first order based on the second order book includes:

[0065] Step S31: Determine whether there is a second order that has completed a transaction with the first order based on the second order book and the first order book;

[0066] The second order here refers to an order in the first transaction data that has the opposite trading direction to the first order and the same price. If the first order is a sell order, the second order is a buy order; if the first order is a buy order, the second order is a sell order.

[0067] Step S32: When the second order exists, determine that the transaction result of the first order is completed;

[0068] The transaction result here refers to whether the first order has been successfully executed.

[0069] Step S33: If the second order does not exist, determine that the transaction result of the first order is incomplete.

[0070] Specifically, in this embodiment, the transaction result of the first order is determined based on whether it is stored in the second order. In other embodiments, the transaction result of the first order can be determined based on the transaction data.

[0071] Furthermore, based on the second embodiment, a fourth embodiment of the trading algorithm backtesting of the present invention is proposed. In this embodiment, reference is made to... Figure 4 The step of determining whether there exists a second order that completes a transaction with the first order based on the second order book and the first order book includes:

[0072] Step S311: Determine the order in the second order book that differs from the first order book as the third order, and identify the data difference characteristics of the third order in the first order book and the second order book;

[0073] The difference orders here refer to the orders added or removed from the second order book compared to the first order book, wherein the reduced orders can be determined based on the transaction data as to whether they are withdrawn orders.

[0074] Step S312: Update the first transaction data according to the data difference characteristics and the third order;

[0075] When the second order book contains an order that is not included in the first order book, the order is designated as the third order and added to the first transaction data; when the first order book contains an order that is not included in the second order book, the order is designated as the third order, and the third order is determined to be either a completed order or a withdrawn order based on the transaction data. When the third order is a withdrawn order, the withdrawn order is deleted from the first transaction data.

[0076] Step S313: Match the orders in the first transaction data with the first order according to the matching transaction principle, and determine whether there is a second order that has completed a transaction with the first order based on the matching transaction result.

[0077] The matching principle here refers to a transaction method in which the transaction price between the two parties is determined according to the principle of price priority and time priority, a transaction contract is generated, and delivery is carried out according to the transaction order.

[0078] The matching result here can be the completion of transactions between multiple orders, or no transactions may be completed. For example, when a stock hits its daily limit down, due to the lack of buy orders, transactions cannot be completed because sellers need to agree on a transaction price. The matching result can determine whether a second order exists. In other embodiments, the existence of a second order that completes a transaction with the first order is determined by obtaining the number of orders with the same price as the first order from the transaction data.

[0079] In this embodiment, the process of order changes during live trading is simulated by adding a third order to the first transaction data or deleting a third order from the first transaction data. The existence of a second order is determined by the matching transaction results, thus improving the backtesting results of the trading algorithm.

[0080] Furthermore, based on any of the above embodiments, a fourth embodiment of the trading algorithm backtesting of the present invention is proposed. In this embodiment, reference is made to... Figure 5 After the step of analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes:

[0081] Step S21: Calculate the first liquidity based on the first transaction operation and the first transaction data, and determine the second liquidity required when the first transaction operation is executed;

[0082] The initial liquidity here is determined by the aforementioned trading operations and the first transaction. For example, if the first trading operation buys 10 shares at a unit price of 100, the initial liquidity is determined based on the number of sell orders. Alternatively, the initial liquidity can be determined by the number of the first order.

[0083] Step S22: When the ratio of the first liquidity to the second liquidity is greater than a preset ratio, the transaction result of the first order is determined to be the completion of the first transaction operation, and the backtesting result of the transaction algorithm is determined based on the first order and the transaction result.

[0084] Specifically, in this embodiment, the preset ratio is five. When the first liquidity is 10 and the second liquidity is 1, the transaction result of the first order is determined to be completed, and the backtesting result of the transaction algorithm is determined based on the first order and the transaction result.

[0085] Step S23: When the ratio is less than or equal to the preset ratio, perform the step of determining the transaction result of the first order based on the second order book and the first order book, wherein the transaction result includes whether the first transaction operation has been completed;

[0086] Specifically, when the first liquidity is 20 and the second liquidity is 5, the step of adding the corresponding first order to the first transaction data according to the first transaction operation is determined.

[0087] In this embodiment, by calculating the ratio of the first liquidity and the second liquidity, it is determined whether the first order can be directly considered as completed, reflecting the impact of different first transaction operations on the market. When the first liquidity is high and the second liquidity is low, the backtesting steps are reduced and the efficiency of backtesting is improved.

[0088] Furthermore, the calculation of the first liquidity based on the first transaction operation and the first transaction data includes the following steps:

[0089] The target trading price range is determined based on the target trading price, trading direction, and preset fluctuation range of the first trading operation, wherein the trading direction includes buying or selling.

[0090] The target order is defined as an order whose transaction price is within the target transaction price range and whose transaction direction is opposite to that of the target transaction price.

[0091] The total number of the target orders is determined as the first liquidity.

[0092] The total number of target orders here refers to the total number of orders placed for multiple target orders. When the first order is a limit order, the target transaction price here can refer to the price of the first order; when the first order is a market order, the target transaction price here can be the current market price. The preset fluctuation range refers to the maximum possible deviation of the price centered on the target transaction price. Specifically, in this embodiment, the target transaction price is 10, the preset fluctuation range is 3, and the target transaction price range is determined to be [7, 13]. In other embodiments, the sum of the number of orders based on the target transaction price is used as the first liquidity.

[0093] In this embodiment, by setting a target trading price range, the accuracy of the data for calculating the first liquidity is improved, thereby improving the accuracy of the backtesting results.

[0094] Furthermore, based on any of the above embodiments, a fifth embodiment of the trading algorithm backtesting of the present invention is proposed. In this embodiment, reference is made to... Figure 6 After analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes:

[0095] Step S24: Update the first transaction data according to the first transaction operation and the first order.

[0096] Step S30, followed by:

[0097] Step S34: Determine that the second order book is the new first order book, and obtain the third order book generated at the next moment as the new second order book;

[0098] Specifically, in this embodiment, after the first order is added to the first transaction data, the first transaction data is updated. After the step of determining the transaction result of the first order according to the second order book, the process returns to the step of analyzing the first transaction data according to the transaction algorithm and generating the first transaction operation, thus generating multiple first orders and multiple first transaction operations.

[0099] In this embodiment, after the step of determining the transaction result of the first order based on the second order book, the step of returning to the step of analyzing the first transaction data and generating the first transaction operation based on the transaction algorithm is executed. This allows the transaction algorithm to perform the first transaction operation multiple times based on multiple order books, thereby reducing the difference between backtesting results and live trading results.

[0100] Furthermore, the step of updating the first transaction data based on the first transaction operation and the first order includes:

[0101] When the first transaction operation is a cancellation operation, the first order is deleted from the first transaction data;

[0102] When the first transaction operation is an order placement operation, the first order is added to the first transaction data.

[0103] In this embodiment, when the transaction operation is to withdraw an order, the first order is deleted. Here, the first order may be the first order that was not completed in the first transaction operation.

[0104] In this embodiment, when the transaction operation is to cancel the order, the first order is deleted from the first transaction data, so that when the transaction operation is to cancel, it is the same as the live transaction, thereby reducing the difference between the backtesting results and the live transaction results.

[0105] Furthermore, the step of determining the backtesting result of the transaction algorithm based on the first order and the transaction result includes:

[0106] When the transaction result is completed, calculate the first price ratio between the price of the first order and the average transaction price of the first transaction data, and use the first price ratio as the backtesting result;

[0107] Specifically, in this embodiment, when the transaction result is completed, the transaction effect of the transaction algorithm is determined by the first price ratio. In other embodiments, parameters such as cumulative profit, number of transactions, average number of transactions per day, annualized profit, maximum drawdown, and maximum drawdown duration are calculated based on multiple first orders and used as the backtesting results.

[0108] When the transaction result is incomplete, calculate multiple first price differences between the price of the first order and multiple transaction prices of the first transaction data, and take the minimum value among the multiple first price differences as the backtest result.

[0109] Specifically, in this embodiment, the multiple first price differences are 10, 20, and 30, and 10 is used as the backtesting result. In other embodiments, transaction records, quotation quality reports, etc., can be used as the backtesting result.

[0110] In this embodiment, the transaction result of the transaction algorithm is determined by calculating the first price ratio and the first price difference, thereby improving the accuracy of the backtesting.

[0111] This invention also provides a storage medium storing a transaction algorithm backtesting program, which, when executed by a processor, implements the steps of the transaction algorithm backtesting method embodiment described above.

[0112] (Other topics are listed in a manner corresponding to Topic 1, with all embodiments and corresponding beneficial effects described.)

[0113] It should be noted that, in this document, the terms "comprising," "including," or any other variations thereof are intended to cover non-exclusive inclusion, such that a process, method, article, or system that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such a process, method, article, or system. Unless otherwise specified, an element defined by the phrase "comprising one..." does not exclude the presence of other identical elements in the process, method, article, or system that includes that element.

[0114] The sequence numbers of the above embodiments of the present invention are for descriptive purposes only and do not represent the superiority or inferiority of the embodiments.

[0115] Through the above description of the embodiments, those skilled in the art can clearly understand that the methods of the above embodiments can be implemented by means of software plus necessary general-purpose hardware platforms. Of course, they can also be implemented by hardware, but in many cases the former is a better implementation method. Based on this understanding, the technical solution of the present invention, or the part that contributes to the prior art, can be embodied in the form of a software product. This computer software product is stored in a storage medium (such as ROM / RAM, magnetic disk, optical disk) as described above, and includes several instructions to cause a terminal device (which may be a mobile phone, computer, server, or network device, etc.) to execute the methods described in the various embodiments of the present invention.

[0116] The above are merely preferred embodiments of the present invention and do not limit the patent scope of the present invention. Any equivalent structural or procedural transformations made based on the content of the present invention's specification and drawings, or direct or indirect applications in other related technical fields, are similarly included within the patent protection scope of the present invention.

Claims

1. A backtesting method for a trading algorithm, characterized in that, The backtesting method for the trading algorithm includes the following steps: Obtain the first order book, the second order book, and the transaction algorithm; generate the first transaction data based on the first order book; the first order book and the second order book are generated at adjacent times. The transaction data is analyzed according to the transaction algorithm to obtain the first order and the corresponding first transaction operation; The order in the second order book that differs from the first order book is identified as the third order, and the data difference characteristics of the third order in the first order book and the second order book are determined. Update the first transaction data based on the data difference characteristics and the third order; According to the matching transaction principle, the orders in the first transaction data and the first order are matched and executed, and the results of the matching and execution are used to determine whether there is a second order that has completed the transaction with the first order; When the second order exists, the transaction result of the first order is determined to be completed; If the second order does not exist, the transaction result of the first order is determined to be incomplete; The backtesting results of the transaction algorithm are determined based on the first order and the transaction results.

2. The backtesting method for trading algorithms as described in claim 1, characterized in that, After the step of analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes: Calculate the first liquidity based on the first transaction operation and the first transaction data, and determine the second liquidity required when the first transaction operation is executed; When the ratio of the first liquidity to the second liquidity is greater than a preset ratio, the transaction result of the first order is determined to be the completion of the first transaction operation, and the backtesting result of the transaction algorithm is determined based on the first order and the transaction result. When the ratio is less than or equal to the preset ratio, the transaction result of the first order is determined based on the second order book and the first order book. The transaction result includes the step of determining whether the first transaction operation has been completed.

3. The backtesting method for trading algorithms as described in claim 2, characterized in that, The step of calculating the first liquidity based on the first transaction operation and the first transaction data includes: The target trading price range is determined based on the target trading price, trading direction, and preset fluctuation range of the first trading operation, wherein the trading direction includes buying or selling. The target order is defined as an order whose transaction price is within the target transaction price range and whose transaction direction is opposite to that of the target transaction price. The total number of the target orders is determined as the first liquidity.

4. The backtesting method for trading algorithms as described in any one of claims 1 to 3, characterized in that, After the step of analyzing the first transaction data according to the transaction algorithm to obtain the first order and the corresponding first transaction operation, the method further includes: Update the first transaction data according to the first transaction operation and the first order; After the step of determining the transaction result of the first order based on the second order book and the first order book, the method further includes: Determine the second order book as the new first order book, and obtain the third order book generated at the next moment as the new second order book; Return to the step of analyzing the first transaction data according to the transaction algorithm and generating the first transaction operation.

5. The backtesting method for trading algorithms as described in claim 4, characterized in that, The step of updating the first transaction data based on the first transaction operation and the first order includes: When the first transaction operation is a cancellation operation, the first order is deleted from the first transaction data; When the first transaction operation is an order placement operation, the first order is added to the first transaction data.

6. The backtesting method for trading algorithms as described in claim 4, characterized in that, The step of determining the backtesting result of the transaction algorithm based on the first order and the transaction result includes: When the transaction result is completed, calculate the first price ratio between the price of the first order and the average transaction price of the first transaction data, and use the first price ratio as the backtesting result; When the transaction result is incomplete, calculate multiple first price differences between the price of the first order and multiple transaction prices of the first transaction data, and take the minimum value among the multiple first price differences as the backtest result.

7. A backtesting device for a trading algorithm, characterized in that, The trading algorithm backtesting device includes: a memory, a processor, and a trading algorithm backtesting program stored in the memory and executable on the processor, wherein the trading algorithm backtesting program is configured to implement the steps of the trading algorithm backtesting method as described in any one of claims 1 to 6.

8. A storage medium, characterized in that, The storage medium stores a backtesting program for a trading algorithm, which, when executed by a processor, implements the steps of the backtesting method for a trading algorithm as described in any one of claims 1 to 6.

Citation Information

Patent Citations

  • High-frequency quantitative transaction strategy back test verification method and system

    CN110443707A