TA-Lib学习研究笔记(九)——Pattern Recognition (5)

2023-12-13 05:25:54

TA-Lib学习研究笔记(九)——Pattern Recognition (5)

最全面的形态识别的函数的应用,通过使用A股实际的数据,验证形态识别函数,用K线显示出现标志的形态走势,由于入口参数基本上是open, high, low, close ,统一设置程序代码,只更换函数即可。
发现有的形态在一个股票上从未出现,选择多个股票参与计算测试。
函数返回值integer (values are -100, 0 or 100) ,0 是无形态信号。100 和 -100 是有正向或负向的形态信号。

41.CDLMATCHINGLOW - Matching Low

函数名:CDLMATCHINGLOW
名称:Matching Low 相同低价
简介:二日K线模式,下跌趋势中,第一日长阴线,
第二日阴线,收盘价与前一日相同,预示底部确认,该价格为支撑位。

语法:

integer = CDLMATCHINGLOW(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-17 100
2000-06-26 100
在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2000-02-14  19.20  20.38  18.70  20.37    10.11
2000-02-15  20.50  21.01  19.10  19.46    -4.47
2000-02-16  19.30  19.30  18.56  18.83    -3.24
2000-02-17  18.83  19.69  18.23  18.80    -0.16
2000-02-18  18.79  18.79  18.15  18.41    -2.07
2000-02-21  18.41  19.50  18.00  18.91     2.72
2000-02-22  19.00  19.25  18.20  18.25    -3.49
2000-02-23  18.20  18.58  18.00  18.10    -0.82
2000-02-24  18.05  18.30  18.00  18.18     0.44
2000-02-25  18.18  18.20  18.00  18.09    -0.50
             open   high    low  close  pct_chg
trade_date                                     
2000-06-16  18.79  18.97  18.38  18.49    -1.60
2000-06-19  18.50  18.54  18.20  18.28    -1.14
2000-06-20  18.28  18.40  18.07  18.19    -0.49
2000-06-21  18.23  18.35  18.08  18.23     0.22
2000-06-23  18.50  18.50  18.10  18.22    -0.05
2000-06-26  18.22  18.32  18.10  18.20    -0.11
2000-06-27  18.20  18.30  18.05  18.13    -0.38
2000-06-28  18.13  18.30  18.10  18.15     0.11
2000-06-29  18.15  18.20  18.00  18.07    -0.44
2000-06-30  18.08  18.26  17.90  18.13     0.33
2000-07-03  18.00  18.03  17.70  17.74    -2.15
2000-07-04  17.68  17.99  17.59  17.84     0.56
2000-07-05  17.85  17.86  17.60  17.67    -0.95
2000-07-06  17.67  17.85  17.66  17.72     0.28

42.CDLMATHOLD - Mat Hold

函数名:CDLMATHOLD
名称:Mat Hold 铺垫
简介:五日K线模式,上涨趋势中,第一日阳线,第二日跳空高开影线,
第三、四日短实体影线,第五日阳线,收盘价高于前四日,预示趋势持续。

语法:

integer = CDLMATHOLD(open, high, low, close, penetration=0)

stock code: 000035.SZ
position Pattern date:
trade_date
2007-04-06 100

在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2019-12-06  10.06  10.11  10.01  10.05  -0.5935
2019-12-09  10.05  10.20  10.05  10.12   0.6965
2019-12-10  10.12  10.29  10.10  10.28   1.5810
2019-12-11  10.30  10.30  10.19  10.29   0.0973
2019-12-12  10.29  10.32  10.20  10.21  -0.7775
2019-12-13  10.23  10.33  10.17  10.25   0.3918
2019-12-16  10.30  10.47  10.27  10.44   1.8537
2019-12-17  10.46  10.64  10.38  10.50   0.5747
2019-12-18  10.53  10.59  10.28  10.30  -1.9048
2019-12-19  10.32  10.41  10.28  10.38   0.7767
2019-12-20  10.33  10.58  10.33  10.49   1.0597
2019-12-23  10.50  10.86  10.49  10.74   2.3832
2019-12-24  10.67  11.08  10.52  11.02   2.6071
2019-12-25  10.88  10.98  10.78  10.85  -1.5426
2019-12-26  10.85  11.27  10.85  11.27   3.8710

43.CDLMORNINGDOJISTAR - Morning Doji Star

函数名:CDLMORNINGDOJISTAR
名称:Morning Doji Star 十字晨星
简介:三日K线模式,
基本模式为晨星,第二日K线为十字星,预示底部反转。

语法:

integer = CDLMORNINGDOJISTAR(open, high, low, close, penetration=0)

stock code: 000001.SZ
position Pattern date:
trade_date
2003-02-19 100
2003-08-15 100
在这里插入图片描述

 open   high    low  close  pct_chg
trade_date                                     
2003-02-10  11.58  11.60  11.25  11.31    -2.75
2003-02-11  11.30  11.39  11.25  11.38     0.62
2003-02-12  11.38  11.45  11.28  11.42     0.35
2003-02-13  11.42  11.60  11.20  11.24    -1.58
2003-02-14  11.25  11.43  11.21  11.33     0.80
2003-02-17  11.34  11.39  11.18  11.21    -1.06
2003-02-18  11.20  11.25  11.10  11.18    -0.27
2003-02-19  11.18  11.32  11.09  11.31     1.16
2003-02-20  11.31  11.38  11.22  11.27    -0.35
2003-02-21  11.25  11.27  10.91  10.92    -3.11
2003-02-24  10.90  10.99  10.83  10.85    -0.64
2003-02-25  10.84  11.13  10.81  11.07     2.03
2003-02-28  11.35  11.39  11.14  11.27     1.81
             open   high    low  close  pct_chg
trade_date                                     
2003-08-05  10.88  10.92  10.79  10.81    -0.64
2003-08-06  10.81  10.84  10.67  10.78    -0.28
2003-08-07  10.78  11.16  10.73  10.95     1.58
2003-08-08  10.95  10.98  10.68  10.71    -2.19
2003-08-11  10.67  10.82  10.57  10.74     0.28
2003-08-12  10.75  10.87  10.70  10.76     0.19
2003-08-13  10.76  10.82  10.61  10.62    -1.30
2003-08-14  10.59  10.70  10.55  10.59    -0.28
2003-08-15  10.59  10.98  10.57  10.79     1.89
2003-08-18  10.79  10.95  10.72  10.88     0.83
2003-08-19  10.90  10.96  10.84  10.86    -0.18
2003-08-20  10.86  10.91  10.66  10.73    -1.20
2003-08-21  10.77  10.85  10.70  10.85     1.12
2003-08-22  10.80  10.99  10.72  10.75    -0.92
2003-08-25  10.70  10.70  10.48  10.52    -2.14

44.CDLMORNINGSTAR - Morning Star

函数名:CDLMORNINGSTAR
名称:Morning Star 晨星
简介:三日K线模式,下跌趋势,第一日阴线,
第二日价格振幅较小,第三天阳线,预示底部反转。

语法:

integer = CDLMORNINGSTAR(open, high, low, close, penetration=0)

stock code: 000001.SZ
position Pattern date:
trade_date
2001-02-23 100
2003-02-19 100
在这里插入图片描述

  open   high    low  close  pct_chg
trade_date                                     
2001-02-13  14.41  14.45  14.30  14.30    -0.63
2001-02-14  14.26  14.32  14.20  14.21    -0.63
2001-02-15  14.28  14.35  14.14  14.15    -0.42
2001-02-16  14.16  14.20  14.05  14.19     0.28
2001-02-19  14.18  14.50  14.12  14.49     2.11
2001-02-20  14.45  14.56  14.20  14.27    -1.52
2001-02-21  14.25  14.25  13.95  14.00    -1.89
2001-02-22  13.90  14.00  13.84  13.86    -1.00
2001-02-23  13.80  14.12  13.80  14.12     1.88
2001-02-26  14.15  14.36  14.14  14.21     0.64
2001-02-27  14.25  14.28  14.05  14.10    -0.77
2001-02-28  14.20  14.20  14.05  14.09    -0.07
2001-03-01  14.20  14.50  14.10  14.30     1.49
2001-03-02  14.42  15.28  14.41  15.05     5.24
2001-03-05  15.11  15.41  15.01  15.05     0.00
             open   high    low  close  pct_chg
trade_date                                     
2003-02-10  11.58  11.60  11.25  11.31    -2.75
2003-02-11  11.30  11.39  11.25  11.38     0.62
2003-02-12  11.38  11.45  11.28  11.42     0.35
2003-02-13  11.42  11.60  11.20  11.24    -1.58
2003-02-14  11.25  11.43  11.21  11.33     0.80
2003-02-17  11.34  11.39  11.18  11.21    -1.06
2003-02-18  11.20  11.25  11.10  11.18    -0.27
2003-02-19  11.18  11.32  11.09  11.31     1.16
2003-02-20  11.31  11.38  11.22  11.27    -0.35
2003-02-21  11.25  11.27  10.91  10.92    -3.11
2003-02-24  10.90  10.99  10.83  10.85    -0.64
2003-02-25  10.84  11.13  10.81  11.07     2.03
2003-02-28  11.35  11.39  11.14  11.27     1.81

45.CDLONNECK - On-Neck Pattern

函数名:CDLONNECK
名称:On-Neck Pattern 颈上线
简介:二日K线模式,下跌趋势中,第一日长阴线,第二日开盘价较低,
收盘价与前一日最低价相同,阳线,实体较短,预示着延续下跌趋势。

语法:

integer = CDLONNECK(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2002-01-22 -100
2002-05-27 -100
在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2002-01-14  11.41  11.42  11.00  11.02    -4.34
2002-01-15  10.90  11.15  10.85  10.86    -1.45
2002-01-16  10.90  11.12  10.80  11.00     1.29
2002-01-17  11.00  11.00  10.25  10.31    -6.27
2002-01-18  10.20  10.41  10.00  10.19    -1.16
2002-01-21  10.19  10.20   9.58   9.60    -5.79
2002-01-22   9.51   9.90   9.47   9.60     0.00
2002-01-23   9.60  10.35   9.51  10.34     7.71
2002-01-24  10.20  10.60   9.90  10.36     0.19
2002-01-25  10.36  10.40  10.15  10.21    -1.45
2002-01-28  10.22  10.35   9.60   9.63    -5.68
2002-01-29   9.50   9.87   9.45   9.79     1.66
2002-01-30   9.80   9.90   9.65   9.87     0.82
2002-01-31   9.90  10.65   9.90  10.53     6.69
2002-02-01  10.52  10.78  10.30  10.38    -1.42
             open   high    low  close  pct_chg
trade_date                                     
2002-05-17  11.22  11.37  11.14  11.30     0.80
2002-05-20  11.30  11.33  11.09  11.16    -1.24
2002-05-21  11.30  11.58  11.21  11.44     2.51
2002-05-23  11.31  11.49  11.11  11.19    -2.19
2002-05-24  11.19  11.20  10.91  10.94    -2.23
2002-05-27  10.90  11.05  10.80  10.90    -0.37
2002-05-28  10.99  11.22  10.90  11.10     1.83
2002-05-29  11.17  11.18  10.98  11.02    -0.72
2002-05-30  11.00  11.31  10.93  11.27     2.27
2002-05-31  11.27  11.46  11.15  11.16    -0.98
2002-06-03  11.15  11.29  11.07  11.15    -0.09
2002-06-04  11.20  11.60  11.20  11.41     2.33
2002-06-05  11.41  11.45  11.03  11.05    -3.16
2002-06-06  11.00  11.48  10.92  11.39     3.08

46.CDLPIERCING - Piercing Pattern

函数名:CDLPIERCING
名称:Piercing Pattern 刺透形态
简介:两日K线模式,下跌趋势中,第一日阴线,第二日收盘价低于前一日最低价,
收盘价处在第一日实体上部,预示着底部反转。

语法:

integer = CDLPIERCING(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2002-06-06 100
2005-12-06 100
在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2002-05-27  10.90  11.05  10.80  10.90    -0.37
2002-05-28  10.99  11.22  10.90  11.10     1.83
2002-05-29  11.17  11.18  10.98  11.02    -0.72
2002-05-30  11.00  11.31  10.93  11.27     2.27
2002-05-31  11.27  11.46  11.15  11.16    -0.98
2002-06-03  11.15  11.29  11.07  11.15    -0.09
2002-06-04  11.20  11.60  11.20  11.41     2.33
2002-06-05  11.41  11.45  11.03  11.05    -3.16
2002-06-06  11.00  11.48  10.92  11.39     3.08
2002-06-07  11.40  11.57  11.28  11.43     0.35
2002-06-10  11.42  11.83  11.35  11.54     0.96
2002-06-11  11.54  11.65  11.44  11.50    -0.35
2002-06-12  11.50  11.60  11.34  11.57     0.61
2002-06-13  11.57  11.58  11.35  11.36    -1.82
2002-06-14  11.36  11.36  11.12  11.17    -1.67
            open  high   low  close  pct_chg
trade_date                                  
2005-11-28  5.88  5.88  5.77   5.79    -1.53
2005-11-29  5.75  5.86  5.75   5.78    -0.17
2005-11-30  5.76  5.85  5.74   5.84     1.04
2005-12-01  5.84  5.85  5.77   5.80    -0.68
2005-12-02  5.79  5.85  5.76   5.83     0.52
2005-12-05  5.80  5.80  5.61   5.62    -3.60
2005-12-06  5.60  5.85  5.60   5.76     2.49
2005-12-07  5.76  5.83  5.73   5.81     0.87
2005-12-08  5.80  5.88  5.78   5.81     0.00
2005-12-09  5.81  5.92  5.77   5.88     1.20
2005-12-12  5.90  5.98  5.85   5.90     0.34
2005-12-13  5.88  5.90  5.83   5.90     0.00
2005-12-14  5.90  6.16  5.87   6.07     2.88
2005-12-15  6.08  6.11  5.99   6.00    -1.15
2005-12-16  6.00  6.03  5.96   6.01     0.17

47.CDLRICKSHAWMAN - Rickshaw Man

函数名:CDLRICKSHAWMAN
名称:Rickshaw Man 黄包车夫
简介:一日K线模式,与长腿十字线类似,
若实体正好处于价格振幅中点,称为黄包车夫。

语法:

integer = CDLRICKSHAWMAN(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2000-01-20 100
2000-02-17 100
在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2000-01-10  19.79  20.48  19.77  20.14     3.07
2000-01-11  20.15  20.20  18.80  19.00    -5.66
2000-01-12  19.00  19.20  18.13  18.24    -4.00
2000-01-13  18.20  18.40  17.90  18.14    -0.55
2000-01-14  18.14  18.39  17.75  17.88    -1.43
2000-01-17  17.90  18.10  17.50  18.08     1.12
2000-01-18  18.00  18.08  17.58  17.69    -2.16
2000-01-19  17.50  17.85  17.50  17.79     0.57
2000-01-20  17.80  17.90  17.55  17.81     0.11
2000-01-21  17.80  18.26  17.66  17.96     0.84
2000-01-24  17.91  17.95  17.20  17.50    -2.56
2000-01-25  17.50  18.29  17.50  17.73     1.31
2000-01-26  17.72  17.88  17.50  17.64    -0.51
2000-01-27  17.65  18.17  17.55  17.89     1.42
2000-01-28  18.00  18.58  17.66  18.50     3.41
             open   high    low  close  pct_chg
trade_date                                     
2000-02-14  19.20  20.38  18.70  20.37    10.11
2000-02-15  20.50  21.01  19.10  19.46    -4.47
2000-02-16  19.30  19.30  18.56  18.83    -3.24
2000-02-17  18.83  19.69  18.23  18.80    -0.16
2000-02-18  18.79  18.79  18.15  18.41    -2.07
2000-02-21  18.41  19.50  18.00  18.91     2.72
2000-02-22  19.00  19.25  18.20  18.25    -3.49
2000-02-23  18.20  18.58  18.00  18.10    -0.82
2000-02-24  18.05  18.30  18.00  18.18     0.44
2000-02-25  18.18  18.20  18.00  18.09    -0.50

48.CDLRISEFALL3METHODS - Rising/Falling Three Methods

函数名:CDLRISEFALL3METHODS
名称:Rising/Falling Three Methods 上升/下降三法
简介: 五日K线模式,以上升三法为例,上涨趋势中,
第一日长阳线,中间三日价格在第一日范围内小幅震荡,
第五日长阳线,收盘价高于第一日收盘价,预示股价上升。

语法:

integer = CDLRISEFALL3METHODS(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2022-08-11 100

在这里插入图片描述

 open   high    low  close  pct_chg
trade_date                                     
2022-08-01  12.66  12.66  12.40  12.42  -2.0505
2022-08-02  12.22  12.34  11.94  12.26  -1.2882
2022-08-03  12.19  12.27  12.01  12.03  -1.8760
2022-08-04  12.10  12.17  12.02  12.16   1.0806
2022-08-05  12.13  12.33  11.98  12.31   1.2336
2022-08-08  12.25  12.36  12.16  12.20  -0.8936
2022-08-09  12.21  12.22  12.08  12.12  -0.6557
2022-08-10  12.12  12.24  12.02  12.06  -0.4950
2022-08-11  12.08  12.39  12.04  12.35   2.4046
2022-08-12  12.26  12.41  12.20  12.38   0.2429
2022-08-15  12.29  12.36  12.09  12.11  -2.1809
2022-08-16  12.11  12.20  12.10  12.13   0.1652
2022-08-17  12.15  12.42  12.07  12.40   2.2259
2022-08-18  12.48  12.54  12.16  12.25  -1.2097
2022-08-19  12.27  12.75  12.23  12.57   2.6122

49.CDLSEPARATINGLINES - Separating Lines

函数名:CDLSEPARATINGLINES
名称:Separating Lines 分离线
简介:二日K线模式,上涨趋势中,第一日阴线,第二日阳线,
第二日开盘价与第一日相同且为最低价,预示着趋势继续。

语法:

integer = CDLSEPARATINGLINES(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2000-04-14 100
2000-05-15 -100
在这里插入图片描述

 open   high    low  close  pct_chg
trade_date                                     
2000-04-04  18.28  18.34  18.05  18.11    -0.93
2000-04-05  18.10  18.67  18.05  18.35     1.33
2000-04-06  18.40  18.50  18.25  18.48     0.71
2000-04-07  18.58  19.20  18.41  18.91     2.33
2000-04-10  19.01  19.30  18.70  18.82    -0.48
2000-04-11  18.85  19.30  18.70  18.90     0.43
2000-04-12  19.00  19.50  18.90  19.12     1.16
2000-04-13  19.15  19.25  18.90  19.13     0.05
2000-04-14  19.15  20.00  19.15  19.49     1.88
2000-04-17  19.52  20.02  18.95  19.18    -1.59
2000-04-18  19.24  19.45  18.97  19.10    -0.42
2000-04-19  19.51  19.68  19.10  19.15     0.26
2000-04-20  19.18  19.33  18.90  19.02    -0.68
2000-04-21  19.02  19.10  18.78  18.81    -1.10
2000-04-24  18.81  18.94  18.50  18.57    -1.28
             open   high    low  close  pct_chg
trade_date                                     
2000-05-08  19.12  19.18  18.74  18.80    -1.36
2000-05-09  18.80  18.90  18.20  18.37    -2.29
2000-05-10  18.33  18.40  18.03  18.14    -1.25
2000-05-11  18.11  18.39  17.95  17.99    -0.83
2000-05-12  18.00  18.17  17.82  18.02     0.17
2000-05-15  18.01  18.05  17.48  17.50    -2.89
2000-05-16  17.50  17.84  17.50  17.74     1.37
2000-05-17  17.73  17.94  17.50  17.65    -0.51
2000-05-18  17.65  17.85  17.50  17.83     1.02
2000-05-19  17.88  18.20  17.80  17.93     0.56
2000-05-22  17.95  18.29  17.91  18.08     0.84
2000-05-23  18.08  18.20  17.68  18.16     0.44
2000-05-24  18.16  18.25  17.96  18.07    -0.50
2000-05-25  18.10  18.99  18.10  18.65     3.21

50.CDLSHOOTINGSTAR - Shooting Star

函数名:CDLSHOOTINGSTAR
名称:Shooting Star 射击之星
简介:一日K线模式,上影线至少为实体长度两倍,
没有下影线,预示着股价下跌

语法:

integer = CDLSHOOTINGSTAR(open, high, low, close)

stock code: 000001.SZ
position Pattern date:
trade_date
2000-05-22 -100
2000-06-08 -100

在这里插入图片描述

open   high    low  close  pct_chg
trade_date                                     
2000-05-12  18.00  18.17  17.82  18.02     0.17
2000-05-15  18.01  18.05  17.48  17.50    -2.89
2000-05-16  17.50  17.84  17.50  17.74     1.37
2000-05-17  17.73  17.94  17.50  17.65    -0.51
2000-05-18  17.65  17.85  17.50  17.83     1.02
2000-05-19  17.88  18.20  17.80  17.93     0.56
2000-05-22  17.95  18.29  17.91  18.08     0.84
2000-05-23  18.08  18.20  17.68  18.16     0.44
2000-05-24  18.16  18.25  17.96  18.07    -0.50
2000-05-25  18.10  18.99  18.10  18.65     3.21
2000-05-26  18.80  18.89  18.30  18.32    -1.77
2000-05-29  18.32  18.50  18.00  18.27    -0.27
2000-05-30  18.37  18.47  18.00  18.05    -1.20
2000-05-31  18.04  18.25  17.90  18.00    -0.28
2000-06-01  18.01  18.30  17.95  18.06     0.33
             open   high    low  close  pct_chg
trade_date                                     
2000-05-29  18.32  18.50  18.00  18.27    -0.27
2000-05-30  18.37  18.47  18.00  18.05    -1.20
2000-05-31  18.04  18.25  17.90  18.00    -0.28
2000-06-01  18.01  18.30  17.95  18.06     0.33
2000-06-02  18.06  18.50  18.00  18.20     0.78
2000-06-05  18.20  18.45  18.05  18.10    -0.55
2000-06-06  18.15  18.32  18.00  18.26     0.88
2000-06-07  18.30  18.65  18.26  18.50     1.31
2000-06-08  18.60  19.23  18.60  18.70     1.08
2000-06-09  18.89  18.96  18.28  18.35    -1.87
2000-06-12  18.30  18.60  18.18  18.48     0.71
2000-06-13  18.51  18.70  18.40  18.59     0.60
2000-06-14  18.70  19.00  18.59  18.68     0.48
2000-06-15  18.69  19.09  18.50  18.79     0.59
2000-06-16  18.79  18.97  18.38  18.49    -1.60

文章来源:https://blog.csdn.net/qq_39065491/article/details/134822178
本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。