Non-equal-length similar K line matching method based on morphological coding

Through the form -based non -equal -based similar -similar K -line matching method, the use of morphological recognition technology and DTW algorithm combine the formal punishment matrix to solve the problem of K -line matching accuracy and recall rate in the existing technology, and achieve more accurate accuracy K -line similarity matching.

CN119377693APending Publication Date: 2025-01-28EAST MONEY INFORMATION CO LTD
View PDF 0 Cites 0 Cited by

Patent Information

Application Number
CN202411351066.5
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2024-09-26
Publication Date
2025-01-28

AI Technical Summary

Technical Problem

Existing similar K-line matching algorithms are difficult to capture K-line data with high matching degree in the true sense, and the matching accuracy and recall rate are not high.

Method used

Using a morphological -based non -equal -length similar K -line matching method, a complete form encoding sequence of each K -line sequence is generated through morphological recognition technology, the stock pattern coding sequence pool is constructed, and the DTW algorithm combined with the formal punishment matrix is ​​calculated.

Benefits of technology

The recall rate and accuracy of the K -line similarity matching can more accurately capture stocks with similar trends, and provide more reference price analysis and pre -judgment data.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN119377693A_ABST
    Figure CN119377693A_ABST
Patent Text Reader

Abstract

The technical scheme of the invention discloses an unequal-length similar K line matching method based on morphological coding. Through a brand new matching algorithm, more stocks with similar trends on a generalized level or a technical level are mined, a more accurate K-line similarity matching result closer to expert research and judgment is provided, the matching recall rate is improved, and data with more reference significance is provided for price trend analysis and pre-judgment. Meanwhile, on the basis of preprocessing and pre-matching of a morphological coding level, the pruning capacity of rapid preliminary screening is achieved, computing power resources are saved, and the computing efficiency is improved. Through the form coding information, the form coding information and the K line data are fused into a new matrix, non-equal length sequence similarity calculation of form perception is realized, and the matching accuracy and the recall rate are further improved.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The invention relates to a morphological coding-based unequal-length sequence matching algorithm. Background Art

[0002] In the field of financial trading and market analysis, identifying similar K-line patterns of stocks or assets is crucial for gaining insight into market dynamics and formulating trading strategies. As an intuitive reflection of price changes, the repetitiveness of the K-line chart often indicates changes in market psychology and trends. By efficiently comparing historical and current K-line sequences, traders can capture classic patterns such as head and shoulders tops and double bottoms, and even combination patterns such as rising channels + head and shoulders tops, V-shaped reversals and double bottoms, thereby assisting in predicting subsequent price trends. This technology not only enhances the objectivity of market signal interpretation, but also promotes the intelligence level of trading systems, providing strong support for investment strategies. Therefore, the development of high-precision similar K-line pattern recognition technology is of great value in improving the timeliness and accuracy of trading decisions.

[0003] There are roughly two types of existing similar K-line matching algorithms:

[0004] The first type - fixed equal length candlestick matching algorithm, includes the following steps:

[0005] Step 1. Given N consecutive K lines of the target stock;

[0006] Step 2. Traverse all candidate stocks, select continuous K-lines of the same length N by sliding window, and calculate the difference between K-line data by least square method or Pearson correlation coefficient;

[0007] Step 3. Select N K-line data corresponding to the candidate stocks whose difference values ​​are less than the threshold.

[0008] The fixed equal length candlestick matching algorithm has the following defects:

[0009] 1. The fundamentals and technical aspects of individual stocks vary greatly. Similar technical patterns or trends rarely have equal lengths. Therefore, equal-length matching algorithms mostly remain at the technical theoretical level and are not feasible from a practical application perspective. Therefore, rigid equal-length matching will limit flexibility, because all compared K-line sequences are required to be of equal length, and the original data often needs to be adjusted to a uniform length through truncation or interpolation. This process may cause information loss (such as truncation) or introduce noise (such as unnecessary interpolation points), especially when the length differences of the original sequences are large, which may distort the actual price fluctuation details and affect the accuracy of the match.

[0010] 2. Lack of adaptability to trends and cycles: Financial market data has obvious trend and cycle characteristics, and the equal-length processing method may not be accurate enough when comparing data across different market stages or cycles. For example, during bull and bear markets, even if the shape outlines are similar, their inherent volatility and duration may be very different, and simple equal-length processing is difficult to capture these complex dynamics.

[0011] The second type - non-fixed unequal length K-line matching algorithm, includes the following steps:

[0012] Step 1. Given N consecutive K lines of the target stock:

[0013] Step 2. Traverse all candidate stocks and select the length interval in [L,M] (where L<N,M> N) continuous K-lines, calculate the similarity of two groups of K-lines through interpolation, sampling or non-equal length sequence matching algorithm (such as DTW dynamic time warping algorithm);

[0014] Step 3. Select N K-line data corresponding to the candidate stocks whose difference values ​​are less than the threshold.

[0015] The non-fixed unequal length K-line matching algorithm has the following defects:

[0016] 1. For two sequences of unequal length, it is usually necessary to stretch or shorten (compress and expand) the unknown quantity through interpolation, sampling, etc. until it is consistent with the length of the reference template, which will introduce additional noise and reduce the calculation accuracy.

[0017] 2. The traditional DTW algorithm is based on the matrix calculation of the entire sequence window. For two K-line sequences, Q = q 1 ,q 2 ,...,q n and C = c 1 ,c 2 ,...,c m , calculate the warping path under the n×m matrix, each K-line value has an equal weight, and does not take into account the morphological characteristics of the subsequences, resulting in the calculation of the K-first sequence data between the morphologies, which is prone to calculation distortion and omits the K-lines that actually have similarities, resulting in a low similarity recall. Summary of the invention

[0018] The technical problem to be solved by the present invention is that it is difficult for the existing similar K-line matching algorithm to capture K-line data with a high degree of matching in a true sense, and the matching accuracy and recall rate are not high.

[0019] In order to solve the above technical problems, the technical solution of the present invention is to provide a morphological coding-based non-equal length similar K-line matching method, which is characterized by comprising the following steps:

[0020] Step 1: Based on the morphology recognition technology, traverse the K-line sequences of all the stocks to be matched and the target stocks within the specified period, identify the basic morphologies contained in each K-line sequence and the inclusion relationship between the basic morphologies, and then obtain the complete morphology coding sequence of each K-line sequence, wherein each different basic morphology corresponds to a unique morphology code, and the complete morphology coding sequence is composed of different sequence nodes, each sequence node corresponds to a morphology code, and the sequence nodes contained by the current sequence node are the child nodes of the current sequence node, and the current sequence node is the parent node of the child node;

[0021] The complete pattern coding sequence corresponding to the K-line sequence of the to-be-matched stock is defined as the to-be-matched pattern coding sequence, and the complete pattern coding sequence corresponding to the K-line sequence of the target stock is defined as the target pattern coding sequence;

[0022] Construct a stock morphology coding sequence pool from all morphology coding sequences to be matched;

[0023] Step 2: Based on the morphological similarity between each to-be-matched morphological coding sequence in the stock morphological coding sequence pool and the target morphological coding sequence, a to-be-matched morphological coding sequence with a higher morphological similarity is preliminarily screened from the stock morphological coding sequence pool to obtain a candidate stock corresponding to the to-be-matched morphological coding sequence, wherein the morphological similarity is calculated by the following steps:

[0024] Step 201: construct a to-be-matched tree structure and a target tree structure based on any to-be-matched morphological coding sequence and a target morphological coding sequence, respectively. Each to-be-matched node and target node in the to-be-matched tree structure and the target tree structure corresponds to a sequence node in the to-be-matched morphological coding sequence and the target morphological coding sequence. The edges in the to-be-matched tree structure and the target tree structure represent the inclusion relationship between two to-be-matched nodes and two target nodes.

[0025] Step 202: Calculate the current target node N in the target tree structure. 1 and the current node N to be matched in the tree structure to be matched 2 The encoding similarity s;

[0026] Step 203: Calculate the current node N to be matched 2 For the current target node N 1 The contribution of the matching node is obtained by calculating the matching node score = s*weight(d), where d is the current node to be matched N. 2 The node depth of weight(d) is a decreasing weight function, which ensures that the contribution of deep nodes is relatively small.

[0027] Step 204: based on the calculated scores of all matching nodes, the overall similarity between the target tree structure and the tree structure to be matched is calculated, and the tree structure to be matched with a higher overall similarity is selected from all the tree structures to be matched, and the corresponding to-be-matched morphological coding sequence is obtained as the candidate morphological coding sequence, thereby obtaining the corresponding candidate stock;

[0028] Step 3: Use the DTW algorithm to calculate the similarity between the target morphological coding sequence and all candidate morphological coding sequences obtained in step 2, wherein the target morphological coding sequence and any candidate morphological coding sequence are defined as morphological sequence Patterns. 1 and Patterns 2 , the morphological sequence Patterns 1 and Patterns 2 The corresponding price series are defined as price series Prices 1 and the price series Prices 2 , and the price series Prices 1 and the price series Prices 2 The lengths of are n and m respectively, then the DTW algorithm includes the following steps:

[0029] Step 301, initialize a matrix DTWMatrix of size (n+1)×(m+1), wherein all elements of the matrix DTWMatrix are initialized to infinity except for the upper left corner element which is 0;

[0030] Step 302: Patterns based on morphological sequences 1 and Patterns 2 Create a penalty matrix PatternPenaltyMatrix. Each element in the penalty matrix PatternPenaltyMatrix represents the morphological sequence Patterns 1 and Patterns 2 The penalty value between any two sequence nodes in: If the morphological codes corresponding to the current two sequence nodes are the same, the penalty value is set to 0; otherwise, the penalty value is set to a positive value based on the significance of the morphological difference;

[0031] Step 303: Price sequence Prices 1 and the price series Prices 2 Perform a double loop traversal to calculate the grid sequence Prices 1 and the price series Prices 2 The prices of sequence nodes i and j in 1[i-1] and Prices 2 The squared price difference between [j-1] is taken as the distance d between time series point i and time series point j ij =dist=(Prices 1 [i-1]-Prices 2 [j-1]) 2 ;

[0032] Step 304: search for the penalty matrix PatternPenaltyMatrix. If the morphological codes of sequence node i and sequence node j are different, then the penalty value is added with the morphological penalty patternPenalty and then added to the inter-point distance d calculated in step 303. ij On the top, we get the distance d between points with penalty offset ij ;

[0033] Step 305: Update the element DTWMatrix[i][j] in the matrix DTWMatrix, DTWMatrix[i][j]=d ij +min(DTWMatrix[i-1][j],DTWMatrix[i][j-1],DTWMatrix[i-1][j-1]);

[0034] Step 306: After updating all elements in the matrix DTWMatrix, the final DTW distance value is obtained;

[0035] Step 307: Select the most similar candidate morphological coding sequence from all candidate morphological coding sequences based on the DTW distance value, obtain the corresponding candidate stock, and use the K-line sequence corresponding to the candidate stock as the final matched K-line sequence.

[0036] Preferably, in step 1, any two basic forms are defined as basic form 1 and basic form 2 respectively:

[0037] If within the start and end time range of basic form one, there is a sub-time interval, within which the current K-line sequence presents basic form two, then basic form one contains basic form two.

[0038] Preferably, in step 1, in the complete morphological coding sequence, based on the inclusion relationship between the basic forms, all the sequence nodes are divided into different levels, the sequence nodes of the current level are the parent nodes of the sequence nodes of the next level, and the sequence nodes of the next level are the child nodes of the current parent nodes, then:

[0039] The sequence nodes at different levels are separated by a predefined symbol:

[0040] If the parent node of all child nodes of the current level is the root node, then all child nodes of the current level are not separated by any symbol; otherwise, child nodes of the current level that belong to different parent nodes are separated by symbol two, and child nodes of the current level that belong to the same parent node are not separated by any symbol.

[0041] Preferably, in step 202, the encoding similarity s is calculated as follows:

[0042] If the current target node N 1 With the current node to be matched N 2 The corresponding morphological codes are different, then s = 0,

[0043] If the current target node N 1 With the current node to be matched N 2 The corresponding morphological codes are the same, then s = S r *S a , where: S r is the time span similarity, S r =Min(T 1 ,T 2 ) / Max(T 1 ,T 2 ), T 1 is the current target node N 1 The time period of the pattern, T 2 is the current node to be matched N 2 The time period of the pattern, the time period of the pattern = the end time of the pattern - the start time of the pattern; S a is the amplitude similarity, S a =Min(A 1 ,A 2 ) / Max(A 1 ,A 2 ), A 1 is the current target node N 1 The morphological amplitude, A 2 is the current node to be matched N 2 The pattern amplitude, pattern amplitude = (pattern highest price - pattern lowest price) / price when the pattern ends.

[0044] Preferably, in step 203, the decreasing weight function weight(d) is set to: weight(d)=1 / d.

[0045] Preferably, in step 204, the overall similarity is the sum of the scores of all matching nodes, or a certain weighted average of the scores of all matching nodes.

[0046] The present invention uses a new matching algorithm to dig out more stocks with similar trends at the broad level or technical level, provide more accurate and expert-based K-line similarity matching results, improve the matching recall rate, and provide more reference data for price trend analysis and prediction. At the same time, based on the preprocessing and pre-matching at the morphological coding level, the pruning capability of rapid initial screening is achieved, computing resources are saved, and computing efficiency is improved. Through the morphological coding information, it is fused with the K-line data into a new matrix to realize the calculation of morphologically perceived non-equal length sequence similarity, further improving the matching accuracy and recall rate.

[0047] Compared with the prior art solutions, the present invention has the following beneficial effects:

[0048] On the one hand, the present invention solves the limitations of the equal-length sequence matching algorithm. On the other hand, by integrating the morphological information with the K-line sequence, the morphology is more accurately perceived during sequence matching, the sequence is reasonably split, and the non-equal-length subsequences with the same position and morphology are matched to improve the rationality and accuracy of the matching. At the same time, when screening and matching massive data, the present invention performs matching and pruning based on short morphological sequences through the recognition and precoding of morphological features, significantly shortening the calculation amount and efficiency of stock K-line screening, and improving the timeliness of the matching algorithm. BRIEF DESCRIPTION OF THE DRAWINGS

[0049] Figure 1 It shows a K-line pattern;

[0050] Figure 2 Examples of morphology encoding a complex hierarchy;

[0051] Figure 3 The method of calculating the similarity score is illustrated;

[0052] Figure 4 The improved DTW algorithm based on morphology perception proposed in the present invention is illustrated. DETAILED DESCRIPTION

[0053] The present invention will be further described below in conjunction with specific embodiments. It should be understood that these embodiments are only used to illustrate the present invention and are not intended to limit the scope of the present invention. In addition, it should be understood that after reading the content taught by the present invention, those skilled in the art can make various changes or modifications to the present invention, and these equivalent forms fall within the scope limited by the appended claims of the application equally.

[0054] The embodiment of the present invention discloses a morphological coding-based non-equal-length similar K-line matching method, which specifically includes the following steps:

[0055] Step 1: Based on the pattern recognition technology, the K-line data of all stocks in the specified period are traversed, pattern recognized and encoded to complete the re-representation of the K-line pattern.

[0056] Step 1.1: Morphological category definition and coding

[0057] A series of basic K-line pattern categories are defined. In this embodiment, the basic K-line pattern categories include rising trend, falling trend, sideways consolidation, double top, double bottom, head and shoulders top, head and shoulders bottom, etc., and a unique code is assigned to each basic K-line pattern category.

[0058] In this embodiment, the code can be a combination of numbers or letters, for example: upward trend - U1; downward trend - D1; sideways consolidation - S1; double top - T1; double bottom - B1; head and shoulders top - H1; head and shoulders bottom - L1.

[0059] Step 1.2: Establish a hierarchical coding system to represent the inclusion relationship between different basic candlestick patterns

[0060] The present invention introduces the concept of hierarchy in the coding system defined in step 1.1. The seven basic K-line patterns defined in step 1.1 are independent of each other. The so-called "inclusion relationship" means that within the start and end time range of a basic K-line pattern 1, there is a sub-time interval. In this sub-time interval, the K-line presents another basic K-line pattern 2. The basic K-line pattern 2 is called a "small pattern" and the basic K-line pattern 1 is called a "large pattern", that is, a small pattern is contained within a large pattern. Figure 1 As shown, the Shanghai Composite Index shows an upward trend in the time interval of 2024.2.5-2024.5.20, but shows a local sideways trend in the sub-interval of 2024.3.18-2024.4.26. This is called a morphological inclusion relationship, which is coded as U1.S1.

[0061] Referring to the representation of the level-order traversal of a tree with empty nodes, the aforementioned "inclusion relationship" can be expressed by adding the sub-level number after the encoding. For example, a large sideways consolidation pattern containing a double bottom can be encoded as:

[0062] Large sideways consolidation (S1) + double bottom (B1) = S1.B1.

[0063] If there are multiple levels of inclusion, you can continue to expand, such as:

[0064] Large sideways trend (S1) + upward trend (U1) + double bottom (B1) = S1.U1.B1.

[0065] like Figure 2 A more complex form shown can be encoded as:

[0066] Large sideways consolidation (S1) + (double bottom (B1) + (downward trend (D1) + sideways consolidation (S1)) + (head and shoulders top (H1) + upward trend (U1))) = S1.B1D1H1.x-S1-U1, where "x" means that the parent node of the previous layer has no child nodes, which is an empty node, and "-" is used to separate child nodes of different parent nodes.

[0067] Step 1.3: Traverse all stocks, calculate and store the complete shape codec sequence of each stock based on the shape category coding defined in step 1.1 and the hierarchical coding system defined in step 1.2, and then obtain the stock shape code sequence pool, recorded as Tsc (target shape codec).

[0068] Step 1.4: Based on the shape category coding defined in step 1.1 and the hierarchical coding system defined in step 1.2, the shape sequence of the K-line of the target stock is identified and encoded to obtain the complete shape coding sequence of the target stock, which is recorded as Ssc (source shape codec).

[0069] Step 2: If Figure 3 As shown, according to Ssc, the similarity matching of the complete morphological coding sequence is performed in Tsc, and the stocks with preliminary morphological similarity and the corresponding K-line sequences are obtained from Tsc.

[0070] Step 2.1: Preprocessing

[0071] First, each complete morphological coding sequence in Tsc and Ssc are decomposed into basic units (morphological coding and its hierarchy) to form a tree structure. The tree structure corresponding to Ssc is defined as the "target tree structure", and the tree structure corresponding to each complete morphological coding sequence in Tsc is defined as the "tree structure to be matched". Each node in the tree structure represents a morphological code, and the edge represents the parent-child relationship (i.e., "inclusion relationship").

[0072] Step 2.2: Best subtree matching

[0073] Calculate the similarity score of the target tree structure and any tree structure to be matched, and obtain the tree structure to be matched that is most similar to the target tree structure based on the similarity score, that is, obtain the "best subtree". In the embodiment of the present invention, the following steps are used to calculate the similarity score between the two tree structures:

[0074] Step 2.21: Node Depth Weighting

[0075] According to the node depth d of the tree structure, a decreasing weight function weight(d), for example weight(d)=1 / d, is set to ensure that the contribution of deep nodes is relatively small.

[0076] Step 2.22: Calculate similarity score

[0077] For each matching node in the tree structure, the contribution score is calculated based on the encoding similarity and the weight function, and the overall similarity score of the two tree structures is accumulated, which specifically includes the following steps:

[0078] Calculate any node N in the target tree structure 1 Any node N in the tree structure to be matched 2 The encoding similarity s:

[0079] If the node N 1 With node N 2 The morphological encoding is different, then s = 0,

[0080] If the node N 1 With node N 2 The morphological codes of are the same, then s=S r *S a , where: S r is the time span similarity, defining the morphological time period of node N as T (i.e., morphological end time - morphological start time), S r =Min(T 1 ,T 2 ) / Max(T 1 ,T 2 ), T 1 For node N 1 The time period of the pattern, T 2 For node N 2 The time period of the shape; S a is the amplitude similarity, and the shape amplitude of node N is defined as A (i.e. (shape highest price - shape lowest price) / shape end price), S a =Min(A 1 ,A 2 ) / Max(A 1 ,A 2 ), A 1 For node N 1 The morphological amplitude, A 2 For node N 2 The morphological amplitude of

[0081] Calculate the node N 2 For node N 1 The contribution of the matching node is obtained by calculating the matching node score = s*weight(d), where d is the node N 2 The node depth of .

[0082] Step 2.23: Based on the scores of all matching nodes, calculate the overall similarity between the target tree structure and the tree structure to be matched, and select the best subtree from all the tree structures to be matched based on the overall similarity. In an embodiment of the present invention, the overall similarity can be the sum of the scores of all matching nodes, or a weighted average of the scores of all matching nodes, to ensure that the matching of deeper nodes does not excessively affect the overall score. After obtaining the overall similarity, set a similarity threshold according to the application scenario, and only output the matching results with an overall similarity higher than the threshold as the final best subtree.

[0083] Step 3: Based on step 2, candidate stocks with preliminary morphological similarities to the target K-line sequence in the specified interval of the target stock and the corresponding K-line sequence in the interval to be matched are obtained.

[0084] Step 4: Based on the complete morphological coding sequence, the present invention proposes an improved DTW algorithm based on morphological perception for the target K-line sequence and the K-line sequence in the interval to be matched, and further calculates the similarity between K-line sequences of unequal lengths. The goal of the DTW algorithm is to calculate the similarity between two K-line sequences (i.e., time series - in this invention, it is a K-line sequence of length n, Prices 1 and the K-line sequence Prices of length m 2 ), taking into account the patterns to which they belong. 1 and Patterns 2 ) The additional penalty caused by the difference, such as Figure 4 As shown, the DTW algorithm includes the following steps:

[0085] Step 4.1: Initialize a matrix DTWMatrix of size (n+1)×(m+1). Except for the upper left corner element, all other elements of the matrix DTWMatrix are initialized to infinity. This matrix DTWMatrix will be used to store the DTW distance calculated during the dynamic programming process.

[0086] Step 4.2: Define the penalty matrix based on the complete pattern coding sequence and create a penalty matrix PatternPenaltyMatrix. Each element in the penalty matrix PatternPenaltyMatrix represents the penalty value between any two patterns in the two K-line sequences: if the two patterns are the same, the penalty value is set to 0; if the two patterns are different, a positive penalty value is set according to the significance of the pattern difference.

[0087] Step 4.3: Integrate the morphological penalty into the standard DTW calculation process, including the following steps:

[0088] Step 4.31: Perform a double loop traversal on the two K-line sequences and calculate the prices of time series points i and j in the K-line sequences. 1 [i-1] and Prices 2 The squared difference of the price between [j-1] is taken as the distance between points d ij =dist, that is (Prices 1 [i-1]-Prices 2 [j-1]) 2 , update the distance between points.

[0089] Step 4.32: On the basis of conventional DTW distance calculation, each time the distance between time series points on two K-line sequences is calculated, the penalty matrix PatternPenaltyMatrix is ​​searched. If the two time series points belong to different patterns, the penalty value plus the pattern penalty patternPenalty is added to the original distance between points to obtain the distance value dist between points with penalty offset.

[0090] Step 4.33: Update DTWMatrix[i][j]

[0091] Through dynamic programming, the optimal DTW warping path is calculated, which is the distance between the currently calculated points plus the minimum value of the three neighbor elements in the matrix DTWMatrix (upper left corner, above, and left), that is, DTWMatrix[i][j] = d ij +min(DTWMatrix[i-1][j],DTWMatrix[i][j-1],DTWMatrix[i-1][j-1]).

[0092] Step 4.4: Integrate steps 4.1 to 4.3 to formulate the final DTWWithPatternPenalty similarity matching algorithm process. The target K-line sequence obtained in step 3 and the K-line sequence of the candidate stock to be matched are combined to construct a time series analysis matrix; the DTW algorithm receives the pattern sequences Patterns of the two stocks 1 、Patterns 2 , and the corresponding price series Prices 1 、Prices 2 , combined with the morphological penalty matrix PatternPenaltyMatrix in step 4.2 as input, calculate the distance between points after incorporating the morphological penalty according to the DTW algorithm logic, and return the final DTW distance value.

[0093] Step 5: Perform refined morphologically-aware similarity calculations on the stock group initially screened out in step 4, obtain the most similar K-line sequence according to a given optimization matching algorithm, and output the matched K-line results.

[0094] Step 5.1: Load all the data of stocks with primary similarity and corresponding interval K-line obtained in step 3.

[0095] Step 5.2: For the target K-line series data, use the morphological coding-aware DTW sequence similarity algorithm to calculate its similarity with the candidate stock interval K-line series data one by one.

Claims

1. A non-equal length similar K-line matching method based on morphological coding, characterized in that: The following steps are involved: Step 1: Based on the morphology recognition technology, traverse the K-line sequences of all the stocks to be matched and the target stocks within the specified period, identify the basic morphologies contained in each K-line sequence and the inclusion relationship between the basic morphologies, and then obtain the complete morphology coding sequence of each K-line sequence, wherein each different basic morphology corresponds to a unique morphology code, and the complete morphology coding sequence is composed of different sequence nodes, each sequence node corresponds to a morphology code, and the sequence nodes contained by the current sequence node are the child nodes of the current sequence node, and the current sequence node is the parent node of the child node; The complete pattern coding sequence corresponding to the K-line sequence of the to-be-matched stock is defined as the to-be-matched pattern coding sequence, and the complete pattern coding sequence corresponding to the K-line sequence of the target stock is defined as the target pattern coding sequence; Construct a stock morphology coding sequence pool from all morphology coding sequences to be matched; Step 2: Based on the morphological similarity between each to-be-matched morphological coding sequence in the stock morphological coding sequence pool and the target morphological coding sequence, a to-be-matched morphological coding sequence with a higher morphological similarity is preliminarily screened from the stock morphological coding sequence pool to obtain a candidate stock corresponding to the to-be-matched morphological coding sequence, wherein the morphological similarity is calculated by the following steps: Step 201: construct a to-be-matched tree structure and a target tree structure based on any to-be-matched morphological coding sequence and a target morphological coding sequence, respectively. Each to-be-matched node and target node in the to-be-matched tree structure and the target tree structure corresponds to a sequence node in the to-be-matched morphological coding sequence and the target morphological coding sequence. The edges in the to-be-matched tree structure and the target tree structure represent the inclusion relationship between two to-be-matched nodes and two target nodes. Step 202, calculating the coding similarity s between the current target node N1 in the target tree structure and the current to-be-matched node N2 in the to-be-matched tree structure; Step 203: Calculate the contribution of the current node to be matched N2 to the current target node N1, and obtain the matching node score = s*weight(d), where d is the node depth of the current node to be matched N2, and weight(d) is a decreasing weight function, which ensures that the contribution of deep nodes is relatively small. Step 204: based on the calculated scores of all matching nodes, the overall similarity between the target tree structure and the tree structure to be matched is calculated, and the tree structure to be matched with a higher overall similarity is selected from all the tree structures to be matched, and the corresponding to-be-matched morphological coding sequence is obtained as the candidate morphological coding sequence, thereby obtaining the corresponding candidate stock; Step 3: Use the DTW algorithm to calculate the similarity between the target morphological coding sequence and all candidate morphological coding sequences obtained in step 2, wherein the target morphological coding sequence and any candidate morphological coding sequence are defined as morphological sequence Patterns1 and morphological sequence Patterns2, respectively, and the price sequences corresponding to morphological sequence Patterns1 and morphological sequence Patterns2 are defined as price sequence Prices1 and price sequence Prices2, respectively, and the lengths of price sequence Prices1 and price sequence Prices2 are n and m, respectively. The DTW algorithm includes the following steps: Step 301, initialize a matrix DTWMatrix of size (n+1)×(m+1), wherein all elements of the matrix DTWMatrix are initialized to infinity except for the upper left corner element which is 0; Step 302: Create a penalty matrix PatternPenaltyMatrix based on the morphological sequences Patterns1 and Patterns2. Each element in the penalty matrix PatternPenaltyMatrix represents the penalty value between any two sequence nodes in the morphological sequences Patterns1 and Patterns2: if the morphological codes corresponding to the current two sequence nodes are the same, the penalty value is set to 0; otherwise, the penalty value is a positive value set according to the significance of the morphological difference; Step 303: Double loop traverses the price sequence Prices1 and the price sequence Prices2, and calculates the squared price difference between the prices Prices1[i-1] and Prices2[j-1] of the sequence node i and the sequence node j in the grid sequence Prices1 and the price sequence Prices2 as the distance d between the time series point i and the time series point j. ij =dist=(Prices1[i-1]-Prices2[j-1]) 2 ; Step 304: search for the penalty matrix PatternPenaltyMatrix. If the morphological codes of sequence node i and sequence node j are different, then the penalty value is added with the morphological penalty patternPenalty and then added to the inter-point distance d calculated in step 303. ij On the top, we get the distance d between points with penalty offset ij ; Step 305: Update the element DTWMatrix[i][j] in the matrix DTWMatrix, DTWMatrix[i][j]=d ij +min(DTWMatrix[i-1][j],DTWMatrix[i][j-1],DTWMatrix[i-1][j-1]); Step 306: After updating all elements in the matrix DTWMatrix, the final DTW distance value is obtained; Step 307: Select the most similar candidate morphological coding sequence from all candidate morphological coding sequences based on the DTW distance value, obtain the corresponding candidate stock, and use the K-line sequence corresponding to the candidate stock as the final matched K-line sequence.

2. The non-equal length similar K-line matching method based on morphological coding as claimed in claim 1, characterized in that: In step 1, any two basic forms are defined as basic form 1 and basic form 2: If within the start and end time range of basic form one, there is a sub-time interval, within which the current K-line sequence presents basic form two, then basic form one contains basic form two.

3. The non-equal length similar K-line matching method based on morphological coding as claimed in claim 1, characterized in that: In step 1, in the complete morphological coding sequence, based on the inclusion relationship between the basic morphologies, all the sequence nodes are divided into different levels, the sequence node of the current level is the parent node of the sequence node of the next level, and the sequence node of the next level is the child node of the current parent node, then: the sequence nodes at different levels are separated by a predefined symbol one; If the parent node of all child nodes of the current level is the root node, then all child nodes of the current level are not separated by any symbol; otherwise, child nodes of the current level that belong to different parent nodes are separated by symbol two, and child nodes of the current level that belong to the same parent node are not separated by any symbol.

4. The non-equal length similar K-line matching method based on morphological coding as claimed in claim 1, characterized in that: In step 202, the encoding similarity s is calculated as follows: If the morphological codes corresponding to the current target node N1 and the current node to be matched N2 are different, then s=0. If the morphological codes corresponding to the current target node N1 and the current node to be matched N2 are the same, then s = S r *S a , where: S r is the time span similarity, S r =Min(T1,T2) / Max(T1,T2), T1 is the morphological time period of the current target node N1, T2 is the morphological time period of the current node to be matched N2, morphological time period = morphological end time - morphological start time; S a is the amplitude similarity, S a =Min(A1,A2) / Max(A1,A2), A1 is the shape amplitude of the current target node N1, A2 is the shape amplitude of the current node N2 to be matched, shape amplitude = (shape highest price - shape lowest price) / shape end price.

5. The non-equal length similar K-line matching method based on morphological coding as claimed in claim 1, characterized in that: In step 203, the decreasing weight function weight(d) is set to: weight(d)=1 / d.

6. The non-equal length similar K-line matching method based on morphological coding as claimed in claim 1, characterized in that: In step 204, the overall similarity is the sum of the scores of all matching nodes, or a weighted average of the scores of all matching nodes.