Backtesting method, device and equipment and computer readable storage medium
By parsing natural language backtesting logic using a pre-trained large language model to generate structured parameters and automatically executing backtesting simulations, the system eliminates the dependence of existing backtesting systems on user programming skills, achieving a low-threshold, highly flexible backtesting system suitable for automated backtesting in financial scenarios.
Patent Information
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- ZHEJIANG HERYMED TECH CO LTD
- Filing Date
- 2026-01-27
- Publication Date
- 2026-04-14
AI Technical Summary
Existing backtesting systems are highly dependent on users' programming skills, have a high barrier to entry, lack flexibility and scalability, and are difficult to meet complex and multivariate backtesting needs.
A pre-trained proprietary large language model is used to parse the backtesting logic description of natural language input, generate structured backtesting parameters, and use the backtesting engine to automatically execute backtesting simulations and output quantized results, reducing the programming complexity for users and improving system flexibility.
It enables users to automatically build backtesting logic without complex programming, improving the system's flexibility and scalability, adapting to diverse and dynamic market demands, and quickly verifying the effectiveness and risk level of event-driven backtesting strategies.
Smart Images

Figure CN121858632A_ABST
Abstract
Description
Technical Field
[0001] This invention relates to the field of computer technology, and in particular to a backtesting method, apparatus, device, and computer-readable storage medium. Background Technology
[0002] Existing backtesting systems generally consist of four core components: data source access and configuration, signal generation, backtesting logic construction, and backtesting task execution. Common technical approaches used to implement these backtesting methods include: graphical user interfaces (GUIs), dedicated scripting languages, and general-purpose languages combined with dedicated libraries. These methods present a certain barrier to entry for users' programming skills, require customized development, and can lead to insufficient system scalability.
[0003] Therefore, how to reduce the high dependence of backtesting systems on users' programming capabilities, lower the threshold for use, and improve the flexibility and scalability of the system are technical problems that urgently need to be solved. Summary of the Invention
[0004] In view of this, the purpose of the present invention is to provide a backtesting method, apparatus, device and computer-readable storage medium, which solves the problems of high dependence on user programming ability, high threshold for use, poor flexibility and insufficient scalability of existing backtesting systems.
[0005] To address the aforementioned technical problems, this invention provides a backtesting method, comprising: Acquire a statement as input in natural language; the statement contains an event backtesting logic description; The statement is parsed using a pre-trained proprietary large language model to obtain structured backtesting parameters; the structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, obtained by a template recursive replacement mechanism from structured event semantic objects. Using the backtesting engine, backtesting simulation is performed based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and backtesting quantitative results are calculated based on the buy-sell behavior sequence. The pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
[0006] Optionally, before parsing the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters, the method further includes: Acquire historical financial text data, and construct a proprietary training dataset based on the historical financial text data to support tasks such as masked language modeling, event time-series sequencing, and financial causal reasoning. The general large language model is pre-trained based on the proprietary training dataset. When the first training termination condition is met, the initial large language model is obtained. The initial large language model is trained on the training dataset using the data, and the pre-trained proprietary large language model is obtained when the second training termination condition is met. The structured backtesting parameters in the training dataset are parameters constructed according to the specifications of the preset template library and module library.
[0007] Optionally, a general-purpose large language model is pre-trained based on the proprietary training dataset. When the first training termination condition is met, an initial large language model is obtained, including: The general large language model is pre-trained based on the proprietary training dataset, and the first total loss value is output based on the first loss function. When the first total loss value of the output reaches convergence, the first largest language model is obtained; The expression for the first loss function is: ; in, This is the first total loss value; This represents the loss value for the masked language model. Loss values are sorted by event time sequence; This represents the loss value for causal inference. , and These are the weight hyperparameters for the masked language model loss, the event sequence ranking loss, and the causal inference loss, respectively.
[0008] Optionally, the initial large language model is trained on the training dataset using the data, and when the second training termination condition is met, the pre-trained proprietary large language model is obtained, including: The initial large language model is trained on the training dataset based on the data, and a second total loss value is output based on the second loss function; When the output of the second total loss value reaches convergence, the pre-trained proprietary large language model is obtained; The expression for the second loss function is: ; in, This represents the second total loss value; N is the total number of training samples. The length of the structured backtesting parameters for the i-th sample; For large language model parameters Below, based on The prediction is exactly The probability of; The t-th term in the target structured backtesting parameters of the i-th sample; The input structured event semantic object is the i-th training sample; These are parameters for a large language model.
[0009] Optionally, the statement is parsed using a pre-trained proprietary large language model to obtain structured backtesting parameters, including: The statement is parsed to obtain a structured event semantic object; Based on the backtest-specific template library, backtest-specific module library, and the structured event semantic object, the placeholders in the template are recursively parsed layer by layer and replaced by the placeholder-module-semantic object element mapping until all placeholders are replaced with specific parameters, thus obtaining the structured backtest parameters. The template library defines a backtesting logic framework, including placeholders corresponding to backtesting scenarios, and the templates adopt a directed acyclic graph structure; the module library contains backtesting-specific algorithm modules, forming a bidirectional mapping relationship with the template library.
[0010] Optionally, after using the backtesting engine to perform backtesting simulation based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and calculating the backtesting quantitative results based on the buy-sell behavior sequence, the method further includes: The visualization module integrates the backtesting quantitative results, the buying and selling behavior sequence, and the structured event semantic object into a multi-dimensional, exchangeable visual display output; the backtesting quantitative results include at least the performance indicator quantitative results and the risk indicator quantitative results.
[0011] Optionally, the backtesting engine is used to perform backtesting simulations based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and backtesting quantitative results are calculated based on the buy-sell behavior sequence, including: Based on the target, backtesting time range, and event type in the structured backtesting parameters, obtain target data from the target data source; Using the backtesting engine, backtesting simulations are performed based on the event triggering conditions and trading rules in the structured backtesting parameters, as well as the target data, to generate the trading behavior sequence.
[0012] The present invention also provides a backtesting device, comprising: The query language acquisition module is used to acquire statements input in natural language; the statements contain event backtesting logic descriptions. The large model parsing module is used to parse the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters. The structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, obtained by a template recursive replacement mechanism from structured event semantic objects. The backtesting module is used to perform backtesting simulation using the backtesting engine and the structured backtesting parameters to obtain a buy-sell behavior sequence, and to calculate the backtesting quantitative results based on the buy-sell behavior sequence. The pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
[0013] The present invention also provides a backtesting device, comprising: Memory, used to store computer programs; A processor for implementing the backtesting method as described above when executing the computer program.
[0014] The present invention also provides a computer-readable storage medium storing computer-executable instructions, which, when loaded and executed by a processor, implement the backtesting method described above.
[0015] As can be seen, this invention acquires natural language input statements; the statements contain event backtesting logic descriptions; a pre-trained proprietary large language model is used to parse the statements to obtain structured backtesting parameters; the structured backtesting parameters are configuration objects obtained by a template recursive replacement mechanism from structured event semantic objects, which can be directly executed and read by the backtesting engine; the backtesting engine is used to perform backtesting simulations based on the structured backtesting parameters to obtain a buying and selling behavior sequence, and backtesting quantification results are calculated based on the buying and selling behavior sequence; wherein, the pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on the training dataset based on data; the data pair consists of a data pair composed of structured event semantics used for training and structured backtesting parameters used for training. This method, through a closed loop of natural language interaction, automated backtesting, and quantification result output, primarily serves the rapid verification of event-driven backtesting strategies. It allows users to complete the entire process from requirement expression to strategy verification simply by describing backtesting logic (especially event-driven backtesting requirements) in natural language, without complex programming. Finally, it outputs quantifiable backtesting results, enabling users to quickly determine the historical effectiveness and risk level of the backtesting strategy.
[0016] In addition, the present invention also provides a backtesting device, equipment, and computer-readable storage medium, which also have the above-mentioned beneficial effects. Attached Figure Description
[0017] To more clearly illustrate the technical solutions in the embodiments of the present invention or the prior art, the drawings used in the description of the embodiments or the prior art will be briefly introduced below. Obviously, the drawings described below are only embodiments of the present invention. For those skilled in the art, other drawings can be obtained based on the provided drawings without creative effort.
[0018] Figure 1 A flowchart of a backtesting method provided in an embodiment of the present invention; Figure 2 A conversion example diagram provided for an embodiment of the present invention; Figure 3 Another conversion example diagram provided for an embodiment of the present invention; Figure 4 A flowchart illustrating a backtesting method provided in an embodiment of the present invention; Figure 5 This is a schematic diagram of the structure of a backtesting device provided in an embodiment of the present invention; Figure 6 This is a schematic diagram of the structure of a backtesting device provided in an embodiment of the present invention. Detailed Implementation
[0019] To make the objectives, technical solutions, and advantages of the embodiments of the present invention clearer, the technical solutions of the embodiments of the present invention will be clearly and completely described below with reference to the accompanying drawings. Obviously, the described embodiments are only some embodiments of the present invention, and not all embodiments. Based on the embodiments of the present invention, all other embodiments obtained by those skilled in the art without creative effort are within the scope of protection of the present invention.
[0020] Existing modular backtesting systems generally consist of four core components: data source access and configuration, signal generation, backtesting logic construction, and backtesting task execution. Users typically need to write code scripts to configure and operate these processes. Currently, there are three main parameterization methods for mainstream backtesting systems: (1) Graphical User Interface: Most financial platforms provide a graphical interface, where users configure backtesting parameters, such as asset selection, backtesting period setting, and technical indicator parameter input, through elements such as input boxes, drop-down menus, and checkboxes. This method is intuitive and easy to use, but it is limited by the preset parameter items and structure, making it difficult to meet the needs of expressing highly complex, customized, or innovative strategies.
[0021] (2) Dedicated scripting languages: Some platforms (such as TradingView's PineScript, MetaTrader's MQL, etc.) provide their own scripting languages. Users need to master the exclusive syntax and function libraries to implement strategy logic and parameter settings through programming. Although this method is flexible and expressive, it has a high technical threshold and is extremely unfriendly to non-technical users.
[0022] (3) Combining general-purpose programming languages with specialized libraries: Professional quantitative analysts and developers often use general-purpose languages such as Python and R, combined with backtesting libraries such as Pandas (data analysis library), NumPy (numerical computation library), Zipline (quantitative backtesting framework designed specifically for event-driven strategies), and Backtrader (quantitative backtesting framework supporting multi-asset and multi-strategy backtesting, commonly known in the industry) to manually implement the complete backtesting process. This approach is the most flexible and powerful, but it requires users to have solid programming and financial engineering skills.
[0023] Therefore, the parameterization methods of the aforementioned mainstream backtesting systems have the following problems: (1) High technical threshold: Most systems require users to have strong programming skills, and ordinary users find it difficult to directly express or implement backtesting logic, which limits the popularization and application of such tools; (2) Insufficient system scalability: Existing systems mostly adopt customized development, lacking universality and modular design. Adding or adjusting functions requires a lot of development resources, resulting in slow response to market changes and low system flexibility and maintenance efficiency. (3) Weak semantic understanding and detail grasp: Existing solutions mostly rely on keywords or fixed patterns, which have limited ability to identify key details and conditional logic in complex backtesting requirements descriptions, and are prone to misunderstandings or omissions; (4) Rigid parameter extraction methods: Fixed templates and parsing rules are prone to failure when faced with new financial professional terms or non-standard expressions, and are difficult to adapt to complex backtesting requirements and the diversity of languages; (5) Limited scalability: As the complexity of backtesting requirements and expressions increases, backtesting systems that rely on rule extraction and fixed modules are difficult to cover all situations, rule conflicts, long module development cycles, high maintenance costs, and severely limited flexibility; (6) Lack of systematic reasoning and external context integration capabilities: The ability to perform multi-step reasoning and call external APIs (interfaces) to obtain real-time or historical data is weak, and it is difficult to handle complex tasks involving data queries and chain logic. In summary, these defects limit the ability of existing technologies to automatically parse and execute complex and multivariate backtesting instructions, and also restrict the large-scale application of backtesting systems for natural language.
[0024] This invention addresses the problems of existing commercial backtesting systems, such as high dependence on user programming skills, high usage barriers, and poor customization and scalability of system functional modules. By introducing a Large Language Model (LLM) as an intermediary, it achieves automatic structuring of user natural language backtesting requirements and automated construction of the backtesting process, greatly reducing user operational complexity and improving the system's flexibility and scalability, enabling backtesting tools to better adapt to diverse and dynamic market demands.
[0025] Please refer to the details. Figure 1 , Figure 1 A flowchart illustrating a backtesting method provided in an embodiment of the present invention. The method may include: S101: Obtain the statement of natural language input.
[0026] The execution entity in this embodiment is a terminal. This embodiment does not limit the type of terminal, as long as it can perform the backtesting operation. The statement used to obtain natural language input refers to the natural language statement entered by the user. Backtesting is a tool / method that uses historical data to simulate the operation of a strategy / model, verifying its effectiveness, profitability, risk level, and other indicators over a specific historical period. Its core purpose is to evaluate the feasibility and reliability of the strategy / model, providing a basis for decision-making in practical applications. It is commonly used in financial / quantitative buying and selling to verify the historical returns, maximum drawdown, win rate, etc., of strategies such as stocks, futures, and cryptocurrencies, and to screen feasible strategies. In this embodiment, backtesting can be event backtesting, strategy backtesting, or event-strategy backtesting. The statement contains a description of the backtesting logic. The backtesting method in this embodiment can be specifically applied to financial scenarios. For example, we tested the short-term performance of the top 20 A-share listed companies in the new energy vehicle industry (by market capitalization) from January 1, 2021 to December 31, 2024, after the official release of the domestic new energy vehicle purchase tax reduction policy. We bought at the opening price on the first trading day after the policy was released, held for 5 trading days and sold at the closing price, and allocated funds in equal amounts. We calculated the average return, win rate and maximum drawdown of this strategy.
[0027] S102: Use a pre-trained proprietary large language model to parse the sentences and obtain structured backtesting parameters.
[0028] It should be noted that this embodiment parses the natural language input statement into structured backtesting parameters, a process that relies on a pre-trained proprietary large language model. This pre-trained proprietary large language model is a large language model obtained by training on a proprietary training dataset and by training on the training dataset using other data. The data pair consists of structured event semantics used for training and structured backtesting parameters used for training. The structured backtesting parameters are JSON (JavaScript Object Notation) configuration trees obtained from structured event semantic objects through a template recursive replacement mechanism; these are configuration objects that can be directly read and executed by the backtesting engine. The core function of the structured backtesting parameter P is execution: guiding the backtesting engine on how to do things (what to buy, when to buy, how much to buy). The structured backtesting parameter P mainly contains the following three types of core information: (1) Backtesting Goal: Backtesting Type: Determine whether the task is strategy backtesting or event backtesting; Sub-type: Specific strategy or event classification criteria.
[0029] (2) Global settings: Period: The specific start and end dates (e.g., 2020.01.01 - 2025.06.02); Benchmark: The reference target used for comparison (e.g., SPY or 000300.SH).
[0030] (3) Operations: This is the core of the structured backtesting parameter P, containing a series of specific operation instructions. Each operation consists of modules and parameters. For example, in the case of fixed investment, the operation parameters include: operation template: fixed investment; target object: specific stock code; investment amount: numerical value; investment frequency: time interval; buy / sell direction: buy / sell.
[0031] Furthermore, the above-mentioned use of a pre-trained proprietary large language model to parse sentences and obtain structured backtesting parameters can specifically include: Step 11: Parse the statement to obtain a structured event semantic object.
[0032] In this embodiment, the pre-trained proprietary large language model can parse sentences into structured event semantic objects Y. The definition and composition of structured event semantic objects Y are as follows: Y = {E, T, S, R}, representing the semantic intent of what the user wants to see: E (Event): Event types at the semantic level, such as executives increasing their holdings or earnings reports exceeding expectations; T (Target): The target of influence described in natural language, such as the graphics card manufacturer; S (Time / Sequence): A vague time or sequence description, i.e., time sequence information, such as one week after publication.
[0033] R (Relation): A causal or logical graph between events, i.e., a chain of causal relationships, such as event a leading to result b.
[0034] Compared to direct keyword matching (such as identifying only buys), this step is prone to losing causal relationships. This embodiment generates structured event semantic objects, accurately capturing the complex logic in the financial context and providing unambiguous input for subsequent execution.
[0035] Step 12: Based on the backtest-specific template library, backtest-specific module library, and structured event semantic objects, recursively parse the placeholders in the template layer by layer and replace them through placeholder-module-semantic object element mapping until all placeholders are replaced with specific parameters to obtain structured backtest parameters.
[0036] In this embodiment, the pre-trained proprietary large language model can also transform structured event semantic objects Y into structured backtesting parameters P. It should be noted that the template library defines the backtesting logic framework, including placeholders corresponding to the backtesting scenarios, and the templates adopt a directed acyclic graph structure; the module library contains backtesting-specific algorithm modules, forming a bidirectional mapping relationship with the template library. (See reference...) Figure 2 , Figure 2 This is a transformation example diagram provided in an embodiment of the present invention. It can also be simply understood as follows: the template library and module library are predefined toolboxes and vocabularies, representing a candidate set and constraint boundary for the pre-trained proprietary large language model to transform structured event semantic objects Y into structured backtesting parameters P. The module library restricts the pre-trained proprietary large language model to only execute policy types supported by the system, and restricts it to only execute parameter logic supported by the system. In this embodiment, the template design strictly prohibits circular references, ensuring a recursive directed acyclic graph (DAG) structure. This is not only a theoretical proof, but also a key design feature in engineering to prevent infinite recursion and ensure that the task will always terminate.
[0037] Specifically, assume that all backtesting requirements can ultimately be reduced to a finite set of templates. For each structured event semantic object Y, the pre-trained proprietary large language model will first parse out a top-level template. Its parameters or submodules may still contain placeholders to be identified (unfilled submodules). At each recursive step, the pre-trained proprietary large language model adjusts its structure based on the currently incomplete module structure. Replace the placeholders with more specific submodules or parameters, denoted as The recursive expansion process of each module can be formally described as follows: in This indicates a replacement or completion operation.
[0038] For details, please refer to... Figure 3 , Figure 3 This is another example diagram of the transformation provided in this embodiment of the invention. Step 1: Top-level routing. The pre-trained proprietary large language model analyzes the structured event semantic object Y and selects the most matching operation template from the backtesting proprietary template library. This operation template defines the backtesting logic framework. For example, if the structured event semantic object Y is identified as a fixed-amount investment strategy, the most matching operation template DCA_Template (a fixed-amount investment template specifically for quantitative backtesting) is called from the template library. For example, this operation template includes four placeholders: target, amount, frequency, and event. Step 2: Recursive filling. Each placeholder in the template is recursively filled, which may require simple numerical values or complex logic. When encountering a complex placeholder, the pre-trained proprietary large language model calls the corresponding functional module (such as DateRangeModule or ConditionModule) from the module library to fill it. If there are still placeholders within this module, the pre-trained proprietary large language model continues to search for finer-grained atomic parameters from the module library. Step 3: Atomization termination. The recursive process continues until all placeholders are filled with atomic parameters (such as numbers and strings), ultimately forming a complete structured backtest parameter P. The structured backtest parameter P and the structured event semantic object Y contain the same information, but the descriptive language differs.
[0039] For example, parameter E of the structured backtesting parameter P is the corresponding operation template. For instance, it can be transformed into an EventDrivenBacktest or DollarCostAveraging module. Parameter T is the standardized financial instrument code. For example, it can be transformed into a specific Ticker B (stock code B). Parameter S is the precise timestamp or period parameter. For example: start_date: 2020-01-20, frequency: 7d. Parameter R is the operation logic / trigger condition. For example: Condition: if a then b, transforming causal relationships into code logic or trading signals.
[0040] Furthermore, this embodiment also proves the convergence of the above-mentioned recursive mechanism: (1) Explanation of convergence logic.
[0041] Template limitations: All templates It is a finite set, and the definitions and available modules for each template are also finite.
[0042] Reduction Principle: For any natural language requirement, after a finite number of recursive substitutions, all submodules will be reduced to the template. Instantiation (i.e., after the specific parameters are filled in, placeholders are no longer included).
[0043] Nesting finiteness: When designing templates, circular references are prohibited (directed cycles cannot be formed between recursive templates), and each replacement operation moves closer to the atomic operation to ensure that the recursion depth has an upper bound.
[0044] (2) Formal proof of convergence (recursive induction).
[0045] Define the "incompleteness" function template The number of remaining unfinished submodules. Each recursive expansion has... Because both the operation templates and modules are limited, each expansion can... It is monotonically decreasing and will not result in an infinite number of unfinished submodules being added, therefore, after a finite number of steps... Afterwards, there will surely be That is, all placeholders are materialized, the entire structured representation is reduced, and the recursive process terminates.
[0046] (3) Engineering verifiability.
[0047] In practice, a maximum limit can be set for the number of recursion levels in each iteration. Furthermore, a structure validity check is designed to ensure that the parsing process always progresses toward the instantiation termination state of the template, preventing infinite recursion caused by improper template definition or abnormal structured event semantic object Y.
[0048] S103: Using the backtesting engine, backtesting simulation is performed based on structured backtesting parameters to obtain a sequence of buying and selling behaviors, and backtesting quantitative results are calculated based on the sequence of buying and selling behaviors.
[0049] This step is the backtesting execution phase. The backtesting engine loads the strategy logic based on the structured backtesting parameters, reads the target data, and simulates buying and selling behavior to generate a buying and selling behavior sequence A. The backtesting engine no longer needs to pre-write hard-coded strategies, realizing natural language-driven zero-code backtesting.
[0050] Furthermore, the aforementioned backtesting engine is used to perform backtesting simulations based on structured backtesting parameters to obtain a sequence of buying and selling behaviors, and backtesting quantitative results are calculated based on the buying and selling behavior sequence. Specifically, this may include: obtaining target data from the target data source based on the target object, backtesting time range, and event type in the structured backtesting parameters; and using the backtesting engine to perform backtesting simulations based on the event triggering conditions and buying and selling rules in the structured backtesting parameters, as well as the target data, to generate a sequence of buying and selling behaviors.
[0051] Specifically, the backtesting engine first uses the target object (specific trading object), backtesting time range (time boundary), and event type (core triggering event) in the structured backtesting parameters as filtering conditions to extract the target data such as historical market data and event triggering details required for backtesting from the target data source. Then, the backtesting engine receives the event triggering conditions (trading start rules) and buying and selling rules (buying time, holding period, selling timing, and other operational specifications) specified in the structured backtesting parameters, and performs automated backtesting simulation in combination with the aforementioned target data. Finally, it generates a detailed transaction operation list (i.e., a sequence of buying and selling behaviors) arranged in chronological order, providing core raw data for subsequent calculation of backtesting evaluation indicators.
[0052] Furthermore, after utilizing the backtesting engine to perform backtesting simulations based on structured backtesting parameters, obtaining a sequence of buying and selling behaviors, and calculating backtesting quantitative results based on the buying and selling behaviors sequence, the method may further include: integrating the backtesting quantitative results, the buying and selling behaviors sequence, and the structured event semantic objects into a multi-dimensional and exchangeable visual display output through a visualization module; the backtesting quantitative results include at least the quantitative results of performance indicators and the quantitative results of risk indicators.
[0053] Specifically, by calling a standard financial computing library, based on the sequence of buying and selling behavior... Calculate performance indicators Quantitative results of indicators such as cumulative return R, volatility, etc., and quantitative results of risk indicators. For example, the key maximum drawdown ( ) is calculated as: .in, The peak value is represented by 'valley', and the valley value by 'valley'. (Visualization module) Receive all calculation results, including various backtesting metrics output by the backtesting engine, such as performance indicators. (Results), Risk Indicators, Buying and Selling Behavior Sequences (Process), and the structured event semantic object Y (cause) output by the pre-trained proprietary large language model. The visualization module integrates this information into a multi-dimensional, interactive display. Its structure can be described as follows: .in, The data source for some (such as the "Earnings Release" label on a chart) is precisely the structured event semantic object output by LLM. This achieves an end-to-end link from natural language to final attribution visualization. It overlays results, causes, and processes, enabling users to understand not only what (performance) but also why (semantic events); and automatically overlays structured event semantic objects onto traditional time-series charts. Event annotations help users intuitively understand the correspondence between strategy actions and market events; they can automatically perform attribution analysis between maximum drawdown and the occurrence of a specific event, greatly improving the interpretability of risk control. Among these features... For visual display output; The visual output for the structured event semantic object Y; A visual output of the buying and selling behavior sequence; Visualize the results of quantitative performance indicators.
[0054] Furthermore, before using a pre-trained proprietary large language model to parse the sentences and obtain structured backtesting parameters, the process may further include: Step 21: Obtain historical financial text data and build a proprietary training dataset based on the historical financial text data to support tasks such as masked language modeling, event time-series sequencing, and financial causal reasoning.
[0055] In this embodiment, the training of the proprietary large language model adopts a staged training structure. The first stage strengthens the model's understanding of natural language output sentences, enabling it to generate accurate structured event semantic objects Y. Its purpose is to specialize the model, allowing it to distinguish between "selling on bad news" and "profit-taking." The second stage strengthens the model's mapping ability from structured event semantic objects Y to structured backtesting parameters P, i.e., learning how to correctly use template and module libraries. Its purpose is to make the model understand rules, ensuring that the generated structured backtesting parameters P strictly conform to the JSON Schema specification and can be directly executed by the backtesting engine. It should be noted that both the first and second stages are supervised training. The proprietary training dataset in the first stage consists of data pairs between natural language sentences and structured event semantic objects Y, used to train the general model.
[0056] Step 22: Pre-train the general large language model based on the proprietary training dataset. When the first training termination condition is met, the initial large language model is obtained.
[0057] This embodiment does not limit the general-purpose large language model; any model capable of handling common languages, such as GPT or BERT, is acceptable. Furthermore, the general-purpose large language model is pre-trained using a proprietary training dataset. When the first training termination condition is met, an initial large language model is obtained. Specifically, this may include: pre-training the general-purpose large language model using the proprietary training dataset, and outputting a first total loss value based on a first loss function; when the output first total loss value converges, the first large language model is obtained. The expression for the first loss function is: ;in, This is the first total loss value; This represents the loss value for the masked language model. Loss values are sorted by event time sequence; This represents the loss value for causal inference. , and represents the weight hyperparameters for the masked language model loss, event sequence ranking loss, and causal inference loss.
[0058] Among them, (1) masked language model loss ( ): Used to train the model's accurate understanding of quantitative financial terms, ensuring that the model can accurately extract the event type (E) and the affected target (T) from natural language. For example, the model can identify "golden cross" and "volume contraction" as specific technical indicator events, and accurately map slang such as "Ningwang" and "photovoltaic Mao" to specific stock codes or sector indices, rather than ordinary nouns. (2) Event time sequence ranking loss ( By learning the natural sequence of financial business processes (such as "financial report disclosure" followed by "stock price fluctuation"), the model possesses strict time window logic, thereby accurately generating the time series information (S) in Y. For example, the model can parse the implicit T+1 backtesting time point description such as "market opening the day after the announcement", preventing the logical error of "price gouging" using future data. (3) Causal inference loss ( The first loss function (R) is used to train the model's ability to infer the corresponding strategy execution logic based on financial trading logic or indicator construction principles, ensuring that the causal relationship chain (R) generated by the model has a rigorous logical closed loop. Specifically, the model does not only perform keyword matching, but can understand the deep principles. For example, when a user inputs "build a strategy based on the momentum effect," the model can use causal reasoning to deduce the strategy logic of "highest increase in the past period → continue to buy and hold"; or when a user mentions "volatility breakout," the model can deduce the conditional judgment chain of "current volatility is greater than the historical threshold → trigger opening a position." This effectively prevents the generation of invalid strategies that only have abstract concepts without specific execution actions. Similarly, the above losses can also be referred to in Table 1, which explains the losses in the first loss function.
[0059] Step 23: Train the initial large language model using the training dataset. When the second training termination condition is met, a pre-trained proprietary large language model is obtained. The structured backtesting parameters in the training dataset are parameters constructed according to the specifications of the preset template library and module library.
[0060] This step is the second stage of the training process. The training dataset in the second stage consists of data pairs between structured event semantic objects Y and structured backtesting parameters P, where the structured backtesting parameters P are parameters constructed according to the specifications of the preset template library and module library.
[0061] Furthermore, the above-mentioned method of training the initial large language model on the training dataset using data, and obtaining a pre-trained proprietary large language model when the second training termination condition is met, can specifically include: training the initial large language model on the training dataset based on data, and outputting a second total loss value based on a second loss function; when the output second total loss value converges, the pre-trained proprietary large language model is obtained; the expression for the second loss function is: ;in, This represents the second total loss value; N is the total number of training samples. The length of the structured backtesting parameters for the i-th sample; For large language model parameters Below, based on The prediction is exactly The probability of; The t-th term in the target structured backtesting parameters of the i-th sample; The input structured event semantic object is the i-th training sample; These are parameters for a large language model.
[0062] The backtesting method provided in this embodiment of the invention comprises the following steps: S101: Obtaining a natural language input statement; S102: Parsing the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters; S103: Using the backtesting engine, performing backtesting simulation based on the structured backtesting parameters to obtain a buying and selling behavior sequence, and calculating the backtesting quantitative results based on the buying and selling behavior sequence. This method, through a closed loop of natural language interaction, automated backtesting, and quantitative result output, primarily serves the rapid verification of event-driven backtesting strategies. It allows users to complete the entire process from requirement expression to strategy verification automatically, without complex programming, simply by describing the backtesting logic (especially event-driven backtesting requirements) in natural language, ultimately outputting quantifiable backtesting results to quickly determine the historical effectiveness and risk level of the backtesting strategy. Furthermore, compared to general methods that directly generate Python code using LMM, which can easily lead to illusions (referencing non-existent libraries), uncontrollable code logic, and difficulty in security risk control, this embodiment incorporates domain constraints, ensuring that the model can only select from a limited, verified template and module library, eliminating the possibility of generating illegal strategies or malicious code. This invention solves the problem of phantom code and logical non-convergence that easily occur in general models during financial backtesting, ensuring the absolute executability of the structured backtesting parameters P. Furthermore, this invention... Enable the model to understand financial logic, through By enabling the model to master the system instruction specifications, unlike directly fine-tuning the model-generated code (natural language → code), which ignores the intermediate semantic understanding and format constraints, resulting in poor generalization and susceptibility to errors, this embodiment achieves more robust control through an explicit structured event semantic object Y and a structured backtesting parameter P intermediate layer.
[0063] To better understand the process of transforming the structured event semantic object Y into structured backtesting parameters P, a data flow structure is also provided. The corresponding structured event semantic object Y is generated based on the user's natural language statement Query. Generally, based on the different focuses of the backtesting task, tasks can be divided into two main types: strategy backtesting and event backtesting. In business, tasks can be further divided into multiple subtypes based on different logics. Therefore, you need to identify and classify the task type and subtypes based on the structured event semantic object Y and the classification criteria. Typically, backtesting consists of a series of operations. You need to identify and infer the corresponding operations from the structured event semantic object Y and select a suitable operation template from <optional operations>. Therefore, the task mainly includes three steps. First, identify and infer the backtesting type and backtesting subtype based on the features presented in the structured event semantic object Y and the <classification criteria>. Second, select the operation templates involved in the structured event semantic object Y from <optional operations>. Third, select the appropriate modules and infer the corresponding parameter values based on the modules involved in the selected operation templates. To better complete the task, you should strictly adhere to the following rules.
[0064] Goal parameter inference logic. Rule 1: Goal parameters, mainly including backtesting type parameters. Rule 2: Inference for backtesting type must be based on the structured event semantic object Y and the features presented in the <classification criteria>. Rule 3: The values of the inference type and sub-type must be completely consistent with the values presented in the <classification criteria>.
[0065] Operation Parameter Inference Rules. Rule 1: A backtesting task consists of a series of operations, and each operation is also composed of a series of modules. Rule 2: Inference of backtesting operation parameters must be based on the structured event semantic object Y and the operation templates presented in <Optional Operations>. Rule 3: The operations mentioned in the structured event semantic object Y may follow a specific logic and order; therefore, you must identify and interpret the specified operations according to the predefined order. Rule 4: Each operation you identify and infer must be selected from <Optional Operations>.
[0066] Module Parameter Inference Rules. Rule 1: A module is a key and fundamental component of an operation; it can be referenced by the operation itself or by other modules. Rule 2: Module parameter inference must be based on the structured event semantic object Y and the information presented in the <optional module>. Rule 3: The <optional module> primarily presents three types of information: Name, Template, and Usage. Rule 4: The inference result of a module parameter must be completely consistent with the corresponding JSON parameter structure.
[0067] Global Parameter Inference Rules. Rule 1: Global parameters primarily include the general settings for the backtesting task. Rule 2: Inference of global parameters must be based on the structured event semantic object Y. Rule 3: For inference of global parameters related to the backtesting runtime, there are two main cases: when the structured event semantic object Y explicitly mentions the backtesting runtime, the inference should follow the instructions of the structured event semantic object Y; when the structured event semantic object Y does not explicitly mention the backtesting runtime, you need to provide an appropriate date range. Rule 4: The inference result of operation parameters must be completely consistent with the JSON parameter structure of the referenced module.
[0068] General rules. Rule 1: The output must only include the backtest parameters you are inferring and must not contain any other text. Rule 2: The overall structure of the output must be consistent with the JSON parameter structure presented in <Output Parameter Structure>. Rule 3: When encountering ` in any operation or module... When using the `ref` keyword, it must be replaced with the corresponding module content according to the `<optional module>` template. Rule 4: ` The replacement of `ref` must be performed recursively until no more `ref` appears in the output. The `ref` keyword.
[0069] Figure 4 This is a flowchart illustrating a backtesting method provided in an embodiment of the present invention. The user inputs a natural language strategy description into the large model module (i.e., the pre-trained proprietary large language model mentioned above), and outputs a structured backtesting instruction. That is, the backtesting engine can directly read and execute the structured backtesting parameters. The backtesting engine directly executes the structured backtesting instruction, obtains relevant historical market data from historical data, performs backtesting simulation according to the structured backtesting instruction, and outputs the backtesting results to the user for viewing.
[0070] The following describes a backtesting device provided by an embodiment of the present invention. The backtesting device described below can be referred to in correspondence with the backtesting method described above.
[0071] Please refer to the details. Figure 5 , Figure 5 A schematic diagram of a backtesting device provided in an embodiment of the present invention may include: The query language acquisition module 100 is used to acquire the statement input in natural language; the statement contains an event backtesting logic description. The large model parsing module 200 is used to parse the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters; the structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, obtained by a template recursive replacement mechanism from structured event semantic objects. The backtesting module 300 is used to perform backtesting simulation using the backtesting engine based on the structured backtesting parameters to obtain a buying and selling behavior sequence, and to calculate the backtesting quantitative results based on the buying and selling behavior sequence. The pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
[0072] Based on the above embodiments, the backtesting device may further include: A proprietary training dataset construction module is used to acquire historical financial text data before parsing the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters, and to construct the proprietary training dataset based on the historical financial text data to support masked language modeling, event time-series sequencing and financial causal reasoning tasks. The first training module is used to pre-train the general large language model based on the proprietary training dataset, and obtain the initial large language model when the first training termination condition is met. The second training module is used to train the initial large language model on the training dataset using the data. When the second training termination condition is met, the pre-trained proprietary large language model is obtained. The structured backtesting parameters in the training dataset are parameters constructed according to the specifications of the preset template library and module library.
[0073] Based on the above embodiments, the first training module may include: The pre-training unit is used to pre-train the general large language model based on the proprietary training dataset and output a first total loss value based on the first loss function. The first convergence determination unit is used to obtain the first large language model when the output of the first total loss value reaches convergence; the expression of the first loss function is: ; in, This is the first total loss value; This represents the loss value for the masked language model. Loss values are sorted by event time sequence; This represents the loss value for causal inference. , and These are the weight hyperparameters for the masked language model loss, the event sequence ranking loss, and the causal inference loss, respectively.
[0074] Based on the above embodiments, the second training module may include: The training unit is used to train the initial large language model on the training dataset based on the data, and output a second total loss value based on the second loss function; The second convergence judgment unit is used to obtain the pre-trained proprietary large language model when the output of the second total loss value reaches convergence; the expression of the second loss function is: ; in, This represents the second total loss value; N is the total number of training samples. The length of the structured backtesting parameters for the i-th sample; For large language model parameters Below, based on The prediction is exactly The probability of; The t-th term in the target structured backtesting parameters of the i-th sample; The input structured event semantic object is the i-th training sample; These are parameters for a large language model.
[0075] Based on any of the above embodiments, the large model parsing module 200 may include: The first parsing unit is used to parse the statement to obtain a structured event semantic object; The second parsing unit is used to recursively parse the placeholders in the template layer by layer based on the backtest-specific template library, the backtest-specific module library and the structured event semantic object, and replace them through the placeholder-module-semantic object element mapping until all placeholders are replaced with specific parameters to obtain structured backtest parameters. The template library defines a backtesting logic framework, including placeholders corresponding to backtesting scenarios, and the templates adopt a directed acyclic graph structure; the module library contains backtesting-specific algorithm modules, forming a bidirectional mapping relationship with the template library.
[0076] Based on the above embodiments, the backtesting device may further include: The display module is used to, after using the backtesting engine to perform backtesting simulation based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and calculating the backtesting quantitative results based on the buy-sell behavior sequence, integrate the backtesting quantitative results, the buy-sell behavior sequence, and the structured event semantic object into a multi-dimensional and exchangeable visual display output through the visualization module; the backtesting quantitative results include at least the performance indicator quantitative results and the risk indicator quantitative results.
[0077] Based on the above embodiments, the backtesting module 300 may include: The data acquisition unit is used to acquire target data from the target data source based on the target object, backtesting time range, and event type in the structured backtesting parameters. The backtesting unit is used to utilize the backtesting engine to perform backtesting simulations based on the event triggering conditions and trading rules in the structured backtesting parameters and the target data, thereby generating the trading behavior sequence.
[0078] It should be noted that the order of the modules and units in the aforementioned backtesting device can be changed without affecting the logic.
[0079] The backtesting device provided in this embodiment of the invention uses a query language acquisition module 100 to acquire a natural language input statement; the statement contains an event backtesting logic description; a large model parsing module 200 is used to parse the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters; the structured backtesting parameters are configuration objects obtained by a template recursive replacement mechanism from structured event semantic objects and can be directly executed and read by the backtesting engine; a backtesting module 300 is used to use the backtesting engine to perform backtesting simulation based on the structured backtesting parameters to obtain a buying and selling behavior sequence, and calculate backtesting quantification results based on the buying and selling behavior sequence; wherein, the pre-trained proprietary large language model is a large language model obtained by training a model on a proprietary training dataset and by training a model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training. This device, through a closed loop of natural language interaction, automated backtesting, and quantification result output, primarily serves the rapid verification of event-driven backtesting strategies. It allows users to complete the entire process from requirement expression to strategy verification simply by describing backtesting logic (especially event-driven backtesting requirements) in natural language, without complex programming. Finally, it outputs quantifiable backtesting results, enabling users to quickly determine the historical effectiveness and risk level of the backtesting strategy.
[0080] The backtesting device provided in the embodiments of the present invention will be described below. The backtesting device described below and the backtesting method described above can be referred to each other.
[0081] Please refer to Figure 6 , Figure 6 A schematic diagram of a backtesting device provided in an embodiment of the present invention may include: Memory 10 is used to store computer programs; Processor 20 is used to execute computer programs to implement the backtesting method described above.
[0082] The memory 10, processor 20, and communication interface 31 all communicate with each other through the communication bus 32.
[0083] In this embodiment of the invention, the memory 10 is used to store one or more programs. The programs may include program code, which includes computer operation instructions. In this embodiment of the invention, the memory 10 may store programs for implementing the following functions: The statement is used to obtain natural language input; the statement contains a description of the event backtesting logic. The pre-trained proprietary large language model is used to parse the sentences to obtain structured backtesting parameters. The structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, which are obtained by the structured event semantic objects through the template recursive replacement mechanism. Using a backtesting engine, backtesting simulations are performed based on structured backtesting parameters to obtain a sequence of buying and selling behaviors, and backtesting quantitative results are calculated based on the buying and selling behavior sequence. Among them, the pre-trained proprietary large language model is a large language model obtained by training the model on the proprietary training dataset and by training the model on the training dataset based on the data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
[0084] In one possible implementation, the memory 10 may include a program storage area and a data storage area, wherein the program storage area may store the operating system and applications required for at least one function; and the data storage area may store data created during use.
[0085] Furthermore, memory 10 may include read-only memory and random access memory, providing instructions and data to the processor. A portion of the memory may also include NVRAM. The memory stores operating systems and operating instructions, executable modules, or data structures, or subsets thereof, or extended sets thereof, wherein the operating instructions may include various operating instructions for implementing various operations. The operating system may include various system programs for implementing various basic tasks and handling hardware-based tasks.
[0086] Processor 20 can be a central processing unit (CPU), an application-specific integrated circuit, a digital signal processor, a field-programmable gate array, or other programmable logic device. Processor 20 can be a microprocessor or any conventional processor. Processor 20 can call programs stored in memory 10.
[0087] Communication interface 31 can be an interface for the communication module, used to connect with other devices or systems.
[0088] Of course, it should be noted that, Figure 6The structure shown does not constitute a limitation on the backtesting device in the embodiments of the present invention. In practical applications, the backtesting device may include... Figure 6 More or fewer components as shown, or combinations of certain components.
[0089] The computer-readable storage medium provided in the embodiments of the present invention is described below. The computer-readable storage medium described below can be referred to in correspondence with the backtesting method described above.
[0090] The present invention also provides a computer-readable storage medium storing a computer program, which, when executed by a processor, implements the steps of the backtesting method described above.
[0091] The computer-readable storage medium may include various media capable of storing program code, such as USB flash drives, portable hard drives, read-only memory (ROM), random access memory (RAM), magnetic disks, or optical disks.
[0092] The various embodiments in this specification are described in a progressive manner, with each embodiment focusing on its differences from other embodiments. Similar or identical parts between embodiments can be referred to interchangeably. For the apparatus disclosed in the embodiments, since it corresponds to the method disclosed in the embodiments, the description is relatively simple; relevant parts can be referred to in the method section.
[0093] Those skilled in the art will further recognize that the units and algorithm steps of the various examples described in conjunction with the embodiments disclosed herein can be implemented in electronic hardware, computer software, or a combination of both. To clearly illustrate the interchangeability of hardware and software, the components and steps of the various examples have been generally described in terms of functionality in the foregoing description. Whether these functions are implemented in hardware or software depends on the specific application and design constraints of the technical solution. Those skilled in the art can use different methods to implement the described functions for each specific application, but such implementations should not be considered beyond the scope of this invention.
[0094] Finally, it should be noted that in this document, relationships such as "first" and "second" are used merely to distinguish one entity or operation from another, and do not necessarily require or imply any such actual relationship or order between these entities or operations. Furthermore, the terms "comprising," "including," or any other variations are intended to cover non-exclusive inclusion, such that a process, method, article, or apparatus that comprises a list of elements includes not only those elements but also other elements not expressly listed, or elements inherent to such process, method, article, or apparatus.
[0095] The foregoing has provided a detailed description of a backtesting method, apparatus, device, and computer-readable storage medium provided by the present invention. Specific examples have been used to illustrate the principles and implementation methods of the present invention. The descriptions of the above embodiments are only for the purpose of helping to understand the method and core ideas of the present invention. At the same time, for those skilled in the art, there will be changes in specific implementation methods and application scope based on the ideas of the present invention. Therefore, the content of this specification should not be construed as a limitation of the present invention.
Claims
1. A backtesting method, characterized in that, include: Acquire a statement as natural language input; the statement contains an event backtesting logic description; The statement is parsed using a pre-trained proprietary large language model to obtain structured backtesting parameters; the structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, obtained by a template recursive replacement mechanism from structured event semantic objects. Using the backtesting engine, backtesting simulation is performed based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and backtesting quantitative results are calculated based on the buy-sell behavior sequence. The pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
2. The backtesting method according to claim 1, characterized in that, Before parsing the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters, the process also includes: Acquire historical financial text data, and construct a proprietary training dataset based on the historical financial text data to support tasks such as masked language modeling, event time-series sequencing, and financial causal reasoning. The general large language model is pre-trained based on the proprietary training dataset. When the first training termination condition is met, the initial large language model is obtained. The initial large language model is trained on the training dataset using the data, and the pre-trained proprietary large language model is obtained when the second training termination condition is met. The structured backtesting parameters in the training dataset are parameters constructed according to the specifications of the preset template library and module library.
3. The backtesting method according to claim 2, characterized in that, The general-purpose large language model is pre-trained based on the aforementioned proprietary training dataset. When the first training termination condition is met, an initial large language model is obtained, including: The general large language model is pre-trained based on the proprietary training dataset, and the first total loss value is output based on the first loss function. When the first total loss value of the output reaches convergence, the first largest language model is obtained; The expression for the first loss function is: ; in, This is the first total loss value; This represents the loss value for the masked language model. Loss values are sorted by event time sequence; This represents the loss value for causal inference. , and These are the weight hyperparameters for the masked language model loss, the event sequence ranking loss, and the causal inference loss, respectively.
4. The backtesting method according to claim 2, characterized in that, The initial large language model is trained on the training dataset using the data described above. When the second training termination condition is met, the pre-trained proprietary large language model is obtained, including: The initial large language model is trained on the training dataset based on the data, and a second total loss value is output based on the second loss function; When the output of the second total loss value reaches convergence, the pre-trained proprietary large language model is obtained; The expression for the second loss function is: ; in, This represents the second total loss value; N is the total number of training samples. The length of the structured backtesting parameters for the i-th sample; For large language model parameters Below, based on The prediction is exactly The probability of; The t-th term in the target structured backtesting parameters of the i-th sample; The input structured event semantic object is the i-th training sample; These are parameters for a large language model.
5. The backtesting method according to any one of claims 1 to 4, characterized in that, The statement is parsed using a pre-trained proprietary large language model to obtain structured backtesting parameters, including: The statement is parsed to obtain a structured event semantic object; Based on the backtest-specific template library, backtest-specific module library, and the structured event semantic object, the placeholders in the template are recursively parsed layer by layer and replaced by the placeholder-module-semantic object element mapping until all placeholders are replaced with specific parameters, thus obtaining the structured backtest parameters. The template library defines a backtesting logic framework, including placeholders corresponding to backtesting scenarios, and the templates adopt a directed acyclic graph structure; the module library contains backtesting-specific algorithm modules, forming a bidirectional mapping relationship with the template library.
6. The backtesting method according to claim 5, characterized in that, After using the backtesting engine to perform backtesting simulation based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and calculating the backtesting quantitative results based on the buy-sell behavior sequence, the method further includes: The visualization module integrates the backtesting quantitative results, the buying and selling behavior sequence, and the structured event semantic object into a multi-dimensional, exchangeable visual display output; the backtesting quantitative results include at least the performance indicator quantitative results and the risk indicator quantitative results.
7. The backtesting method according to claim 1, characterized in that, Using the backtesting engine, backtesting simulations are performed based on the structured backtesting parameters to obtain a buy-sell behavior sequence, and backtesting quantitative results are calculated based on the buy-sell behavior sequence, including: Based on the target, backtesting time range, and event type in the structured backtesting parameters, obtain target data from the target data source; Using the backtesting engine, backtesting simulations are performed based on the event triggering conditions and trading rules in the structured backtesting parameters, as well as the target data, to generate the trading behavior sequence.
8. A backtesting device, characterized in that, include: The query language acquisition module is used to acquire statements input in natural language. The statement contains a description of the event backtesting logic; The large model parsing module is used to parse the statement using a pre-trained proprietary large language model to obtain structured backtesting parameters. The structured backtesting parameters are configuration objects that can be directly executed and read by the backtesting engine, obtained by a template recursive replacement mechanism from structured event semantic objects. The backtesting module is used to perform backtesting simulation using the backtesting engine and the structured backtesting parameters to obtain a buy-sell behavior sequence, and to calculate the backtesting quantitative results based on the buy-sell behavior sequence. The pre-trained proprietary large language model is a large language model obtained by training the model on a proprietary training dataset and by training the model on a training dataset based on data; the data pair is a data pair consisting of structured event semantics used for training and structured backtesting parameters used for training.
9. A backtesting device, characterized in that, include: Memory, used to store computer programs; A processor for executing the computer program to implement the backtesting method as described in any one of claims 1 to 7.
10. A computer-readable storage medium, characterized in that, The computer-readable storage medium stores computer-executable instructions, which, when loaded and executed by a processor, implement the backtesting method as described in any one of claims 1 to 7.