Classical K-line form recognition method based on machine learning algorithm

By combining machine learning algorithms and technical form definitions, using Gaussian process to fit the stock price trend curve, identify and verify the technical form, the problem that existing technology is difficult to effectively identify the technical form is solved, and more accurate technical analysis signals and investment decision support is achieved.

CN120070059APending Publication Date: 2025-05-30WESTERN SECURITIES CO LTD
View PDF 0 Cites 1 Cited by

Patent Information

Application Number
CN202510118297.X
Authority / Receiving Office
CN · China
Patent Type
Applications(China)
Current Assignee / Owner
Filing Date
2025-01-24
Publication Date
2025-05-30

AI Technical Summary

Technical Problem

The existing technology is difficult to effectively identify and utilize the technical forms in the market, which limits investors' technical analysis capabilities.

Method used

By combining machine learning algorithms and technical form definition, the Gaussian process is used to fit the stock price trend curve, find the extreme point, and define the technical form according to the correlation between the extreme point, and finally set the breakthrough position and determine the effectiveness of the form.

Benefits of technology

It has achieved effective identification of common technical forms in the market, provided more accurate technical analysis signals, and enhanced investors' decision-making capabilities.

✦ Generated by Eureka AI based on patent content.

Smart Images

  • Figure CN120070059A_ABST
    Figure CN120070059A_ABST
Patent Text Reader

Abstract

The invention discloses a classical K-line form recognition method based on a machine learning algorithm. The method comprises the following steps: firstly, fitting a stock price trend curve by adopting a Gaussian process; searching extreme points according to the smooth stock price trend curve; defining a technical form through the correlation of the positions of the extreme points; setting a breakthrough position after form recognition, and judging that the form is an effective form after breakthrough; and finally, making a form schematic diagram according to the definition of each form and the position of the extreme point. According to the method, the machine learning algorithm and the technical form definition are combined, and common technical forms in the market are effectively identified to help investors to carry out better technical analysis.
Need to check novelty before this filing date? Find Prior Art

Description

Technical Field

[0001] The present invention belongs to the field of computer technology, and particularly relates to a method for identifying classic K-line patterns based on machine learning algorithms. Background Art

[0002] As an advanced data-driven tool, machine learning models have demonstrated powerful application potential in quantitative investment. Their core advantage lies in the ability to automatically extract patterns from complex, non-linear, and massive financial data and generate predictive and practical decision-making results. Compared with traditional financial models, machine learning has greater flexibility and adaptability in dealing with high-dimensional data, unstructured data, and dynamically changing market environments, helping investors design more intelligent trading strategies.

[0003] Time series data is a key information source in the financial market, such as historical prices, trading volumes, and volatilities. Machine learning models have demonstrated powerful capabilities in time series modeling, especially deep learning models (such as long short-term memory networks LSTM and GRU) that can handle non-linear and long-term dependence relationships. These models can identify market cyclical patterns and abnormal fluctuations and generate high-precision price or volatility predictions. In addition, tree models (such as XGBoost) can effectively model asset trends when combining time series and other features, providing support for short-term trend tracking strategies and long-term mean reversion strategies.

[0004] Technical analysis is an important analysis method in financial investment. Technical analysis is roughly divided into technical indicators and technical patterns. Technical indicators are indicators based on historical price and volume data and calculated using mathematical methods to predict future market directions, such as MACD, BOLL, ATR, etc. Technical patterns are behaviors that identify price patterns based on historical price trends and use image and pattern recognition methods to judge future market directions, such as head and shoulders top, double bottom, ascending triangle, etc. Summary of the Invention

[0005] The object of the present invention is to provide a method for identifying classic K-line patterns based on machine learning algorithms. By combining machine learning algorithms and the definition of technical patterns, it can effectively identify common technical patterns in the market and help investors conduct better technical analysis.

[0006] The technical solution adopted by the present invention is a method for identifying classic K-line patterns based on machine learning algorithms, which is specifically implemented according to the following steps: Step 1: Use a Gaussian process to fit the stock price trend curve; Step 2: Find extreme points based on the smoothed stock price trend curve; Step 3: Define technical patterns based on the correlation of the positions of extreme points; Step 4: Set the breakout point after morphological recognition, and determine the morphology as a valid morphology after breakout; Step 5: Make a morphological schematic diagram according to the definition of each morphology and the position of the extreme points.

[0007] The features of the present invention also lie in that Step 1 is specifically implemented according to the following steps: Use Gaussian process to fit the stock price. The training set features are selected as an arithmetic sequence with a common difference of 1, and the label is the post-rights-adjusted closing price for model training. Save the training results, and obtain a smooth and non-lagging curve by inputting the features of the training set; since Gaussian curve will use future data during fitting, it is necessary to perform fitting every day to judge in real time whether the technical morphology is formed. The technical morphology signals judged historically need to be saved, and no processing will be done if there are changes during future fitting; Since fitting needs to be performed every day and the features are relatively fixed, the model training is accelerated.

[0008] The acceleration process of the model training in Step 1 is specifically implemented according to the following steps: ① Given a time span, calculate several matrix parameters in the Gaussian process of this arithmetic sequence: the Gaussian kernel matrix A of feature and feature, the Gaussian kernel matrix B of label and label, and the Gaussian kernel matrix C of label and feature; ② If the input stock feature length is the same as the default, directly use the calculated matrices A, B, and C for calculation; ③ If the input stock feature is less than the default time span, the kernel covariance matrix takes slices directly to obtain, which can also be accelerated, but the inverse of the kernel covariance matrix cannot be sliced and processed, and only recalculation can be done; In this way, several matrices in the Gaussian process can cache the results through calculation, and the curve fitting of special lengths is calculated separately to play an accelerating role.

[0009] Step 2 is specifically implemented according to the following steps: ① The determination of extreme points is on the fitted curve. If this point is the maximum value of all points within a certain domain, it is a maximum extreme point; if it is the minimum value of all points within a certain domain, it is a minimum extreme point; ② After obtaining the extreme points on the fitted curve, the extreme points need to be corrected to the original stock price curve. To avoid using future data, historical correction is performed. If this point is a minimum extreme point and the position of the original curve where it is located is greater than the previous point, then correct the minimum extreme point to the previous moment; if this point is a maximum extreme point and the position of the original curve where it is located is less than the previous point, then correct the maximum extreme point to the previous moment; After obtaining the extreme points, it is prepared for the subsequent morphological determination.

[0010] In step 3, the technical patterns include head and shoulders top / bottom patterns, triangle top / bottom patterns, double bottom / top patterns, and expanding bottom / top patterns.

[0011] The determination rules for each technical pattern in step 3 are as follows: (1) Head and shoulders top / bottom patterns: Take any six consecutive extreme points found from the curve fitted by the Gaussian process as the judgment basis. Denote the six sequential extreme points as E0, E1, E2, E3, E4, E5 in order: ① E0 < min(E2, E4) ② E5 is a maximum point ③ E3 >= 1.01 max(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E1 / E2 – 1 >= 0.05 ⑦ E5 / E4 - 1 >= 0.05 The pattern recognition of the head and shoulders bottom is exactly the opposite. The six sequential extreme points are E0, E1, E2, E3, E4, E5 in order.

[0012] ① E0 > max(E2, E4) ② E5 is a minimum point ③ 1.01 E3 <= min(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E2 / E1 - 1 >= 0.05 ⑦ E4 / E5 - 1 >= 0.05 (2) Triangle top / bottom patterns: Take any five consecutive extreme points found from the curve fitted by the Gaussian process as the judgment basis. Denote the five extreme points as E1, E2, E3, E4, E5 in order: ① Calculate ret13 = E1 / E3 – 1, ret35 = E3 / E5 – 1, E42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.1 ③ 0.02 < ret35 < 0.1 ④ 0.02 < ret42 < 0.1 ⑤ E5 > 1.01 E4 ⑥ E5 is a maximum point According to the above rules, the triangular top pattern can be identified. For the triangular bottom, simply reverse the above rules for judgment, specifically as follows: Record the five extreme points as E1, E2, E3, E4, E5 in sequence: ① Calculate ret31 = E3 / E1 – 1, ret53 = E5 / E3 – 1, ret24 = E2 / E4 - 1 ② 0.02 < ret31 < 0.1 ③ 0.02 < ret53 < 0.1 ④ 0.02 < ret24 < 0.1 ⑤ E4 > 1.01 E5 ⑥ E5 is the minimum extreme point (3)Double bottom / top pattern: The extreme value judgment of double top / bottom is different from other patterns.

[0013] Extreme point 1: A point that is the maximum or minimum within the ξ domain is called an extreme point. When ξ takes 8, the extreme point exLag1 is obtained; Extreme point 2: A point that is the maximum or minimum within the (x - ξ1, x + ξ2) domain is called an extreme point. When ξ1 takes 8 and ξ2 takes 4, the extreme point exLag2 is obtained. The data after the above processing is denoted as data.

[0014] At any extreme point exLag2, it is necessary to combine the previous 3 extreme points exLag1 at the position of this extreme point exLag2 to judge the pattern. The following is the algorithm processing: a. Remove the rows where exLag1 is not 0 to obtain new data, denoted as dataLag; b. A total of 4 extreme points are required for double bottom and double top judgments. Shift the indexes of dataLag forward by 1 to 3 towards the future, denoted as E12Index, E11Index, E10Index, and shift the indexes of dataLag by 0 to 2, denoted as E22Index, E21Index, E20Index. It is necessary to judge which one to use later; c. Step b is to process the indexes. We also need to perform the same processing on the extreme value marks (1, -1) and the post - rights - adjusted closing prices corresponding to the extreme value positions. The extreme value marks are denoted as ex12, ex11, ex10, ex22, ex21, ex20; perform the same processing on the post - rights - adjusted closing prices, denoted as E12, E11Index, E10, E22, E21, E20; d. Merge the dataLag data with the original data (data containing exLag1 and exLag2) according to the two data indexes; e. Fill the columns starting with 2 (ex22, E22, E22Index, ex21, E21, E21Index, ex20, E20, E20Index) obtained from the above processing backward. For the columns starting with 1 (ex12, E12, E12Index, ex11, E11, E11Index, ex10, E10, E10Index, a total of 9 columns), make a judgment. If the columns starting with 1 are not empty, use the columns starting with 2; otherwise, use the columns starting with 1. Thus, at any extreme point exLag2, we can already obtain all the information of the previous 3 extreme points exLag1.

[0015] Next, perform the morphological judgment: ① exLag = -1 and ex1 = -1 and ex2 = 1 and ex0 = 1 ② E2 > 1.1 max(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E0 > 1.005 E2 If the above conditions are met, the position where the bottom of the double bottom is formed is recorded as T; otherwise, it is recorded as F, denoted as the DBOT column. The judgment of the double top can be made by simply reversing the above rules: ① exLag = 1 and ex1 = 1 and ex2 = -1 and ex0 = -1 ② E2 1.1 < min(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E2 > 1.005 E0 (4)Expansion bottom / top pattern The judgment of the expansion bottom / top is similar to that of the triangle top / bottom. Use any 5 consecutive extreme points found by fitting the curve with the Gaussian process as the judgment basis. Denote the 5 sequential extreme points as E1, E2, E3, E4, E5; Expansion top ① Calculate ret13 = E3 / E1 - 1, ret35 = E5 / E3 - 1, ret42 = E2 / E4 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is a maximum extreme point According to the above rules, the expansion top pattern can be identified. The judgment rules for the expansion bottom are as follows: ① Calculate ret13 = E1 / E3 - 1, ret35 = E3 / E5 - 1, ret42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is the minimum point According to the above rules, the expanding bottom pattern can be identified.

[0016] In step 4, after a pattern appears, an effective signal needs to be given based on the pattern. Only after the pattern is broken through can the effectiveness of the pattern be determined. Specifically as follows: (1) Head and shoulders top / bottom pattern: According to the rules in step 4, identify the last shoulder of the head and shoulders top pattern. Now, it is also necessary to determine the complete formation time point (breakthrough) of the pattern; take the average cycle length from E0 to E5, (the index corresponding to E5 minus the index corresponding to E0) 2 / 5, and then round it to get dateAvg; take the minimum value of E2 and E4 as the baseline minLine, and judge one by one from the last shoulder: ① The post - adjusted closing price at 1.01 times the current time point is less than minLine; ② When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, take the first time point that meets the conditions and mark it as the complete formation time point of the head and shoulders top, denoted as S; For the head and shoulders bottom pattern recognition, it is completely reversed. ① Take the maximum value of E2 and E4 as the baseline maxLine; ② The post - adjusted closing price at the current time point is greater than 1.01 times maxLine; ③ When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, take the first time point that meets the conditions and mark it as the complete formation time point of the head and shoulders bottom, denoted as S.

[0017] (2) Triangular top / bottom pattern: According to the rules in step 4, identify the triangular top pattern. Now, it is also necessary to determine the breakthrough of the pattern; take the average cycle length from E1 to E5: (the index corresponding to E5 minus the index corresponding to E1) 2 / 4, and then round it to get dateAvg; start judging one by one from the position where the triangular top pattern is determined: ① The post - rights - adjusted closing price at the current time point > 1.01 times of E3, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, indicating an upward breakthrough; ② 1.01 times of the post - rights - adjusted closing price at the current time point > E4, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, indicating a downward breakthrough; After meeting the above conditions, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangular top, denoted as S; The judgment of the triangular bottom can be completely reversed by using the above rules: ① 1.01 times of the post - rights - adjusted closing price at the current time point < E3, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, indicating a downward breakthrough; ② The post - rights - adjusted closing price at the current time point > 1.01 times of E4, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, indicating an upward breakthrough; After meeting the above conditions, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangular bottom, denoted as S.

[0018] (3)Double - bottom / top pattern Judge the double - bottom pattern according to the rules in step 4. Next, judge the breakthrough signal. The breakthrough point needs to exceed the highest value in the middle of the double - bottom, and the time taken cannot be too long. Judge the two conditions in turn: ① The index corresponding to E3 minus start (the index of point E0) + 1 Round 2.5 / 3 to the nearest whole number and denote it as dateAvg; ② Start judging backward from the position where the bottom of the double - bottom is formed. The post - rights - adjusted closing price is greater than or equal to 1.005 times of E2 and the current time point index minus the time point index where the double - bottom is formed is less than or equal to dateAvg. The first position that meets this condition is the time point when the double - bottom is completely formed; The double - top is judged using the following rules; Judge the double - top pattern according to the rules in step 4. Next, judge the breakthrough signal. The breakthrough point needs to be lower than the minimum value in the middle of the double - top, and the time taken cannot be too long. Judge the two conditions in turn; ① The index corresponding to E3 minus start (the index of point E0) + 1 Round 2.5 / 3 to the nearest whole number and denote it as dateAvg; ② Start judging backward from the position where the top of the double - top is formed. 1.005 times of the post - rights - adjusted closing price is less than or equal to E2 and the current time point index minus the time point index where the double - top is formed is less than or equal to dateAvg. The first position that meets this condition is the time point when the double - top is completely formed; (4)Expanding bottom / top pattern According to the rules in Step 4, the expanding bottom pattern is identified. Now, it is necessary to determine the breakthrough position. The breakthrough position of the expanding bottom directly lags one period, that is, one day, behind the E5 mark of the expanding top determined above. That is, a breakthrough signal for the expanding top pattern is given on the next day. The breakthrough judgment of the expanding top is the same as that of the expanding bottom. The breakthrough signal for the expanding bottom pattern is given on the next day after the E5 mark of the expanding top is determined, lagging one period, that is, one day.

[0019] In Step 5, after obtaining the signals and determination characteristics of each pattern, it is necessary to draw a schematic diagram of the pattern on the stock price chart. For connecting two extreme points with a straight line, the values between the extreme points are filled by linear interpolation. If it is a curve, a fitted curve graph is directly drawn.

[0020] The beneficial effect of the present invention is that a classic candlestick pattern recognition method based on a machine learning algorithm provides a method for identifying technical patterns. By combining machine learning and technical analysis and giving a method for judging effective signals, it provides a powerful tool for financial investors, making technical patterns visual and concrete, and facilitating investors to conduct technical analysis during investment. BRIEF DESCRIPTION OF THE DRAWINGS

[0021] Figure 1 is a flowchart of a classic candlestick pattern recognition method based on a machine learning algorithm; Figure 2 is a comparison of the fitting results of stock prices by different methods; FIG. 3(a) is a case of the head and shoulders bottom pattern; FIG. 3(b) is a case of the head and shoulders top pattern; FIG. 4(a) is a case of the triangle bottom pattern; FIG. 4(b) is a case of the triangle top pattern; FIG. 5(a) is a case of the double top pattern; FIG. 5(b) is a case of the double bottom pattern; FIG. 6(a) is a case of the expanding top pattern; FIG. 6(b) is a case of the expanding bottom pattern. DETAILED DESCRIPTION OF THE INVENTION

[0022] The present invention will be described in detail below with reference to the drawings and specific embodiments.

[0023] The classic candlestick pattern recognition method of the present invention based on a machine learning algorithm has a flowchart as Figure 1 shown, and is specifically implemented according to the following steps: Step 1: Fit the stock price trend curve using a Gaussian process; Step 1 is specifically implemented according to the following steps: The Gaussian process is used to fit the stock price. The features of the training set are selected as an arithmetic sequence with a common difference of 1, and the label is the post - rights - adjusted closing price for model training. The results of the training are saved, and a smooth and non - lagged curve is obtained by inputting the features of the training set. Since the Gaussian curve uses future data during fitting, it is necessary to perform fitting every day to determine in real - time whether a technical pattern is formed. The technical pattern signals judged historically need to be saved, and no processing is done if there are changes during future fitting. Since fitting needs to be performed every day and the features are relatively fixed, the issue of efficient use of computing resources is considered, and the model training is accelerated.

[0024] The acceleration of model training in step 1 is specifically implemented according to the following steps: ① Given a time span, such as 1 year, calculate several matrix parameters in the Gaussian process of this arithmetic sequence: the Gaussian kernel matrix A of feature and feature, the Gaussian kernel matrix B of label and label, and the Gaussian kernel matrix C of label and feature; ② If the input stock feature length is the same as the default, directly use the calculated matrices A, B, and C for calculation; ③ If the input stock feature is less than the default time span, the kernel covariance matrix takes slices directly to obtain, which can also accelerate, but the inverse of the kernel covariance matrix cannot be sliced and can only be recalculated; In this way, several matrices in the Gaussian process can cache the results through calculation, and the curve fitting of special lengths is calculated separately to play an accelerating role.

[0025] Step 2: Find the extreme points according to the smooth stock price trend curve; Step 2 is specifically implemented according to the following steps: ① The determination of extreme points is on the fitted curve. The definition of extreme values refers to the mathematical definition. If a point is the maximum value of all points within a certain domain, it is a maximum extreme value; if it is the minimum value of all points within a certain domain, it is a minimum extreme value. ② After obtaining the extreme points on the fitted curve, the extreme points need to be corrected to the original stock price curve. To avoid using future data, historical correction is performed. If the point is a minimum extreme point and its position on the original curve is greater than the previous point, the minimum extreme point is corrected to the previous moment; if the point is a maximum extreme point and its position on the original curve is less than the previous point, the maximum extreme point is corrected to the previous moment. After obtaining the extreme points, it is prepared for the subsequent pattern determination.

[0026] Step 3: Define technical patterns through the correlation of the positions of extreme points; The technical patterns in step 3 include head - and - shoulders top / bottom patterns, triangle top / bottom patterns, double - bottom / top patterns, and expanding bottom / top patterns.

[0027] The determination rules and algorithms for each technical pattern in Step 3 are different, as follows: (1) Head and shoulders top / bottom pattern: Any six consecutive extreme points found from the curve fitted by the Gaussian process are used as the judgment basis. Denote the six sequential extreme points as E0, E1, E2, E3, E4, E5 respectively: ① E0 < min(E2, E4) ② E5 is a maximum point ③ E3 >= 1.01 max(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E1 / E2 – 1 >= 0.05 ⑦ E5 / E4 - 1 >= 0.05 The pattern recognition of the head and shoulders bottom is completely reversed. The six sequential extreme points are E0, E1, E2, E3, E4, E5 respectively.

[0028] ① E0 > max(E2, E4) ② E5 is a minimum point ③ 1.01 E3 <= min(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E2 / E1 - 1 >= 0.05 ⑦ E4 / E5 - 1 >= 0.05 (2) Triangular top / bottom pattern: Any five consecutive extreme points found from the curve fitted by the Gaussian process are used as the judgment basis. Denote the five extreme points as E1, E2, E3, E4, E5 respectively: ① Calculate ret13 = E1 / E3 – 1, ret35 = E3 / E5 – 1, E42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.1 ③ 0.02 < ret35 < 0.1 ④ 0.02 < ret42 < 0.1 ⑤ E5 > 1.01 E4 ⑥ E5 is a maximum point According to the above rules, the triangular top pattern can be identified. The judgment of the triangular bottom is completely reversed and can be judged by using the above rules. Specifically: Record the five extreme points as E1, E2, E3, E4, and E5 in sequence: ① Calculate ret31 = E3 / E1 – 1, ret53 = E5 / E3 – 1, ret24 = E2 / E4 - 1 ② 0.02 < ret31 < 0.1 ③ 0.02 < ret53 < 0.1 ④ 0.02 < ret24 < 0.1 ⑤ E4 > 1.01 E5 ⑥ E5 is a minimum point (3)Double bottom / top pattern: The extreme value judgment of double top / bottom is different from other patterns.

[0029] Extreme point 1: A point that is the maximum or minimum value within the 𝜉 domain is called an extreme point. When 𝜉 takes 8, the extreme point exLag1 is obtained; Extreme point 2: A point that is the maximum or minimum value within the (x - 𝜉1, x + 𝜉2) domain is called an extreme point. When 𝜉1 takes 8 and 𝜉2 takes 4, the extreme point exLag2 is obtained. The data processed above is denoted as data.

[0030] At any extreme point exLag2, it is necessary to combine the previous 3 extreme points exLag1 at the position of this extreme point exLag2 to judge the pattern. Now, a way needs to be found to find the previous 3 extreme points exLag1 at any extreme point exLag2. The following is the algorithm processing: a. Remove the rows where exLag1 is not 0 to obtain new data, denoted as dataLag; b. A total of 4 extreme points are required for double bottom and double top judgments. Shift the indexes of dataLag 1 to 3 into the future, denoted as E12Index, E11Index, E10Index, and shift the indexes of dataLag 0 to 2, denoted as E22Index, E21Index, E20Index. It is necessary to judge which one to use later; c. Step b is to process the indexes. We also need to perform the same processing on the extreme value marks (1, -1) and the post - rights - adjusted closing prices corresponding to the extreme value positions. The extreme value marks are denoted as ex12, ex11, ex10, ex22, ex21, ex20; perform the same processing on the post - rights - adjusted closing prices, denoted as E12, E11Index, E10, E22, E21, E20; d. Combine the dataLag data with the original data (data containing exLag1 and exLag2) data, and combine them according to the two data indexes; e. Fill the columns starting with 2 (ex22, E22, E22Index, ex21, E21, E21Index, ex20, E20, E20Index) of the above processing backward. For the columns starting with 1 (ex12, E12, E12Index, ex11, E11, E11Index, ex10, E10, E10Index, a total of 9 columns), make a judgment. If the column starting with 1 is not empty, use the column starting with 2; otherwise, use the column starting with 1. Thus, at any extreme point exLag2, we can already obtain all the information of the previous 3 extreme points exLag1.

[0031] Next, make a judgment on the morphology: ① exLag = -1 and ex1 = -1 and ex2 = 1 and ex0 = 1 ② E2 > 1.1 max(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E0 > 1.005 E2 If the above conditions are met, the formation position of the bottom of the double bottom is recorded as T; otherwise, it is F, recorded in the DBOT column. The judgment of the double top is completely reversed and the above rules can be used for judgment: ① exLag = 1 and ex1 = 1 and ex2 = -1 and ex0 = -1 ② E2 1.1 < min(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E2 > 1.005 E0 (4) Expanding bottom / top morphology The judgment of the expanding bottom / top is similar to that of the triangular top / bottom. Any 5 consecutive extreme points found from the curve fitted by the Gaussian process are used as the judgment basis. Denote the 5 sequential extreme points as E1, E2, E3, E4, E5 in turn; Expanding top ① Calculate ret13 = E3 / E1 - 1, ret35 = E5 / E3 - 1, ret42 = E2 / E4 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is a maximum extreme point According to the above rules, the expanding top morphology can be discriminated. The judgment rules for the expanding bottom are as follows: ① Calculate ret13 = E1 / E3 - 1, ret35 = E3 / E5 - 1, ret42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is the minimum point According to the above rules, the expanding bottom pattern can be identified.

[0032] Step 4: After pattern recognition, set the breakout level. After breakout, determine that the pattern is a valid pattern; In Step 4, after a pattern appears, an effective signal needs to be given according to the pattern. Only after the pattern breaks out can the effectiveness of the pattern be determined. Specifically as follows: (1) Head and shoulders top / bottom pattern: According to the rules in Step 4, identify the last shoulder of the head and shoulders top pattern. Now, it is also necessary to determine the complete formation time point (breakout) of the pattern; take the average cycle length from E0 to E5, (the index corresponding to E5 minus the index corresponding to E0) 2 / 5, and then round it to get dateAvg; take the minimum of E2 and E4 as the baseline minLine, and judge one by one from the last shoulder: ① The post - adjusted closing price at 1.01 times the current time point is less than minLine; ② When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, after meeting the above conditions, take the first time point that meets the conditions and mark it as the complete formation time point of the head and shoulders top, denoted as S; For the head and shoulders bottom pattern recognition, it is completely reversed. ① Take the maximum of E2 and E4 as the baseline maxLine; ② The post - adjusted closing price at the current time point is greater than 1.01 times maxLine; ③ When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, after meeting the above conditions, take the first time point that meets the conditions and mark it as the complete formation time point of the head and shoulders bottom, denoted as S.

[0033] (2) Triangular top / bottom pattern: According to the rules in Step 4, identify the triangular top pattern. Now, it is also necessary to determine the breakout of the pattern; take the average cycle length from E1 to E5: (the index corresponding to E5 minus the index corresponding to E1) 2 / 4, and then round it to get dateAvg; start judging one by one from the position where the triangular top pattern is determined: ① The post - rights - adjusted closing price at the current time point > 1.01 times of E3, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, indicating an upward breakthrough; ② 1.01 times of the post - rights - adjusted closing price at the current time point > E4, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, indicating a downward breakthrough; After meeting the above conditions, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangle top, denoted as S; The judgment of the triangle bottom can be completely reversed by using the above rules: ① 1.01 times of the post - rights - adjusted closing price at the current time point < E3, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, indicating a downward breakthrough; ② The post - rights - adjusted closing price at the current time point > 1.01 times of E4, and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, indicating an upward breakthrough; After meeting the above conditions, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangle bottom, denoted as S.

[0034] (3)Double - bottom / double - top pattern Judge the double - bottom pattern according to the rules in step 4. Next, judge the breakthrough signal. The breakthrough point needs to exceed the highest value in the middle of the double - bottom, and the time taken cannot be too long. The two conditions are judged in turn: ① The index corresponding to E3 minus start (the index of point E0) + 1 After rounding 2.5 / 3, it is recorded as dateAvg; ② Starting from the position where the bottom of the double - bottom is formed, judge one by one backward. The post - rights - adjusted closing price is greater than or equal to 1.005 times of E2 and the current time point index minus the time point index where the double - bottom is formed is less than or equal to dateAvg. The first position that meets this condition is the time point when the double - bottom is completely formed; The double - top is judged by the following rules; Judge the double - top pattern according to the rules in step 4. Next, judge the breakthrough signal. The breakthrough point needs to be lower than the minimum value in the middle of the double - top, and the time taken cannot be too long. The two conditions are judged in turn; ① The index corresponding to E3 minus start (the index of point E0) + 1 After rounding 2.5 / 3, it is recorded as dateAvg; ② Starting from the position where the top of the double - top is formed, judge one by one backward. 1.005 times of the post - rights - adjusted closing price is less than or equal to E2 and the current time point index minus the time point index where the double - top is formed is less than or equal to dateAvg. The first position that meets this condition is the time point when the double - top is completely formed; (4)Expanding bottom / top pattern According to the rules in step 4, the expanding bottom pattern is identified. Now, it is necessary to determine the breakout position. The breakout position of the expanding bottom directly lags one period, i.e., one day, behind the E5 mark of the expanding top determined above. That is, the breakout signal of the expanding top pattern is given on the next day. The breakout judgment of the expanding top is the same as that of the expanding bottom. The breakout signal of the expanding bottom pattern is given on the next day after the E5 mark of the expanding top is determined with a one-day lag.

[0035] Step 5: Draw a schematic diagram of the pattern based on the definition of each pattern and the position of the extreme points.

[0036] After obtaining the signals of each pattern and the judgment features of the pattern in step 5, it is necessary to draw a schematic diagram of the pattern on the stock price chart. For connecting two extreme points with a straight line, the values between the extreme points are filled using linear interpolation. If it is a curve, a fitted curve graph is directly drawn.

[0037] Embodiment 1 The classic candlestick pattern recognition method based on machine learning algorithm of the present invention is specifically implemented according to the following steps: Step 1: Fit the stock price trend curve using Gaussian process; Step 2: Find the extreme points according to the smoothed stock price trend curve; Step 3: Define technical patterns through the correlation relationship of the positions of the extreme points; Step 4: Set the breakout position after pattern recognition, and determine the pattern as a valid pattern after breakout; Step 5: Draw a schematic diagram of the pattern based on the definition of each pattern and the position of the extreme points.

[0038] Embodiment 2 The classic candlestick pattern recognition method based on machine learning algorithm of the present invention, the flowchart is as Figure 1 shown, and is specifically implemented according to the following steps: Step 1: Fit the stock price trend curve using Gaussian process; Step 1 is specifically implemented according to the following steps: Use Gaussian process to fit the stock price. The features of the training set are selected as an arithmetic sequence with a common difference of 1, and the label is the post-rights-adjusted closing price for model training. The training results are saved, and a smooth and non-lagging curve is obtained by inputting the features of the training set; since Gaussian curve uses future data during fitting, it is necessary to perform fitting every day to judge in real time whether a technical pattern is formed. The technical pattern signals judged historically need to be saved, and no processing is done if there are changes during future fitting; Since fitting needs to be performed every day and the features are relatively fixed, considering the effective utilization of computing resources, the model training is accelerated.

[0039] In Step 1, the acceleration process of model training is specifically implemented according to the following steps: ① Given a time span, such as 1 year, calculate several matrix parameters in the Gaussian process of this arithmetic sequence: the Gaussian kernel matrix A of feature and feature, the Gaussian kernel matrix B of label and label, and the Gaussian kernel matrix C of label and feature; ② If the input stock feature length is the same as the default, directly use the calculated matrices A, B, and C for calculation; ③ If the input stock feature is less than the default time span, directly obtain the sliced kernel covariance matrix, which can also accelerate. However, the inverse of the kernel covariance matrix cannot be sliced and needs to be recalculated; In this way, several matrices in the Gaussian process can cache the results through this calculation, and the curve fitting of special lengths is calculated separately to achieve the acceleration effect.

[0040] Step 2: Find the extreme points according to the smoothed stock price trend curve; Step 3: Define the technical patterns through the correlation relationship of the extreme point positions; Step 4: Set the breakthrough position after pattern recognition, and determine the pattern as a valid pattern after breakthrough; Step 5: Make a schematic diagram of the pattern according to the definition of each pattern and the extreme point positions.

[0041] Example 3 The classic K-line pattern recognition method based on machine learning algorithm of the present invention has a flowchart as Figure 1 shown, and is specifically implemented according to the following steps: Step 1: Fit the stock price trend curve using the Gaussian process; Step 1 is specifically implemented according to the following steps: Use the Gaussian process to fit the stock price. Select the arithmetic sequence with a common difference of 1 as the training set feature, and the post-rights-adjusted closing price as the label for model training. Save the training results. By inputting the features of the training set, a smooth and non-lagging curve can be obtained; since the Gaussian curve uses future data during fitting, it is necessary to perform fitting every day to real-time judge whether the technical pattern is formed. The historical technical pattern signals judged need to be saved, and no processing is done if there are changes during future fitting; Since fitting is required every day and the features are relatively fixed, the problem of effective utilization of computing resources is considered, and the acceleration process of model training is carried out.

[0042] In Step 1, the acceleration process of model training is specifically implemented according to the following steps: ① Given a time span, such as 1 year, calculate several matrix parameters in the Gaussian process of this arithmetic sequence: the Gaussian kernel matrix A of feature and feature, the Gaussian kernel matrix B of label and label, and the Gaussian kernel matrix C of label and feature; ②If the length of the input stock features is the same as the default, directly use the calculated matrices A, B, and C for calculation; ③If the input stock features are less than the default time span, the kernel covariance matrix is directly obtained by slicing. This can also accelerate the calculation, but since the inverse of the kernel covariance matrix cannot be sliced, it has to be recalculated; In this way, the several matrices in the Gaussian process can cache the results through sequential calculations, and the curve fitting for special lengths is calculated separately to achieve acceleration.

[0043] Step 2: Find the extreme points based on the smoothed stock price trend curve; Step 2 is specifically implemented according to the following steps: ①The determination of extreme points is based on the fitted curve. The definition of extreme values refers to the mathematical definition. If a point is the maximum value among all points within a certain domain, it is a maximum extreme value; if it is the minimum value among all points within a certain domain, it is a minimum extreme value; ②After obtaining the extreme points on the fitted curve, the extreme points need to be corrected to the original stock price curve. To avoid using future data, historical correction is performed. If the point is a minimum extreme point and its position on the original curve is greater than the previous point, the minimum extreme point is corrected to the previous moment; if the point is a maximum extreme point and its position on the original curve is less than the previous point, the maximum extreme point is corrected to the previous moment; after obtaining the extreme points, it prepares for the subsequent morphological determination.

[0044] Step 3: Define technical patterns based on the correlation relationships of the positions of extreme points; Step 4: Set the breakout level after pattern recognition, and determine the pattern as a valid pattern after breakout; Step 5: Make a schematic diagram of the pattern according to the definition of each pattern and the positions of extreme points.

[0045] Example 4 The classic candlestick pattern recognition method based on machine learning algorithms in the present invention has a flow chart as Figure 1 shown, and is specifically implemented according to the following steps: Step 1: Use Gaussian process to fit the stock price trend curve; Step 1 is specifically implemented according to the following steps: Use Gaussian process to fit the stock price. The feature of the training set is selected as an arithmetic sequence with a common difference of 1, and the label is the post - rights - adjusted closing price for model training. Save the training results. By inputting the features of the training set, a smooth and non - lagged curve is obtained; since Gaussian curves use future data during fitting, it is necessary to perform fitting every day to real - time judge whether a technical pattern is formed. The technical pattern signals judged historically need to be saved, and no processing is done if they change during future fitting processes; Since fitting is required every day and the features are relatively fixed, the issue of efficient utilization of computing resources is considered, and the model training is accelerated.

[0046] Step 2: Find the extreme points based on the smoothed stock price trend curve; Step 3: Define technical patterns through the correlation of the positions of extreme points; The technical patterns in Step 3 include head and shoulders top / bottom patterns, triangle top / bottom patterns, double bottom / top patterns, and expanding bottom / top patterns.

[0047] The determination rules and algorithms for each technical pattern in Step 3 are different, as follows: (1) Head and shoulders top / bottom patterns: Take any six consecutive extreme points found from the curve fitted by the Gaussian process as the judgment basis, and denote the six sequential extreme points as E0, E1, E2, E3, E4, E5 in turn: ① E0 < min(E2, E4) ② E5 is a maximum point ③ E3 >= 1.01 max(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E1 / E2 – 1 >= 0.05 ⑦ E5 / E4 - 1 >= 0.05 The pattern recognition of the head and shoulders bottom is completely reversed, and the six sequential extreme points are E0, E1, E2, E3, E4, E5 in turn.

[0048] ① E0 > max(E2, E4) ② E5 is a minimum point ③ 1.01 E3 <= min(E1, E5) ④ abs(E5 / E1 - 1) <= 0.1 ⑤ abs(E4 / E2 - 1) <= 0.1 ⑥ E2 / E1 - 1 >= 0.05 ⑦ E4 / E5 - 1 >= 0.05 (2) Triangle top / bottom patterns: Take any five consecutive extreme points found from the curve fitted by the Gaussian process as the judgment basis, and denote the five extreme points as E1, E2, E3, E4, E5 in turn: ① Calculate ret13 = E1 / E3 – 1, ret35 = E3 / E5 – 1, E42 = E4 / E2 - 1 ②0.02 < ret13 < 0.1 ③0.02 < ret35 < 0.1 ④0.02 < ret42 < 0.1 ⑤E5 > 1.01 E4 ⑥E5 is the maximum point According to the above rules, the triangular top pattern can be identified. For the judgment of the triangular bottom, just reverse the above rules. Specifically: Denote the 5 extreme points as E1, E2, E3, E4, E5 in sequence: ① Calculate ret31 = E3 / E1 – 1, ret53 = E5 / E3 – 1, ret24 = E2 / E4 - 1 ②0.02 < ret31 < 0.1 ③0.02 < ret53 < 0.1 ④0.02 < ret24 < 0.1 ⑤E4 > 1.01 E5 ⑥E5 is the minimum point (3)Double bottom / top pattern: The extreme value judgment of the double top / bottom is different from other patterns.

[0049] Extreme point 1: A point that is the maximum or minimum value within the ξ domain is called an extreme point. When ξ takes 8, the extreme point exLag1 is obtained; Extreme point 2: A point that is the maximum or minimum value within the (x - ξ1, x + ξ2) domain is called an extreme point. When ξ1 takes 8 and ξ2 takes 4, the extreme point exLag2 is obtained. The data after the above processing is denoted as data.

[0050] At any extreme point exLag2, it is necessary to combine the previous 3 extreme points exLag1 at the position of this extreme point exLag2 to judge the pattern. Now, a way needs to be found to find the previous 3 extreme points exLag1 at any extreme point exLag2. The following is the algorithm processing: a. Remove the rows where exLag1 is not 0 to obtain new data, denoted as dataLag; b. A total of 4 extreme points are required for the double bottom and double top judgments. Shift the indices of dataLag 1 to 3 into the future, denoted as E12Index, E11Index, E10Index, and shift the indices of dataLag 0 to 2, denoted as E22Index, E21Index, E20Index. It is necessary to judge which one to use later; Step cb is to process the index. We also need to do the same processing on the extreme value mark (1, -1) and the adjusted closing price corresponding to the extreme value position. We record the extreme value marks as ex12, ex11, ex10, ex22, ex21, ex20; we also do the same processing on the adjusted closing price as E12, E11Index, E10, E22, E21, E20; d. Merge the dataLag data with the original data (including the data of exLag1 and exLag2) according to the two data indexes; e. The columns starting with 2 (ex22, E22, E22Index, ex21, E21, E21Index, ex20, E20, E20Index) processed above are filled backwards, and the columns starting with 1 (ex12, E12, E12Index, ex11, E11, E11Index, ex10, E10, E10Index, a total of 9 columns) are judged. If the column starting with 1 is not empty, the column starting with 2 is used, otherwise the column starting with 1 is used; so far, at any extreme point exLag2, we can get all the information of the first three extreme points exLag1.

[0051] The following is the judgment of the form: ①exLag=-1 and ex1=-1 and ex2=1 and ex0=1 ②E2>1.1 max(E1, E3) ③abs(E3 / E1-1)<0.01 ④E0>1.005 E2 If the above conditions are met, the bottom of the double bottom is recorded as T, otherwise it is F, recorded as DBOT column. The judgment of the double top can be judged by the above rules in the opposite way: ①exLag=1 and ex1=1 and ex2=-1 and ex0=-1 ②E2 1.1 <min(E1,E3) ③abs(E3 / E1-1)<0.01 ④E2>1.005 E0 (4) Expanding bottom / top pattern The judgment of the expansion bottom / top is similar to the triangular top / bottom. The judgment is based on any five consecutive extreme points found by the curve fitted by the Gaussian process. The five sequential extreme points are E1, E2, E3, E4, and E5. Expansion top ① Calculate ret13 = E3 / E1 - 1, ret35 = E5 / E3 - 1, ret42 = E2 / E4 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is the maximum point According to the above rules, the expanding top pattern can be identified. The judgment rules for the expanding bottom are as follows: ① Calculate ret13 = E1 / E3 - 1, ret35 = E3 / E5 - 1, ret42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is the minimum point According to the above rules, the expanding bottom pattern can be identified.

[0052] Step 4: Set the breakout level after pattern recognition, and determine the pattern as a valid pattern after breakout; Step 5: Draw a schematic diagram of the pattern based on the definition of each pattern and the position of the extreme point.

[0053] Example 5 The classic candlestick pattern recognition method based on machine learning algorithm of the present invention has a flow chart as Figure 1 shown, and is specifically implemented according to the following steps: Step 1: Use Gaussian process to fit the stock price trend curve; Step 2: Find the extreme points according to the smoothed stock price trend curve; Step 3: Define the technical pattern through the correlation relationship of the positions of the extreme points; Step 4: Set the breakout level after pattern recognition, and determine the pattern as a valid pattern after breakout; In Step 4, after a pattern appears, an effective signal needs to be given according to the pattern. Only after the pattern breaks through can the effectiveness of the pattern be determined. Specifically as follows: (1) Head and shoulders top / bottom pattern: According to the rules in Step 4, identify the last shoulder of the head and shoulders top pattern. Now, it is also necessary to determine the complete formation time point (breakthrough) of the pattern; take the average cycle length from E0 to E5, (the index corresponding to E5 minus the index corresponding to E0) 2 / 5, and then round it to get dateAvg; take the minimum value of E2 and E4 as the baseline minLine, and judge one by one from the last shoulder backwards: ① The post - rights - adjusted closing price at the current time point multiplied by 1.01 is less than minLine; ② After the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, take the first time point that meets the conditions and mark it as the fully - formed time point of the head - and - shoulders top, denoted as S; The pattern recognition of the head - and - shoulders bottom is completely reversed. ① Take the maximum value of E2 and E4 as the baseline maxLine; ② The post - rights - adjusted closing price at the current time point is greater than 1.01 times of maxLine; ③ After the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, take the first time point that meets the conditions and mark it as the fully - formed time point of the head - and - shoulders bottom, denoted as S.

[0054] (2)Triangle top / bottom pattern: According to the rules in step 4, the triangle top pattern is identified. Now it is necessary to judge the breakthrough of the pattern; take the average cycle length from E1 to E5: (the index corresponding to E5 minus the index corresponding to E1) 2 / 4, and then round it to get dateAvg; start judging one by one from the position where the triangle top pattern is determined: ① If the post - rights - adjusted closing price at the current time point > 1.01 times of E3 and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, upward breakthrough; ② If 1.01 times of the post - rights - adjusted closing price at the current time point > E4 and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, downward breakthrough; after the above conditions are met, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangle top, denoted as S; The judgment of the triangle bottom is completely reversed and can be judged using the above rules: ① If 1.01 times of the post - rights - adjusted closing price at the current time point < E3 and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as - 1, downward breakthrough; ② If the post - rights - adjusted closing price at the current time point > 1.01 times of E4 and the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg, then mark it as 1, upward breakthrough; after the above conditions are met, take the first time point that meets the conditions and mark it as the breakthrough time point of the triangle bottom, denoted as S.

[0055] (3)Double - bottom / top pattern Identify the double-bottom pattern according to the rules in Step 4. Next, judge the breakout signal. The breakout point needs to exceed the highest value in the middle of the double bottom and should not take too long. The two conditions are judged in sequence: ① The index corresponding to E3 minus start (the index of point E0) + 1 Round 2.5 / 3 to the nearest whole number and record it as dateAvg; ② Starting from the formation position of the bottom of the double bottom, judge one by one backward. The post-rights-adjusted closing price is greater than or equal to 1.005 times of E2 and the current time point index minus the time point index of the double bottom formation position is less than or equal to dateAvg. The first position that meets this condition is the time point when the double bottom is fully formed; The double top is judged using the following rules; Identify the double-top pattern according to the rules in Step 4. Next, judge the breakout signal. The breakout point needs to be lower than the minimum value in the middle of the double top and should not take too long. The two conditions are judged in sequence; ① The index corresponding to E3 minus start (the index of point E0) + 1 Round 2.5 / 3 to the nearest whole number and record it as dateAvg; ② Starting from the formation position of the top of the double top, judge one by one backward. 1.005 times of the post-rights-adjusted closing price is less than or equal to E2 and the current time point index minus the time point index of the double top formation position is less than or equal to dateAvg. The first position that meets this condition is the time point when the double top is fully formed; (4) Expanding bottom / top pattern Identify the expanding bottom pattern according to the rules in Step 4. Now it is also necessary to judge the breakout position. The breakout position of the expanding bottom is directly one day later than the E5 mark of the expanding top judged above, that is, give the breakout signal of the expanding top pattern on the next day. The breakout judgment of the expanding top is the same as that of the expanding bottom. One day later than the E5 mark of the expanding top judged, that is, give the breakout signal of the expanding bottom pattern on the next day.

[0056] Step 5, Make a schematic diagram of the pattern according to the definition of each pattern and the position of the extreme point.

[0057] Example 6 The classical candlestick pattern recognition method based on machine learning algorithm of the present invention is specifically implemented according to the following steps: Step 1, Use Gaussian process to fit the stock price trend curve: The Gaussian process is used to fit the stock price. The features of the training set are selected as an arithmetic sequence with a common difference of 1, and the label is the post - rights - adjusted closing price for model training. The results of the training are saved. By inputting the features of the training set, a smooth and non - lagged curve can be obtained. Since the Gaussian curve uses future data during fitting, it is necessary to perform fitting every day to judge in real - time whether the technical pattern is formed. The technical pattern signals judged historically need to be saved, and no processing is done if there are changes during future fitting.

[0058] Since fitting needs to be performed every day and the features are relatively fixed, the issue of efficient utilization of computing resources is considered, and the model training is accelerated as follows: ① Given a time span, calculate several matrix parameters within the Gaussian process of this arithmetic sequence; ② If the length of the stock features is the same as the default, the pre - calculated parameters can be directly used for calculation; ③ When the input features are less than the default time span, the kernel covariance matrix can be directly obtained by taking slices, which can also accelerate. However, the inverse of the kernel covariance matrix cannot be sliced and can only be recalculated.

[0059] In this way, several matrix parameters in the Gaussian process can cache the results through one - time calculation, and the curve fitting of special lengths is calculated separately, which can play an accelerating role.

[0060] Compared with traditional smoothing algorithms, such as simple moving average (SMA), exponential weighted moving average (EMA), and Hull moving average (HMA), the curve fitted by the Gaussian process has no latency ( Figure 2 )

[0061] Step 2: Find the extreme points according to the smoothed stock price trend curve: ① The determination of extreme points is on the fitted curve. The definition of extreme values refers to the mathematical definition. If a point is the maximum value of all points within a certain domain, it is a maximum extreme value; if it is the minimum value of all points within a certain domain, it is a minimum extreme value. ② After obtaining the extreme points on the fitted curve, the extreme points need to be corrected to the original stock price curve. To avoid using future data, historical correction is performed. If this point is a minimum extreme point and the position on the original curve is greater than the previous point, the minimum extreme point is corrected to the previous moment; if this point is a maximum extreme point and the position on the original curve is less than the previous point, the maximum extreme point is corrected to the previous moment.

[0062] With the extreme points, the subsequent pattern determination can be carried out.

[0063] Step 3: Define the technical pattern through the correlation of the positions of extreme points.

[0064] The determination rules and algorithms for each pattern are different. Examples are given below for illustration: (1)Head and shoulders top / bottom pattern Any six consecutive extreme points found from the curve fitted by the Gaussian process are used as the judgment basis. Denote the six sequential extreme points as E0, E1, E2, E3, E4, E5 in turn: ①E0 < min(E2, E4) ②E5 is a maximum point ③E3 >= 1.01 max(E1, E5) ④abs(E5 / E1 - 1) <= 0.1 ⑤abs(E4 / E2 - 1) <= 0.1 ⑥E1 / E2 – 1 >= 0.05 ⑦E5 / E4 - 1 >= 0.05 The pattern recognition of the head and shoulders bottom is completely reversed. The six sequential extreme points are E0, E1, E2, E3, E4, E5 in turn.

[0065] ①E0 > max(E2, E4) ②E5 is a minimum point ③1.01 E3 <= min(E1, E5) ④abs(E5 / E1 - 1) <= 0.1 ⑤abs(E4 / E2 - 1) <= 0.1 ⑥E2 / E1 - 1 >= 0.05 ⑦E4 / E5 - 1 >= 0.05 (2)Triangle top / bottom pattern Any five consecutive extreme points found from the curve fitted by the Gaussian process are used as the judgment basis. Denote the five extreme points as E1, E2, E3, E4, E5 in turn: ①Calculate ret13 = E1 / E3 – 1, ret35 = E3 / E5 – 1, E42 = E4 / E2 - 1 ②0.02 < ret13 < 0.1 ③0.02 < ret35 < 0.1 ④0.02 < ret42 < 0.1 ⑤E5 > 1.01 E4 ⑥E5 is a maximum point According to the above rules, the triangle top pattern can be identified. The judgment of the triangle bottom is completely reversed and can be judged by adopting the above rules. Specifically: Record the five extreme points as E1, E2, E3, E4, and E5 in sequence: ① Calculate ret31 = E3 / E1 – 1, ret53 = E5 / E3 – 1, ret24 = E2 / E4 - 1 ② 0.02 < ret31 < 0.1 ③ 0.02 < ret53 < 0.1 ④ 0.02 < ret24 < 0.1 ⑤ E4 > 1.01 E5 ⑥ E5 is a minimum point.

[0066] (3)Double bottom / top pattern The extreme value judgment of double tops / bottoms is different from other patterns.

[0067] Extreme point 1: A point that is the maximum or minimum value within the ξ domain is called an extreme point. When ξ takes 8, the extreme point exLag1 is obtained; Extreme point 2: A point that is the maximum or minimum value within the (x - ξ1, x + ξ2) domain is called an extreme point. When ξ1 takes 8 and ξ2 takes 4, the extreme point exLag2 is obtained. The data after the above processing is denoted as data.

[0068] At any extreme point exLag2, it is necessary to combine the previous 3 extreme points exLag1 at the position of this extreme point exLag2 to judge the pattern. Now, a way needs to be found to find the previous 3 extreme points exLag1 at any extreme point exLag2. The following is the algorithm processing: a. Remove the rows where exLag1 is not 0 to obtain new data, denoted as dataLag; b. A total of 4 extreme points are required for double bottom and double top judgments. Shift the indexes of dataLag 1 to 3 into the future, denoted as E12Index, E11Index, E10Index, and shift the indexes of dataLag 0 to 2, denoted as E22Index, E21Index, E20Index. It is necessary to judge which one to use later; c. Step b is to process the indexes. We also need to perform the same processing on the extreme value marks (1, -1) and the post - rights - adjusted closing prices corresponding to the extreme value positions. The extreme value marks are denoted as ex12, ex11, ex10, ex22, ex21, ex20; perform the same processing on the post - rights - adjusted closing prices, denoted as E12, E11Index, E10, E22, E21, E20; d. Combine the dataLag data with the original data (data containing exLag1 and exLag2) data, and combine them according to the two data indexes; e. Fill the columns starting with 2 (ex22, E22, E22Index, ex21, E21, E21Index, ex20, E20, E20Index) of the above processing backward. Judge the columns starting with 1 (ex12, E12, E12Index, ex11, E11, E11Index, ex10, E10, E10Index, a total of 9 columns). If the columns starting with 1 are not empty, use the columns starting with 2; otherwise, use the columns starting with 1. At this point, at any extreme point exLag2, we can already obtain all the information of the previous 3 extreme points exLag1.

[0069] Next, perform the morphological judgment: ① exLag = -1 and ex1 = -1 and ex2 = 1 and ex0 = 1 ② E2 > 1.1 max(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E0 > 1.005 E2 If the above conditions are met, the formation position of the bottom of the double bottom is recorded as T; otherwise, it is recorded as F, denoted as the DBOT column. The judgment of the double top can be completely reversed by using the above rules: ① exLag = 1 and ex1 = 1 and ex2 = -1 and ex0 = -1 ② E2 1.1 < min(E1, E3) ③ abs(E3 / E1 - 1) < 0.01 ④ E2 > 1.005 E0 (4)Expansion bottom / top pattern The judgment of the expansion bottom / top is similar to that of the triangle top / bottom. Use any 5 consecutive extreme points found by the curve fitted by the Gaussian process as the judgment basis. Denote the 5 sequential extreme points as E1, E2, E3, E4, E5: Expansion top ① Calculate ret13 = E3 / E1 - 1, ret35 = E5 / E3 - 1, ret42 = E2 / E4 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is a maximum extreme point According to the above rules, the expansion top pattern can be discriminated. The judgment rules for the expansion bottom are as follows: ① Calculate ret13 = E1 / E3 - 1, ret35 = E3 / E5 - 1, ret42 = E4 / E2 - 1 ② 0.02 < ret13 < 0.2 ③ 0.02 < ret35 < 0.2 ④ 0.02 < ret42 < 0.2 ⑤ E2 < E1 ⑥ E5 is the minimum point According to the above rules, the expanding bottom pattern can be identified.

[0070] Step 4: Set the breakout level after pattern recognition, and determine the pattern as a valid pattern after breakout: Step 5: Draw a schematic diagram of the pattern based on the definition of each pattern and the position of the extreme point After obtaining the signals of each pattern and the determination characteristics of the pattern, it is necessary to draw a schematic diagram of the pattern on the stock price chart. For connecting two extreme points with a straight line, the values are filled by linear interpolation between the extreme points. If it is a curve, a fitted curve graph is directly drawn. The schematic diagrams of each pattern are given by way of example in the following figures. As shown in Figures 3(a) and 3(b), Figure 3(a) is a case of the head and shoulders bottom pattern; Figure 3(a) is a case of the head and shoulders top pattern; Figure 4(a) is a case of the triangle bottom pattern; Figure 4(b) is a case of the triangle top pattern; Figure 5(a) is a case of the double top pattern; Figure 5(b) is a case of the double bottom pattern; Figure 6(a) is a case of the expanding top pattern; Figure 6(b) is a case of the expanding bottom pattern.

Claims

1. The classic K-line pattern recognition method based on machine learning algorithm is characterized by: Follow the steps below to implement it: Step 1: Use Gaussian process to fit the stock price trend curve; Step 2: Find extreme points based on the smooth stock price trend curve; Step 3: Define the technical pattern by the correlation of the extreme point positions; Step 4: Set the breakthrough position after pattern recognition, and determine the pattern as a valid pattern after breakthrough; Step 5: Make a pattern diagram based on the definition of each pattern and the location of the extreme points.

2. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 1, characterized in that: The step 1 is specifically implemented according to the following steps: The Gaussian process is used to fit the stock price. The training set features are selected as arithmetic progressions with an arithmetic interval of 1. The label is the adjusted closing price for model training. The training results are saved, and a smooth curve without lag is obtained by inputting the features of the training set. Since the Gaussian curve uses future data when fitting, it needs to be fitted every day to determine in real time whether the technical pattern is formed. The technical pattern signals judged in the past need to be saved, and no processing will be done if they change during the future fitting process. Since fitting needs to be performed every day and the features are relatively fixed, model training is accelerated.

3. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 2, characterized in that: The acceleration of model training in step 1 is specifically implemented according to the following steps: ① Given a time span, calculate several matrix parameters in the Gaussian process of the arithmetic sequence: Gaussian kernel matrix A between features, Gaussian kernel matrix B between labels, and Gaussian kernel matrix C between labels and features; ② If the input stock feature length is consistent with the default, the calculated A, B, C matrix is ​​directly used for calculation; ③ If the input stock feature is shorter than the default time span, the kernel covariance matrix can be directly obtained by slicing, which can also speed up the process. However, the inverse of the kernel covariance matrix cannot be sliced ​​and can only be recalculated. In this way, the results of several matrices in the Gaussian process can be cached by this calculation, and the curve fitting of special length can be calculated separately, which plays an accelerating role.

4. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 3, characterized in that: The step 2 is specifically implemented according to the following steps: ① The determination of the extreme point is that on the fitting curve, if the point is the maximum value of all points in a certain range, it is the maximum value; if it is the minimum value of all points in a certain range, it is the minimum value; ② After obtaining the extreme point on the fitting curve, it is necessary to correct the extreme point to the original stock price curve. To avoid using future data, a historical correction is performed. If the point is a minimum point and the original curve position is greater than the previous point, the minimum point is corrected to the previous moment; if the point is a maximum point and the original curve position is less than the previous point, the maximum point is corrected to the previous moment; After obtaining the extreme points, prepare for the subsequent shape determination.

5. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 4, characterized in that: The technical patterns in step 3 include head and shoulders top / bottom pattern, triangle top / bottom pattern, double bottom / top pattern, and expanding bottom / top pattern.

6. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 5, characterized in that: The specific determination rules for each technical form in step 3 are as follows: (1) Head and Shoulders Top / Bottom Pattern: Take any 6 consecutive extreme points found by the curve fitted by Gaussian process as the basis for judgment, and record the 6 sequential extreme points as E0, E1, E2, E3, E4, E5: ①E0 <min(E2,E4) ②E5 is the maximum point ③E3>=1.01 max(E1,E5) ④abs(E5 / E1-1)<=0.1 ⑤abs(E4 / E2-1)<=0.1 ⑥E1 / E2–1>=0.05 ⑦E5 / E4-1>=0.05 The pattern recognition of the head and shoulders bottom is completely reversed, and the six sequential extreme points are E0, E1, E2, E3, E4, and E5; ①E0>max(E2,E4) ②E5 is the minimum point <h2 style=";text-align:left;direction:ltr">③1.01<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> E3<=min(E1, E5) ④abs(E5 / E1 - 1) <= 0.1 ⑤abs(E4 / E2 - 1) <= 0.1 ⑥E2 / E1 - 1 >= 0.05 ⑦E4 / E5 - 1 >= 0.05 (2) Triangle top / bottom pattern: Take any five consecutive extreme points found by the curve fitted by Gaussian process as the basis for judgment, and record the five extreme points as E1, E2, E3, E4, and E5: ① Calculate ret13=E1 / E3–1, ret35=E3 / E5–1, E42=E4 / E2-1 ②0.02 <ret13<0.1 ③0.02 <ret35<0.1 ④0.02 <ret42<0.1 ⑤E5>1.01 E4 ⑥E5 is the maximum point According to the above rules, the triangle top can be identified. The triangle bottom can be identified by the reverse of the above rules, specifically: The five extreme points are E1, E2, E3, E4, and E5: ① Calculate ret31=E3 / E1–1, ret53=E5 / E3–1, ret24=E2 / E4-1 ②0.02 <ret31<0.1 ③0.02 <ret53<0.1 ④0.02 <ret24<0.1 <h2 style=";text-align:left;direction:ltr">⑤E4>1.01<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> E5 ⑥E5 is the minimum point (3) Double bottom / top pattern: The extreme value judgment of double tops / bottoms is different from other forms: Extreme point 1: A point that is the maximum or minimum value in the 𝜉 domain is called an extreme point. 𝜉 is 8, and we get the extreme point exLag1; Extreme point 2: A point that is the maximum or minimum value in the range of (x-𝜉1, x+𝜉2) is called an extreme point. 𝜉1 is 8, 𝜉2 is 4, and the extreme point exLag2 is obtained. The data after the above processing is recorded as data; At any extreme point exLag2, it is necessary to combine the three extreme points exLag1 before the extreme point exLag2 to determine the shape. The following is the algorithm processing: a. Remove the rows where exLag1 is not 0 and get new data, recorded as dataLag; b. Double bottom and double top judgment requires a total of 4 extreme value points. The index of dataLag is shifted 1~3 to the future, recorded as E12Index, E11Index, E10Index, and the index of dataLag is shifted 0~2, recorded as E22Index, E21Index, E20Index. It is necessary to determine which one to use later; Step cb is to process the index. We also need to do the same processing on the extreme value mark (1, -1) and the adjusted closing price corresponding to the extreme value position. We record the extreme value marks as ex12, ex11, ex10, ex22, ex21, ex20; we also do the same processing on the adjusted closing price as E12, E11Index, E10, E22, E21, E20; d. Merge the dataLag data with the original data (including the data of exLag1 and exLag2) according to the two data indexes; e. The columns starting with 2 (ex22, E22, E22Index, ex21, E21, E21Index, ex20, E20, E20Index) processed above are filled backwards, and the columns starting with 1 (ex12, E12, E12Index, ex11, E11, E11Index, ex10, E10, E10Index, a total of 9 columns) are judged. If the column starting with 1 is not empty, the column starting with 2 is used, otherwise the column starting with 1 is used; so far, at any extreme point exLag2, we can already get all the information of the first three extreme points exLag1; The following is the judgment of the form: ①exLag=-1 and ex1=-1 and ex2=1 and ex0=1 ②E2>1.1 max(E1,E3) ③abs(E3 / E1-1)<0.01 <h2 style=";text-align:left;direction:ltr">④E0>1.005<h2 style=";text-align:left;direction:ltr"> <h2 style=";text-align:left;direction:ltr"> E2 If the above conditions are met, the bottom of the double bottom is recorded as T, otherwise it is F, recorded as DBOT column. The judgment of the double top can be judged by the above rules in the opposite way: ①exLag=1 and ex1=1 and ex2=-1 and ex0=-1 2E2 1.1 < min(E1,E3) ③abs(E3 / E1-1)<0.01 ④E2>1.005 E0 (4) Expanding bottom / top pattern The judgment of the expansion bottom / top is similar to the triangular top / bottom. The judgment is based on any five consecutive extreme points found by the curve fitted by the Gaussian process. The five sequential extreme points are E1, E2, E3, E4, and E5. Expansion top ① Calculate ret13=E3 / E1-1, ret35=E5 / E3-1, ret42=E2 / E4-1 ②0.02 <ret13<0.2 ③0.02 <ret35<0.2 ④0.02 <ret42<0.2 ⑤E2 <E1 ⑥E5 is the maximum point According to the above rules, the expansion top pattern can be identified. The rules for determining the expansion bottom are as follows: ① Calculate ret13=E1 / E3-1, ret35=E3 / E5-1, ret42=E4 / E2-1 ②0.02 <ret13<0.2 ③0.02 <ret35<0.2 ④0.02 <ret42<0.2 ⑤E2 <E1 ⑥E5 is the minimum point According to the above rules, the expanding bottom pattern can be identified.

7. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 6, characterized in that: In step 4, after the pattern is formed, an effective signal needs to be given according to the pattern. The validity of the pattern can only be determined after the pattern breaks through, as follows: (1) Head and Shoulders Top / Bottom Pattern: According to the rules of step 4, the last shoulder of the head and shoulders top pattern is determined. Now we need to determine the time when the pattern is fully formed (breakthrough); take the average cycle length from E0 to E5 (the index corresponding to E5 minus the index corresponding to E0) 2 / 5, then round it off and record it as dateAvg; take the minimum value of E2 and E4 as the baseline minLine, and judge one by one from the last shoulder: ① The current adjusted closing price at 1.01 times is less than minLine; ② When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, the first time point that meets the conditions is marked as the time point when the head and shoulders top is fully formed, recorded as S; The pattern recognition of the head and shoulders bottom is completely reversed. ① Take the maximum value of E2 and E4 as the baseline maxLine; ② The adjusted closing price at the current time is greater than 1.01 times maxLine; ③ When the difference between the index corresponding to the current time point and the index of E5 is less than dateAvg and the above conditions are met, the first time point that meets the conditions is marked as the time point when the head and shoulders bottom is fully formed, recorded as S; (2) Triangle top / bottom pattern: According to the rules of step 4, the triangle top pattern is determined. Now we need to determine the breakthrough of the pattern. Take the average cycle length from E1 to E5: (the index corresponding to E5 minus the index corresponding to E1) 2 / 4, then round it off and record it as dateAvg; start from the position where the triangle top is determined and judge one by one: ① If the adjusted closing price at the current time is greater than 1.01 times of E3, and the index difference between the current time and E5 is less than dateAvg, it is marked as 1, indicating an upward breakthrough; ② If the current time point's 1.01 times adjusted closing price is greater than E4, and the index difference between the current time point and E5 is less than dateAvg, it is marked as -1, indicating a downward breakthrough. After the above conditions are met, the first time point that meets the conditions is marked as the breakthrough time point of the triangle top, recorded as S. The judgment of the triangle bottom can be judged by using the above rules in the opposite way: ① If the current time point's 1.01 times adjusted closing price is less than E3, and the index difference between the current time point and E5 is less than dateAvg, then it is marked as -1, indicating a downward breakthrough; ② If the adjusted closing price at the current time point is greater than 1.01 times of E4, and the index difference between the current time point and E5 is less than dateAvg, it is marked as 1, and it breaks upward. After the above conditions are met, the first time point that meets the conditions is marked as the breakthrough time point of the triangle bottom, recorded as S; (3) Double bottom / top pattern According to the rules of step 4, the double bottom pattern is identified. Next, the breakthrough signal is determined. The breakthrough point needs to exceed the highest value in the middle of the double bottom, and the time taken cannot be too long. The two conditions are judged in turn: ①The index corresponding to E3 minus start (the index of E0) + 1 2.5 / 3 is rounded off and recorded as dateAvg; ② Starting from the bottom of the double bottom, judge backward one by one. If the adjusted closing price is greater than or equal to 1.005 times E2 and the current time point index minus the time point index of the double bottom formation position is less than or equal to dateAvg, the first position that meets this condition is the time point when the double bottom is fully formed; Double tops are determined using the following rules; According to the rules of step 4, the double top pattern is determined. Next, the breakthrough signal is determined. The breakthrough point needs to be lower than the minimum value in the middle of the double top, and the time taken cannot be too long. The two conditions are determined in turn. ①The index corresponding to E3 minus start (the index of E0) + 1 2.5 / 3 is rounded off and recorded as dateAvg; ② Starting from the top of the double top, judge backward one by one. If 1.005 times of the adjusted closing price is less than or equal to E2 and the current time point index minus the time point index of the double top formation position is less than or equal to dateAvg, the first position that meets this condition is the time point when the double top is fully formed; (4) Expanding bottom / top pattern According to the rules of step 4, the expansion bottom pattern is determined. Now it is necessary to determine the breakthrough position. The breakthrough position of the expansion bottom directly lags behind the E5 mark used to determine the expansion top by one period, that is, one day. That is, a breakthrough signal of the expansion top pattern is given on the next day. The breakthrough judgment of the expansion top is consistent with that of the expansion bottom. The E5 mark used to determine the expansion top lags behind by one period, that is, one day. That is, a breakthrough signal of the expansion bottom pattern is given on the next day.

8. The method for recognizing classic K-line patterns based on a machine learning algorithm according to claim 7, characterized in that: After obtaining the signal and judgment features of each form in step 5, it is necessary to draw a schematic diagram of the form on the stock price chart. For a straight line connecting two extreme points, the values ​​between the extreme points are filled in by linear interpolation. If it is a curve, a fitting curve diagram is directly drawn.

Citation Information

Cited By

  • Method, system and equipment for searching classic form of stock average line multi-head arrangement based on YOLO and medium

    CN121564737A