Transaction strategy data analysis method and device and storage medium
By analyzing the declaration code to generate target codes and determining transaction signals, the high time cost problem caused by manual modification of code logic in the existing financial visualization system is solved, and the effect of quickly responding to changes in strategy indicators and reducing the time cost of trading strategies is achieved.
Patent Information
- Application Number
- CN202510341046.8
- Authority / Receiving Office
- CN · China
- Patent Type
- Applications(China)
- Current Assignee / Owner
- Filing Date
- 2025-03-21
- Publication Date
- 2025-07-25
AI Technical Summary
When building and evaluating trading strategy indicators, the existing financial visualization system needs to manually modify the back-end code logic, resulting in a high time cost for quantitative trading strategies.
By analyzing the declaration code received by the transaction data visualization interface, determining the relevant variables and operation instructions, generating a variable call tree, and generating the target code based on this, obtaining the execution result to determine the transaction signal, and finally rendering the transaction data view in the visualization interface.
It realizes that it can quickly respond to changes in strategy indicators without manually writing code, reduces the time cost of quantitative trading strategies, and improves the flexibility and efficiency of the system.
Smart Images

Figure CN120371279A_ABST
Abstract
Description
Technical Field
[0001] This application relates to the technical field of data processing, and particularly to a data analysis method, device, and storage medium for trading strategies. Background Art
[0002] Financial visualization aims to help users quantify trading strategies and better understand and analyze complex financial data through visualization technology. The core idea of quantitative trading strategies is to use statistical models to model variables that affect the returns of trading products based on historical trading data of trading products, and to quantify the performance of various strategy indicators of quantitative trading strategies on different trading products. However, when constructing and evaluating strategy indicators in current financial visualization systems, it is necessary to write code logic for generating trading signals and drawing key information for multiple strategy indicators at the backend. When the strategy indicators change, it is necessary to manually modify the code logic at the backend, resulting in a high time cost for quantitative trading strategies.
[0003] The above content is only used to assist in understanding the technical solution of this application, and does not represent an admission that the above content is prior art. Summary of the Invention
[0004] The main purpose of this application is to provide a data analysis method, device, and storage medium for trading strategies, aiming to solve the technical problem of high time cost of quantitative trading strategies.
[0005] To achieve the above purpose, this application proposes a data analysis method for trading strategies, and the method includes: Determine relevant variables, operation instructions corresponding to the relevant variables, and call relationships between the relevant variables according to the declaration code received by the trading data visualization interface; Generate a variable call tree based on the relevant variables and the call relationships, and generate target code based on the operation instructions and the variable call tree; Obtain the execution result of the target code, and determine a trading signal according to the execution result; Render and output a trading data visualization view on the trading data visualization interface according to the execution result and the trading signal.
[0006] In an embodiment, before the step of determining relevant variables, operation instructions corresponding to the relevant variables, and call relationships between the relevant variables according to the declaration code received by the trading data visualization interface, the method further includes: Output the trading data visualization interface, and a code editing control is set in the trading data visualization interface; In response to a trigger operation of the code editing control, display a code editing interface; Obtain the declarative code in response to an editing action received by the code editing interface.
[0007] In one embodiment, the step of generating a variable call tree according to the relevant variables and the call relationship includes: Determine each policy metric in the declarative code, and use each policy metric as the root node of the variable call tree; Determine the time series data corresponding to each policy metric, and use the time series data as the leaf node of each policy metric; Determine the arithmetic instructions in the time series data and the arithmetic parameters called in the arithmetic instructions, and use the arithmetic parameters as the leaf nodes of the time series data.
[0008] In one embodiment, the step of generating target code based on the arithmetic instructions and the variable call tree includes: According to the root node of the variable call tree, obtain the code blocks corresponding to each policy metric, and determine the variable names to be replaced in the code blocks; Replace the variable names to be replaced in each code block with the time series data corresponding to each policy metric to update the code blocks; Determine an arithmetic function according to the arithmetic instructions; Generate the target code according to the updated code blocks and the arithmetic function.
[0009] In one embodiment, before the step of obtaining the execution result of the target code and determining a trading signal according to the execution result, it further includes: Obtain historical trading data of a trading product; Use the historical trading data and the values corresponding to the terminal sub-nodes of the variable call tree as the input data of the target code, and run the target code to obtain the execution result.
[0010] In one embodiment, the trading data visualization interface includes a first view area, and at least one K-line chart and a line chart are included in the first view area, wherein the K-line chart is used to display the historical trading data of a trading product, the line chart is used to display the time series data, and a time selection control is arranged below the K-line chart; The step of rendering and outputting a trading data visualization view on the trading data visualization interface according to the execution result and the trading signal includes: In response to a trigger operation received by the time selection control, determine the display time period of the K-line chart and the line chart; Render and output the K-line chart according to the historical transaction data of the transaction product during the display time period, and render and display the transaction signal in the K-line chart; Determine the values of the time series data corresponding to each of the strategy indicators according to the execution result, and render and output the line chart according to the values of the time series data, wherein one strategy indicator corresponds to one line chart, and the values of the time series data are calculated based on the historical transaction data of the transaction product during the display time period.
[0011] In one embodiment, before the step of obtaining the execution result of the target code and determining the transaction signal according to the execution result, the method further includes: Determine the evaluation time period and the evaluation end condition corresponding to the trading strategy according to the statement code received by the trading data visualization interface; Update the target code according to the evaluation time period and the evaluation end condition.
[0012] In one embodiment, the trading data visualization interface includes a second view area, and the second view area includes at least one scatter plot, and each point in the scatter plot represents a trading product. The step of rendering and outputting a trading data visualization view on the trading data visualization interface according to the execution result and the trading signal includes: Determine the evaluation data corresponding to the trading strategy according to the execution result, wherein the evaluation data is calculated based on the historical transaction data of the trading product during the evaluation time period and the evaluation end condition; Render and output the scatter plot according to the evaluation data, wherein the evaluation data includes one or more of the number of transactions, success rate, average return rate, and total profit.
[0013] In addition, to achieve the above object, the present application also provides a data analysis device for trading strategies, the device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the data analysis method for trading strategies as described above.
[0014] In addition, to achieve the above object, the present application also provides a storage medium, the storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the data analysis method for trading strategies as described above are implemented.
[0015] The present application provides a data analysis method for trading strategies. According to the statement code received by the trading data visualization interface, relevant variables, operation instructions corresponding to the relevant variables, and the call relationships between the relevant variables are determined; a variable call tree is generated based on the relevant variables and call relationships, and target code is generated based on the operation instructions and the variable call tree; the execution result of the target code is obtained, and a trading signal is determined according to the execution result; according to the execution result and the trading signal, a trading data visualization view is rendered and output on the trading data visualization interface. This method automatically generates target code by parsing the statement code, without manually writing the code logic for generating trading signals and drawing key information for multiple strategy indicators, and can quickly respond to changes in strategy indicators, reducing the time cost of quantitative trading strategies. BRIEF DESCRIPTION OF THE DRAWINGS
[0016] The accompanying drawings herein are incorporated into and constitute a part of this specification, showing embodiments consistent with the present application, and are used together with the specification to explain the principles of the present application.
[0017] To more clearly illustrate the technical solutions in the embodiments of the present application or the prior art, the following will briefly introduce the accompanying drawings required for use in the description of the embodiments or the prior art. Obviously, for those of ordinary skill in the art, other drawings can be obtained based on these drawings without creative efforts.
[0018] Figure 1 It is a schematic flowchart provided for Embodiment 1 of the data analysis method for the trading strategy of the present application; Figure 2 It is a schematic diagram of a variable call tree provided for Embodiment 1 of the data analysis method for the trading strategy of the present application; Figure 3 It is a schematic flowchart provided for Embodiment 2 of the data analysis method for the trading strategy of the present application; Figure 4 It is a schematic diagram of the trading data visualization interface provided for Embodiment 2 of the data analysis method for the trading strategy of the present application; Figure 5 It is a schematic flowchart provided for Embodiment 3 of the data analysis method for the trading strategy of the present application; Figure 6 It is a schematic diagram of a scatter plot provided for Embodiment 3 of the data analysis method for the trading strategy of the present application; Figure 7 It is a schematic flowchart provided for Embodiment 4 of the data analysis method for the trading strategy of the present application; Figure 8 It is a schematic diagram of a bar code tree provided for Embodiment 4 of the data analysis method for the trading strategy of the present application; Figure 9The schematic diagram of the device structure of the hardware operating environment involved in the data analysis method of the trading strategy in the embodiments of the present application.
[0019] The implementation, functional features, and advantages of the present application will be further described in conjunction with the embodiments and with reference to the accompanying drawings. Specific embodiments
[0020] It should be understood that the specific embodiments described herein are only used to explain the technical solutions of the present application and are not used to limit the present application.
[0021] To better understand the technical solutions of the present application, the following will be described in detail in conjunction with the drawings of the specification and specific embodiments.
[0022] Financial visualization aims to help users quantify trading strategies and better understand and analyze complex financial data through visualization techniques. The core idea of the quantitative trading strategy is to use statistical models to model the variables affecting the returns of trading products based on the historical trading data of trading products, and to quantify the performance of each strategy indicator of the quantitative trading strategy on different trading products. However, when constructing and evaluating strategy indicators in the current financial visualization system, it is necessary to write the code logic for generating trading signals and drawing key information for multiple strategy indicators at the backend. When the strategy indicators change, it is necessary to manually modify the code logic at the backend, resulting in a high time cost for the quantitative trading strategy.
[0023] In view of the above problems, the present application proposes a data analysis method for trading strategies, which determines relevant variables, the operation instructions corresponding to the relevant variables, and the call relationships between the relevant variables according to the declaration code received by the trading data visualization interface; generates a variable call tree according to the relevant variables and call relationships, and generates target code based on the operation instructions and the variable call tree; obtains the execution result of the target code, and determines the trading signal according to the execution result; renders and outputs the trading data visualization view on the trading data visualization interface according to the execution result and the trading signal. This method can automatically generate target code by parsing the declaration code, without the need to manually write the code logic for generating trading signals and drawing key information for multiple strategy indicators, and can quickly respond to changes in strategy indicators, reducing the time cost of quantitative trading strategies.
[0024] It should be noted that the execution subject of this embodiment can be a computing service device with data processing, network communication, and program running functions, such as a tablet computer, a personal computer, etc., or an electronic device, a trading data visualization system, etc. that can implement the above functions. The following takes the trading data visualization system as an example to illustrate this embodiment and the following embodiments.
[0025] Based on this, the first embodiment proposed by the present application provides a data analysis method for trading strategies, referring to Figure 1, in this embodiment, the data analysis method of the trading strategy includes steps S10 to S40: Step S10, determine relevant variables, the arithmetic instructions corresponding to the relevant variables, and the call relationships between the relevant variables according to the declaration code received by the trading data visualization interface.
[0026] It should be noted that the declaration code defines the construction rules of the strategy indicators of a trading strategy. When constructing strategy indicators, the construction elements include construction data, data operations, and trading signals. Among them, the construction data in the construction elements is time series data, which can be variables, such as the opening price, closing price, highest price, lowest price, etc. of a trading product every day; it can also be constants, such as the constant values preset in specific strategy indicators. Data operation refers to the operations that the construction data needs to perform when constructing strategy indicators, such as arithmetic operations based on time series, logical comparison operations, and aggregation operations such as calculating the average value and variance. The construction data corresponding to each strategy indicator can generate trading signals through different data operations, such as bullish signals and bearish signals. Among them, the bullish signal refers to the best buying time of the trading product predicted by this strategy indicator, and the bearish signal refers to the best selling time predicted by this strategy indicator.
[0027] Exemplarily, the user can customize the syntax rules of the declaration code. The system first identifies the variable names and arithmetic instructions in the declaration code, and then determines the call relationships between the variables according to the customized syntax rules.
[0028] Specifically, assume that the trading data visualization interface receives the following declaration code: “{indicators": {"name":"MACD" "shortterm":"EMA(close,12)", "longterm":"EMA(close,26)", "long":"cross(shortterm,longterm)", "short":"cross(longterm,shortterm)"}, {"name":"rsi" "price":"RSI(close,14)", "up":"70", "down":"30", "long":"cross(price,down)" "short":"cross(up,price)"}]}” Among them, the function name of the declared code is "indicators", which defines the name of the strategy indicator with "name", the long signal with "long", and the short signal with "short". Exemplarily, in the above declared code, the strategy indicators "MACD" and "name" are included. Among them, the strategy indicator "MACD" needs to call the intermediate variables "shortterm" and "longterm" when generating trading signals. Both the "shortterm" variable and the "longterm" variable are time series data of data operations. Among them, the "shortterm" variable is calculated by the exponential moving average (EMA, Exponential Moving Average) method with a window length of 12 for the operation parameter "close", and the "longterm" variable is calculated by the exponential moving average method with a window length of 12 for the operation parameter "close". In this example, "close" represents the historical closing price of the trading product. When generating trading signals, the "cross(ts1, ts2)" function used by the "MACD" indicator is also a data operation, which means that the value of the time series data ts1 at the current moment is greater than the time series data ts2, and the value of the time series data ts1 at the previous moment is less than the time series data ts2. That is, in the "MACD" indicator, the long signal "long" is generated at the moment when the "shortterm" variable exceeds the "shortterm" variable.
[0029] According to the above declared code received by the trading data visualization interface, the system first identifies the variable names "shortterm", "longterm", "long", and "short", as well as the operation instructions "EMA" and "cross", and then determines the operation parameters "close", "12", and "26" corresponding to the operation instructions and the call relationships between the above relevant variables according to the predefined syntax rules.
[0030] Step S20, generate a variable call tree according to the relevant variables and the call relationships, and generate target code based on the operation instructions and the variable call tree.
[0031] It should be noted that the variable call tree is a tree structure that graphically represents the dependency relationships between relevant variables. In this embodiment, the root node of the tree represents the constructed indicator, and the leaf nodes represent other relevant variables called to construct the root node.
[0032] Optionally, determine each policy metric in the declaration code, and use each policy metric as the root node of the variable call tree; determine the time series data corresponding to each policy metric, and use the time series data as the leaf node of each policy metric; determine the arithmetic instructions in the time series data and the arithmetic parameters called in the arithmetic instructions, and use the arithmetic parameters as the leaf nodes of the time series data to generate a variable call tree.
[0033] Exemplarily, refer to Figure 2 , Figure 2 which is a schematic diagram of the variable call tree provided for this embodiment and is generated from the declaration code in the above example. Among them, the root node of the variable call tree corresponding to the "MACD" indicator is "MACD", and the leaf nodes of "MACD" are the time series data "shortterm" and "longterm", that is, "EMA(close, 12)" and "EMA(close, 26)". These two time series data contain the arithmetic instruction "EMA", and the arithmetic parameters corresponding to the arithmetic instruction are used as the leaf nodes of the time series data.
[0034] Among them, if the time series data of the policy metric is a preset constant, use each policy metric as the root node of the variable call tree; use the preset constant as the leaf node of each policy metric to generate a variable call tree.
[0035] Exemplarily, refer to Figure 2 , the root node of the variable call tree corresponding to the "rsi" indicator is "rsi", and the leaf nodes of "rsi" are the time series data "price", "up" and "down", that is, "RSI(close, 14)", "70" and "30". The time series data "price" contains the arithmetic instruction "RSI", and its corresponding arithmetic parameters "close" and "14" are used as the leaf nodes of the time series data.
[0036] Optionally, after generating the variable call tree, obtain the code block corresponding to each policy metric according to the root node of the variable call tree, determine the variable names to be replaced in the code block, replace the variable names to be replaced in each code block with the time series data corresponding to each policy metric to update the code block; determine the arithmetic function according to the arithmetic instruction; generate the target code according to the updated code block and the arithmetic function.
[0037] Exemplarily, based on the structure of the variable call tree and the policy metrics represented by the root node, the system extracts code blocks corresponding to the policy metrics from existing code templates or code libraries. These code blocks can be predefined functions, classes, or code segments for implementing the basic calculation logic of the policy metrics. Subsequently, according to the definition and construction elements of the policy metrics, the system determines the mapping relationship between the variable names in the code blocks and the actual time series data. And replaces the variable names in the code blocks with the time series data in the declaration code. For example, by writing regular expressions to determine the positions of the variable names to be replaced in the code blocks, and selecting the variable names to be replaced through a code editor for batch replacement.
[0038] It can be understood that each operation instruction in the declaration code corresponds to an operation logic. The system can call the corresponding operation function according to the operation instruction, such as exponential moving average, relative strength index (RSI), etc. Then, determine the operation parameters required for the operation from the operation instruction, such as the window length of the exponential moving average, the period of the relative strength index, etc. Subsequently, integrate the updated code block and the operation function according to the syntax rules of the code to obtain the target code.
[0039] Step S30, obtain the execution result of the target code, and determine the trading signal according to the execution result.
[0040] The target code is the code that can be directly run on a computer obtained by parsing and converting the declaration code, and is used to implement the analysis function of the trading strategy. After the code is executed, the system obtains the output execution result, which includes the trading signals corresponding to each policy metric in the trading strategy and the time series data calculated according to the operation parameters, etc.
[0041] Step S40, render and output the trading data visualization view on the trading data visualization interface according to the execution result and the trading signal.
[0042] Extract the data to be visualized from the execution result of the target code, such as the calculated time series data, and convert the extracted data into a format suitable for use by a visualization library or tool, such as converting the time series data into an array or data frame format, and converting the trading signal into a graphical marker or categorical data, etc.
[0043] For different data types and analysis requirements, select appropriate visualization components. For example, line charts can be used to display the changing trend of time series data over time. Graphic markers or lines are used for trading signals to highlight the positions of bullish and bearish signals. In the trading data visualization interface, initialize the drawing environment using the selected visualization library or tool, and set basic properties such as the canvas size and background color. Plot the data to be visualized onto the visualization view according to the selected visualization components. At the same time, implement interaction functions between the user and the visualization view through operations such as displaying data details by hovering the mouse, viewing specific signal information by clicking on markers, and using toolbar buttons for chart zooming and panning. Finally, output the rendered visualization view to the trading data visualization interface, enabling users to intuitively observe and analyze trading data and trading signals to assist them in making trading decisions.
[0044] In this embodiment, by parsing the statement code received by the trading data visualization interface, target code is automatically generated and executed, and trading signals and the visualization view are rendered according to the execution result, realizing the automated conversion from statement code to executable code, reducing the workload of manually writing and modifying code, enhancing the flexibility and scalability of the system, effectively solving the problems existing in the construction and evaluation of strategy indicators in the existing financial visualization system, and providing users with a more efficient and intuitive trading strategy analysis method.
[0045] Based on the first embodiment of this application, in the second embodiment of this application, for the same or similar content as in the above-mentioned first embodiment, reference can be made to the above introduction and will not be elaborated hereinafter. On this basis, please refer to Figure 3 , before step S30, the data analysis method of the trading strategy further includes steps S50 to S60: Step S50, obtain historical trading data of the trading product.
[0046] Exemplarily, download a file containing historical trading data from the website or platform of the data provider, and then import the file into the local data processing environment. Use the application programming interface provided by the data provider to send requests programmatically to obtain historical trading data. Determine request parameters such as the trading product identifier and the time range of the trading data. If the historical trading data is stored in a database, establish a connection through a database connection tool or the database connection library of a programming language and construct a database query statement according to the request parameters to obtain the required historical trading data.
[0047] Step S60, use the historical trading data and the values corresponding to the end nodes of the variable call tree as the input data of the target code, and run the target code to obtain the execution result.
[0048] It can be understood that the variable call tree is a tree - like structure that describes the dependency relationships between related variables, and its terminal child nodes represent the data that can be directly obtained without depending on other variables. By traversing the variable call tree, find the variables corresponding to all terminal child nodes and match them with the fields in the historical transaction data. For example, if the terminal child node variable is "close" (historical closing price), then find the corresponding "close" field in the historical transaction data. Extract the value of the corresponding field in the matched historical transaction data as the value of this terminal child node variable. Then, according to the syntax rules of the target code, determine the format requirements of the input data, and integrate the obtained historical transaction data and the extracted variable values of the terminal child nodes, and convert them into data objects that meet the format requirements and input them into the target code. After the target code is executed, obtain the execution result.
[0049] Based on the above, in a feasible implementation, the trading data visualization interface includes a first view area, and the first view area includes at least one K - line chart and a line chart. The K - line chart is used to display the historical transaction data of the trading product, and the line chart is used to display time - series data. A time - selection control is set below the K - line chart. The steps of rendering and outputting the trading data visualization view in the trading data visualization interface according to the execution result and trading signals include: responding to the trigger operation received by the time - selection control to determine the display time period of the K - line chart and the line chart; rendering and outputting the K - line chart according to the historical transaction data of the trading product during the display time period, and rendering and displaying trading signals in the K - line chart; determining the values of the time - series data corresponding to each strategy indicator according to the execution result, and rendering and outputting the line chart according to the values of the time - series data. Among them, one strategy indicator corresponds to one line chart, and the values of the time - series data are calculated based on the historical transaction data of the trading product during the display time period.
[0050] Exemplarily, referring to Figure 4 , Figure 4The trading data visualization interface provided by this embodiment, where the left B area is the first view area. There is a candlestick chart in the upper part B1 area of the first view area, which shows the trading data of a certain trading product in 2023. Among them, the trading signals corresponding to the trading strategy are marked with arrows in the candlestick chart. The arrow pointing upward is a bullish signal, and the arrow pointing downward is a bearish signal. Since the historical trading data of the trading product covers a relatively long time interval, a slider is used as a time selection control in the B2 area below the candlestick chart to select which time period of data to display. The rectangular brush selection area of the slider represents the display time period of the current candlestick chart and line chart. When the user wants to view the historical trading data of other time periods, they can drag the rectangular slider for data brushing, and the candlestick chart and line chart will automatically update the display data according to the brushing area. The triangle at the bottom of the slider represents the trading signals in all time intervals. In practical applications, the bullish signal and bearish signal can be distinguished by colors. For example, the bullish signal is represented by a red triangle, and the bearish signal is represented by a green triangle. There are 3 line charts in the lower part B3 area of the first view area, which respectively correspond to the "MACD" indicator, "rsi" indicator, and "boll" indicator, and the time series data corresponding to the indicators are displayed as lines in the figure.
[0051] Optionally, when it is detected that the mouse moves to the candlestick chart area, a crosshair is used to mark the mouse movement position. The date corresponding to the current position is displayed at the bottom of the crosshair, and the detailed historical trading data at the current position is displayed at the top of the candlestick chart. Exemplarily, referring to Figure 4 , in the upper part of the candlestick chart, "O" represents the opening price, "C" represents the historical closing price, "H" represents the historical highest price, and "L" represents the historical lowest price. When a selection action on the line chart is detected, a border is displayed in the current line chart area to indicate selection. At the same time, only the trading signals of the strategy indicators corresponding to this line chart are displayed for the trading signals in the candlestick chart. As shown in the figure, after the "MACD" indicator is selected, the arrows in the candlestick chart and the vertical lines of the trading signals in the line chart are in one-to-one correspondence.
[0052] In this embodiment, by introducing the historical data acquisition and integration step, the data analysis method of the trading strategy is further improved. Before executing the target code, the historical trading data of the trading product is obtained and combined with the values of the end nodes of the variable call tree as the input of the target code, ensuring the comprehensiveness and accuracy of the evaluation. At the same time, in the design of the visualization interface, through the K-line chart and line chart in the first view area, the historical trading data and time series data are intuitively displayed. Users can flexibly adjust the display time period with the time selection control to achieve focused analysis of the trading data and signals in a specific period. In addition, the interface also supports interactive data exploration. When the mouse hovers, detailed data can be viewed, and corresponding trading signals can be filtered after selecting specific strategy indicators, further enhancing the flexibility and depth of data analysis and optimizing the visualization effect.
[0053] Based on the above embodiments of the present application, in the third embodiment of the present application, the same or similar content as the above embodiments can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 5 , before step S30, the data analysis method of the trading strategy further includes steps S70~S80: Step S70, determine the evaluation time period and evaluation end condition corresponding to the trading strategy according to the declaration code received by the trading data visualization interface.
[0054] Step S80, update the target code according to the evaluation time period and the evaluation end condition.
[0055] Exemplarily, assume that the trading data visualization interface receives the following declaration code: “{"indicators": {"name":"MACD" "shortterm":"EMA(close,12)", "longterm":"EMA(close,26)", "long":"cross(shortterm,longterm)", "short":"cross(longterm,shortterm)"}], "evaluation":{ "period":["2023-07-01","2024-07-01"], "stop":[{ "ahead":"5", "stopless":"0.05",}] } }" Among them, the evaluation time period is "period", and the evaluation end condition is "stop". In the evaluation end condition, it includes the fixed maximum number of days "ahead" condition for forcibly ending the transaction after generating a trading signal and the stop-loss condition "stoploss". That is, for this trading strategy, in the test time interval from July 1, 2023 to July 1, 2024, after generating a trading signal, the transaction will end within at most 5 days, when the loss reaches 5%, or when the next opposite trading signal is generated, and the evaluation data is calculated.
[0056] Exemplarily, the system queries the "period" field and "stop" field in the declaration code, replaces the variable names "period" and "stop" in the target code with the corresponding values of the "period" field and "stop" field in the declaration code, and updates the target code. After the target code is executed, the execution result of the target code is obtained.
[0057] Based on the above content, in a feasible implementation, the trading data visualization interface includes a second view area. The second view area includes at least one scatter plot. Each data point in the scatter plot represents a trading product. The steps of rendering and outputting the trading data visualization view on the trading data visualization interface according to the execution result and the trading signal include: determining the evaluation data corresponding to the trading strategy according to the execution result, where the evaluation data is calculated based on the historical trading data of the trading product within the evaluation time period and the evaluation end condition; rendering and outputting the scatter plot according to the evaluation data, where the evaluation data includes one or more of the number of trades, success rate, average return rate, and total profit.
[0058] Exemplarily, referring to Figure 4 , the upper right C area of the trading data visualization interface is the second view area, and there is a scatter plot in the C4 area on the right side of the second view area. Among them, each data point in the scatter plot represents a trading product.
[0059] Exemplarily, referring to Figure 6 , when the declaration code is not obtained, the colors of all points in the scatter plot are the initial colors, such as blue. After the target code is executed, in response to the click action of the first button a on the left side at the top of the scatter plot, the execution results of all trading products corresponding to the current trading strategy are obtained, and the evaluation data is determined according to the execution results. The size of the evaluation data is displayed in the scatter plot in terms of the depth of color. Among them, the size of the evaluation data and the depth of color can be directly proportional or inversely proportional.
[0060] Optionally, a thumbnail is set in the scatter plot, and the user can view the detailed information of different regions by zooming in and out with the mouse and dragging the mouse in the scatter plot. In response to the click action of the second button b from the left at the top of the scatter plot, a filtering interface is displayed. The filtering interface shows the distribution of the evaluation data, and the user can set multiple filtering conditions by dragging the slider or entering data in the input box. For example, in Figure 6 , filtering conditions are set that the success rate "successRate" is greater than 0.5, the average return rate "avgReturn" is greater than 0, and the total profit "totalProfit" is greater than 0. After the filtering conditions are set, the user clicks the confirmation button c at the bottom of the filtering interface to execute the filtering conditions in the scatter plot, and the scatter plot will mark the data points of the trading products not filtered out as gray. Then, after the user clicks the third button d from the left at the top of the scatter plot, the stock list can be managed in the trading product selection box e. The left selection box shows all the trading products that the user can select, and the right selection box shows the trading products that the user has selected. And the individual trading products shown in the candlestick chart are marked with five-pointed stars. The user can add trading products from the left trading product list to the right list, delete the data items in the right list, or modify the individual trading products selected in the right list and shown in the candlestick chart.
[0061] Optionally, referring to Figure 4, a parallel coordinate plot is set in the C1 area of the second view area, a curve box plot is set in the C2 area, and a sunburst box plot is set in the C3 area. Among them, the parallel coordinate plot summarizes the performance of different strategy indicators in the trading strategy from four dimensions: the number of trades "totalTrades", success rate, average return rate, and total profit. The parallel coordinate plot is a visualization method that maps multi-dimensional data onto a two-dimensional plane. It represents each dimension through a set of parallel coordinate axes, and the values of each data point on each dimension are connected by a broken line. By observing the distribution and intersection of the broken lines, the differences in the same dimension, the distribution characteristics in different dimensions, and the correlations between dimensions of the data can be intuitively reflected. The box plot is a statistical chart used to display the distribution of a set of data. It provides intuitive information about the central tendency, dispersion, and skewness of the data set by showing the minimum value, the first quartile, the median, the third quartile, and the maximum value of the data. The box plot consists of a box and whiskers. The height of the box is the interquartile range of the data, that is, the value of the third quartile minus the first quartile. The upper whisker in the whiskers represents the maximum value of the data, and the lower whisker represents the minimum value of the data. In the curve box plot, the whiskers are formed by the bands of the boundary of the curve set, and the box area is represented in dark color. Because when evaluating the performance of strategy indicators, it is necessary to summarize the trading process data after multiple trading signal triggers, so in this embodiment, the profit fluctuation after the trading signal is triggered is defined as a curve set, and the visualization design of the curve box plot is used as a supplement to the parallel coordinate plot to show a more detailed evaluation process beyond the final result.
[0062] Among them, the sunburst box plot is a view that combines the box plot design on the basis of the sunburst chart. The sunburst chart is a visualization chart used to display the hierarchical information of categorical data. It represents the hierarchical structure of the data in the form of concentric sectors or rings. The sectors or rings with the same radius represent a level, and the different divided areas represent different categories. For example, Figure 4 in the sunburst box plot in [reference], there is a ring with 3 different areas at the same level. The 3 different areas represent the "MACD" indicator, the "rsi" indicator, and the "boll" indicator respectively. The inner ring of the sunburst box plot is the main dimension, and the arc length of the ring is used to represent the distribution of the main dimension data, that is, the number of trades. The outer arc combines the box plot design to show the distribution of another dimension data under the main dimension data. Among them, a dotted line is used in the outer arc to represent the position where the return rate is 0, and users can intuitively judge the positive and negative of the return rate according to the position of the dotted line and the arc. In addition, for the box plot with a return rate median less than 0, the box area is set without filling, which is also to let users intuitively judge the positive and negative of the return rate median. Below the sunburst box plot, the different trading products represented by the colors of each whisker in the box plot of the outer arc are marked.
[0063] In this embodiment, by adding the dynamic update of the evaluation time period and end conditions, as well as the visual display of multi-dimensional evaluation data, to the trading strategy data analysis method, the system can automatically update the evaluation time period and end conditions in the target code according to the "period" and "stop" fields in the declaration code, achieving flexible adjustment of evaluation parameters without manually modifying the code, saving time and labor costs. At the same time, in the second view area of the visualization interface, through various visualization forms such as scatter plots, parallel coordinate plots, curve box plots, and sunburst box plots, the evaluation data of the trading strategy are comprehensively displayed, including key indicators such as the number of trades, success rate, average return rate, and total profit. Users can not only intuitively compare the performance of different trading products, but also deeply analyze the effectiveness and stability of the strategy through interactive filtering and detailed data analysis. In addition, the display of trading signals combined with K-line charts and line charts, as well as the assistance of various statistical charts, provides users with a comprehensive perspective on trading strategy evaluation, greatly enhancing the comprehensiveness of data analysis.
[0064] Based on the above embodiments of the present application, in the fourth embodiment of the present application, the same or similar content as the above embodiments can be referred to the above introduction and will not be repeated hereinafter. On this basis, please refer to Figure 7 , before step S10, the data analysis method of the trading strategy further includes steps S90~S110: Step S90, output the trading data visualization interface, and a code editing control is set in the trading data visualization interface.
[0065] Step S100, in response to the trigger operation of the code editing control, display the code editing interface.
[0066] Step S110, in response to the editing action received by the code editing interface, obtain the declaration code.
[0067] Exemplarily, referring to Figure 4 , there is a code editing control A in the lower right corner of the trading data visualization interface. After the user clicks the code editing control A, the code editing interface will be displayed, and the user can write the declaration language in the code editing interface. After completion, click the update code control in the code editing interface to execute the steps of determining relevant variables, the arithmetic instructions corresponding to the relevant variables, and the call relationships between the relevant variables according to the declaration code received by the trading data visualization interface, generating a variable call tree based on the relevant variables and call relationships, and generating the target code based on the arithmetic instructions and the variable call tree.
[0068] Optionally, the trading data visualization interface includes a third view area, such as Figure 4As shown in the figure, the lower right D area of the transaction data visualization interface is the third view area. The third view area includes a policy iteration tree within the D1 area and a barcode tree within the D2 area. The role of the policy iteration tree is to record the iteration process of the user constructing multiple trading strategies. Each node in the policy iteration tree represents a trading strategy defined by the user, and the node color indicates the evaluation result difference of different strategies under the evaluation method selected in the radio box. In actual use, when the user clicks to select a certain node, the code editing box will display the declaration code of the current trading strategy, and the user can make adjustments based on the current trading strategy. After completing the modification, click the save button above the policy iteration tree, and the policy iteration tree will generate a new child node on the right side of the original node, representing a new strategy iteratively generated based on the original current trading strategy. Using the policy iteration tree view, the user can clearly observe the changes in the evaluation of each trading strategy during the iteration process, and can also conveniently iterate strategies based on different historical trading strategy versions.
[0069] First, for the barcode tree part, the call relationships of relevant variables in the declaration code describing the trading strategy are visualized using a barcode tree. The barcode tree is a visualization design that is good at comparing a large number of trees on a large scale. It can display multiple shallow and stable trees on one screen simultaneously without aggregating individual nodes. The barcode tree is shown by linearizing each tree into a row and adopting a barcode-like style, so that the trees can be stacked vertically and the matching nodes can be aligned horizontally for easy comparison and improved space utilization efficiency. Figure 4 The figure shows the barcode tree after three trading strategies are stacked vertically. With this design, the user can first intuitively observe at a coarse-grained level that the first trading strategy uses the "MACD" indicator, "rsi" indicator, and "boll" indicator in the technical indicator part, the second trading strategy uses the "rsi" indicator, the third trading strategy uses the "boll" indicator, and all three strategies set the evaluation time period "period" and the evaluation end condition "stop" in the evaluation part. If the user wants to observe more fine-grained information in the trading strategy, they can click on the barcode tree view to expand the barcode tree. Figure 8Taking the first trading strategy in the vertically stacked barcode tree as an example, the barcode tree in the fully expanded state is shown: In the indicator part of the first trading strategy, there are three trees, namely "MACD", "rsi", and "boll". Among them, the child nodes of the "MACD" tree are the data operations "EMA(close,12)" and "EMA(close,26)" that describe the exponential moving average. The child nodes of the "rsi" tree are the data "70", "30", and the data operation "rsi(close,14". The child nodes of the "boll" tree are the "close" node, "up" node, and "down" node. The next-level nodes of the "up" node and "down" node are all the data operations "EMA(close,20)" that describe the exponential moving average, the data operation "movingstd(close,26)" that describes the moving standard deviation, and the data "2". In the evaluation part, the test time interval is set from July 1, 2023, to July 1, 2024, and the early termination trading condition of a fixed maximum trading days of 2 days is set.
[0070] In this embodiment, by adding a code editing control and a visualization tool to the trading strategy data analysis method, the interactive experience and analysis efficiency of users in constructing and managing trading strategies are further improved. Users can directly write and modify the declaration code through the code editing control in the trading data visualization interface. The system responds to the editing action in real time, dynamically updates the target code and relevant analysis results, and realizes the seamless connection of code writing, strategy adjustment, and result feedback. At the same time, visualization tools such as the strategy iteration tree and the barcode tree are introduced. The strategy iteration tree records the iteration process of users constructing multiple trading strategies. Each node represents a trading strategy, and the evaluation result differences of different strategies are intuitively displayed through colors, which is convenient for users to track the strategy evolution and effect optimization. The barcode tree visually displays the call relationship of relevant variables in the trading strategy in the form of a barcode, supports users to intuitively compare and analyze multiple trading strategies at a coarse-grained and fine-grained level, and improves the quantification efficiency of trading data.
[0071] It should be noted that the above examples are only for understanding this application and do not constitute a limitation on the data analysis method of the trading strategy of this application. Based on this technical concept, more forms of simple transformations are within the protection scope of this application.
[0072] This application provides a data analysis device for trading strategies. The data analysis device for trading strategies includes: at least one processor; and a memory communicatively connected to the at least one processor; wherein, the memory stores instructions executable by the at least one processor, and the instructions are executed by the at least one processor so that the at least one processor can execute the data analysis method of the trading strategy in the first embodiment above.
[0073] Next, refer toFigure 9 , which shows a schematic structural diagram of a data analysis device suitable for implementing the trading strategy of the embodiments of the present application. The data analysis device for the trading strategy in the embodiments of the present application may include, but is not limited to, mobile terminals such as laptops, tablet computers (PAD, Portable Application Description), etc., and fixed terminals such as desktop computers. Figure 9 The data analysis device for the trading strategy shown is only an example and should not impose any limitations on the functions and usage scope of the embodiments of the present application.
[0074] As Figure 9 shown, the data analysis device for the trading strategy may include a processing device 1001 (such as a central processing unit, a graphics processing unit, etc.), which can perform various appropriate actions and processes according to the program stored in the read-only memory (ROM, Read Only Memory) 1002 or the program loaded from the storage device 1003 into the random access memory (RAM, Random Access Memory) 1004. In the random access memory 1004, various programs and data required for the operation of the data analysis device for the trading strategy are also stored. The processing device 1001, the read-only memory 1002, and the random access memory 1004 are connected to each other through a bus 1005. The input / output (I / O) interface 1006 is also connected to the bus. Generally, the following systems may be connected to the I / O interface 1006: an input device 1007 including, for example, a touch screen, a touchpad, a keyboard, a mouse, an image sensor, a microphone, an accelerometer, a gyroscope, etc.; an output device 1008 including, for example, a liquid crystal display (LCD, Liquid Crystal Display), a speaker, a vibrator, etc.; a storage device 1003 including, for example, a magnetic tape, a hard disk, etc.; and a communication device 1009. The communication device 1009 can allow the data analysis device for the trading strategy to communicate with other devices wirelessly or wiredly to exchange data. Although the figure shows a data analysis device for the trading strategy with various systems, it should be understood that it is not required to implement or have all the systems shown. More or fewer systems may be implemented or had alternatively.
[0075] In particular, according to the embodiments disclosed in the present application, the processes described above with reference to the flowcharts can be implemented as computer software programs. For example, the embodiments disclosed in the present application include a computer program product that includes a computer program carried on a computer-readable medium, and the computer program contains program codes for executing the methods shown in the flowcharts. In such an embodiment, the computer program can be downloaded and installed from a network through a communication device, or installed from a storage device 1003, or installed from a ROM 1002. When the computer program is executed by a processing device 1001, the above functions defined in the methods of the embodiments disclosed in the present application are executed.
[0076] The data analysis device for trading strategies provided by the present application adopts the data analysis method for trading strategies in the above embodiments, and can solve the technical problem of high time cost of quantitative trading strategies. Compared with the prior art, the beneficial effects of the data analysis device for trading strategies provided by the present application are the same as those of the data analysis method for trading strategies provided by the above embodiments, and other technical features in the data analysis device for trading strategies are the same as the features disclosed in the method of the previous embodiment, which will not be elaborated here.
[0077] It should be understood that each part disclosed in the present application can be implemented by hardware, software, firmware, or a combination thereof. In the description of the above embodiments, specific features, structures, materials, or characteristics can be combined in a suitable manner in any one or more embodiments or examples.
[0078] As described above, the above is only the specific implementation manner of the present application, but the protection scope of the present application is not limited thereto. Any person skilled in the art can easily think of changes or substitutions within the technical scope disclosed in the present application, and all should be covered by the protection scope of the present application. Therefore, the protection scope of the present application should be subject to the protection scope of the claims.
[0079] The present application provides a computer-readable storage medium having computer-readable program instructions (i.e., computer programs) stored thereon, and the computer-readable program instructions are used to execute the data analysis method for trading strategies in the above embodiments.
[0080] The computer-readable storage medium provided by the present application can be, for example, a USB flash drive, but is not limited to electrical, magnetic, optical, electromagnetic, infrared, or semiconductor systems, devices, or components, or any combination of the above. More specific examples of computer-readable storage media may include, but are not limited to: electrical connections with one or more wires, portable computer disks, hard disks, random access memory (RAM), read-only memory (ROM), erasable programmable read-only memory (EPROM), or flash memory, optical fibers, portable compact disk read-only memory (CD-ROM), optical storage devices, magnetic storage devices, or any suitable combination of the above. In this embodiment, the computer-readable storage medium can be any tangible medium that contains or stores a program, and this program can be used by or in combination with an instruction execution system, device, or component. The program code contained on the computer-readable storage medium can be transmitted using any appropriate medium, including but not limited to: wires, optical cables, radio frequency (RF), etc., or any suitable combination of the above.
[0081] The above computer-readable storage medium can be included in the data analysis device for trading strategies; it can also exist independently and not be assembled into the data analysis device for trading strategies.
[0082] The above computer-readable storage medium carries one or more programs. When the above one or more programs are executed by the data analysis device for trading strategies, the data analysis device for trading strategies can write computer program code for performing the operations of the present application in one or more programming languages or combinations thereof. The above programming languages include object-oriented programming languages - such as Java, Smalltalk, C++, and also include conventional procedural programming languages - such as the "C" language or similar programming languages. The program code can be executed entirely on the user's computer, partially on the user's computer, or executed as an independent software package, partially on the user's computer and partially on a remote computer, or entirely on a remote computer or server. In the case of a remote computer, the remote computer can be connected to the user's computer through any type of network - including a local area network (LAN) or a wide area network (WAN) - or can be connected to an external computer (for example, by using an Internet service provider to connect through the Internet).
[0083] The flowcharts and block diagrams in the accompanying drawings illustrate the possible architectures, functions, and operations of systems, methods, and computer program products according to various embodiments of the present application. In this regard, each block in the flowchart or block diagram may represent a module, a segment of a program, or a part of code, which contains one or more executable instructions for implementing a specified logical function. It should also be noted that in some alternative implementations, the functions marked in the blocks may occur in a different order than marked in the accompanying drawings. For example, two consecutive blocks shown may actually be executed substantially in parallel, and they may sometimes be executed in the reverse order, depending on the functions involved. It should also be noted that each block in the block diagram and / or flowchart, and combinations of blocks in the block diagram and / or flowchart, can be implemented by a dedicated hardware-based system that performs the specified functions or operations, or can be implemented by a combination of dedicated hardware and computer instructions.
[0084] The modules described in the embodiments of the present application can be implemented in software or in hardware. Among them, the name of the module does not constitute a limitation to the unit itself in some cases.
[0085] The readable storage medium provided by the present application is a computer-readable storage medium, and the computer-readable storage medium stores computer-readable program instructions (i.e., computer programs) for executing the data analysis method of the above-mentioned trading strategy, which can solve the technical problem of high time cost of the quantitative trading strategy. Compared with the prior art, the beneficial effects of the computer-readable storage medium provided by the present application are the same as those of the data analysis method of the trading strategy provided by the above embodiments, and will not be elaborated here.
[0086] The above are only some embodiments of the present application, and do not limit the patent scope of the present application. Any equivalent structural transformation made using the content of the specification and drawings of the present application under the technical concept of the present application, or direct / indirect application in other related technical fields, is included in the patent protection scope of the present application.
Claims
1. A data analysis method for a trading strategy, characterized in that, The data analysis method of the trading strategy includes: Determine relevant variables, operation instructions corresponding to the relevant variables, and the call relationship between the relevant variables according to the statement code received by the trading data visualization interface; Generate a variable call tree based on the relevant variables and the call relationship, and generate target code based on the operation instructions and the variable call tree; Obtain the execution result of the target code, and determine a trading signal according to the execution result; Render and output a trading data visualization view on the trading data visualization interface according to the execution result and the trading signal.
2. The data analysis method of the trading strategy according to claim 1, wherein Before the step of determining relevant variables, operation instructions corresponding to the relevant variables, and the call relationship between the relevant variables according to the statement code received by the trading data visualization interface, it further includes: Output the trading data visualization interface, and a code editing control is set in the trading data visualization interface; In response to the trigger operation of the code editing control, display a code editing interface; In response to the editing action received by the code editing interface, obtain the statement code.
3. The data analysis method of the trading strategy according to claim 1, wherein, The step of generating a variable call tree based on the relevant variables and the call relationship includes: Determine each policy indicator in the statement code, and use each policy indicator as the root node of the variable call tree; Determine the time series data corresponding to each policy indicator, and use the time series data as the leaf nodes of each policy indicator; Determine the operation instructions in the time series data and the operation parameters called in the operation instructions, and use the operation parameters as the leaf nodes of the time series data.
4. The data analysis method of the trading strategy according to claim 3, characterized in that, The step of generating target code based on the operation instructions and the variable call tree includes: According to the root node of the variable call tree, obtain the code block corresponding to each policy indicator, and determine the variable name to be replaced in the code block; Replace the variable name to be replaced in each code block with the time series data corresponding to each policy indicator to update the code block; Determine an operation function according to the operation instructions; Generate the target code according to the updated code block and the operation function.
5. The data analysis method of the trading strategy according to claim 3, wherein Before the step of obtaining the execution result of the target code and determining a trading signal according to the execution result, it further includes: Obtain the historical trading data of the trading product; Use the historical trading data and the values corresponding to the end nodes of the variable call tree as the input data of the target code, and run the target code to obtain the execution result.
6. The data analysis method of the trading strategy according to claim 5, wherein The trading data visualization interface includes a first view area, and at least one K-line chart and a line chart are included in the first view area, wherein the K-line chart is used to display the historical trading data of the trading product, the line chart is used to display the time series data, and a time selection control is set below the K-line chart; The step of rendering and outputting a trading data visualization view on the trading data visualization interface according to the execution result and the trading signal includes: Determine the display time period of the candlestick chart and the line chart in response to a trigger operation received by the time selection control; Render and output the candlestick chart according to the historical transaction data of the trading product within the display time period, and render and display the trading signal in the candlestick chart; Determine the values of the time series data corresponding to each of the strategy indicators according to the execution result, and render and output the line chart according to the values of the time series data, wherein one strategy indicator corresponds to one line chart, and the values of the time series data are calculated based on the historical transaction data of the trading product within the display time period.
7. The data analysis method of the trading strategy according to claim 1, characterized in that, Before the step of obtaining the execution result of the target code and determining the trading signal according to the execution result, the method further includes: Determine the evaluation time period and the evaluation end condition corresponding to the trading strategy according to the statement code received by the trading data visualization interface; Update the target code according to the evaluation time period and the evaluation end condition.
8. The data analysis method for the trading strategy according to claim 5, wherein The trading data visualization interface includes a second view area, and the second view area includes at least one scatter plot, and each point in the scatter plot represents a trading product. The step of rendering and outputting a trading data visualization view in the trading data visualization interface according to the execution result and the trading signal includes: Determine the evaluation data corresponding to the trading strategy according to the execution result, wherein the evaluation data is calculated based on the historical transaction data of the trading product within the evaluation time period and the evaluation end condition; Render and output the scatter plot according to the evaluation data, wherein the evaluation data includes one or more of the number of trades, success rate, average return rate, and total profit.
9. A data analysis device for a trading strategy, characterized in that, The device includes: a memory, a processor, and a computer program stored on the memory and executable on the processor, and the computer program is configured to implement the steps of the data analysis method of the trading strategy according to any one of claims 1 to 8.
10. A storage medium, characterized in that, The storage medium is a computer-readable storage medium, and a computer program is stored on the storage medium, and when the computer program is executed by a processor, the steps of the data analysis method of the trading strategy according to any one of claims 1 to 8 are implemented.