TA-Lib学习研究笔记(九)——Pattern Recognition (3)
最全面的形态识别的函数的应用,通过使用A股实际的数据,验证形态识别函数,用K线显示出现标志的形态走势,由于入口参数基本上是open, high, low, close ,统一设置程序代码,只更换函数即可。
发现有的形态在一个股票上从未出现,选择多个股票参与计算测试。
函数返回值integer (values are -100, 0 or 100) ,0 是无形态信号。100 和 -100 是有正向或负向的形态信号。
21.CDLEVENINGSTAR - Evening Star
函数名:CDLEVENINGSTAR
名称:Evening Star 暮星
简介:三日K线模式,与晨星相反,上升趋势中,
第一日阳线,第二日价格振幅较小,第三日阴线,预示顶部反转。
语法:
integer = CDLEVENINGSTAR(open, high, low, close, penetration=0)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-06-09 -100
2001-01-03 -100
open high low close pct_chg
trade_date
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
2000-06-19 18.50 18.54 18.20 18.28 -1.14open high low close pct_chg
trade_date
2000-12-25 14.65 14.65 14.35 14.39 -1.77
2000-12-26 14.40 14.62 14.30 14.40 0.07
2000-12-27 14.40 14.50 14.36 14.38 -0.14
2000-12-28 14.40 14.42 14.32 14.36 -0.14
2000-12-29 14.36 14.62 14.35 14.52 1.11
2001-01-02 14.54 14.70 14.40 14.55 0.21
2001-01-03 14.56 14.61 14.37 14.44 -0.76
2001-01-04 14.45 14.50 14.30 14.35 -0.62
2001-01-05 14.33 14.33 14.12 14.20 -1.05
2001-01-08 14.20 14.20 13.98 14.00 -1.41
2001-01-09 14.00 14.58 13.85 14.55 3.93
2001-01-10 14.56 14.59 14.31 14.42 -0.89
2001-01-11 14.45 15.20 14.44 14.79 2.57
2001-01-12 14.79 14.95 14.66 14.80 0.07
22.CDLGAPSIDESIDEWHITE - Up/Down-gap side-by-side white lines
函数名:CDLGAPSIDESIDEWHITE
名称:Up/Down-gap side-by-side white lines 向上/下跳空并列阳线
简介:二日K线模式,上升趋势向上跳空,下跌趋势向下跳空,
第一日与第二日有相同开盘价,实体长度差不多,则趋势持续。
语法:
integer = CDLGAPSIDESIDEWHITE(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2006-06-14 -100
2013-02-06 -100
open high low close pct_chg
trade_date
2006-06-12 7.90 7.90 7.90 7.90 -10.02
2006-06-13 7.11 7.30 7.11 7.11 -10.00
2006-06-14 7.10 7.18 6.85 7.13 0.28
2006-06-16 7.21 7.27 7.07 7.11 -0.28
2006-06-19 7.05 7.15 6.80 7.07 -0.56
2006-06-20 7.06 7.16 6.97 7.12 0.71
2006-06-21 7.12 7.21 7.08 7.18 0.84
2006-06-22 7.18 7.48 7.15 7.40 3.06
2006-06-23 7.37 7.37 7.24 7.29 -1.49open high low close pct_chg
trade_date
2013-01-28 19.16 21.07 19.16 21.07 10.03
2013-01-29 21.30 21.55 20.63 21.38 1.47
2013-01-30 21.10 21.34 20.80 21.33 -0.23
2013-01-31 21.27 21.34 20.80 21.10 -1.08
2013-02-01 21.02 22.55 20.79 22.43 6.30
2013-02-04 22.26 22.79 21.71 22.01 -1.87
2013-02-05 21.74 22.16 21.19 21.78 -1.05
2013-02-06 21.70 21.98 21.45 21.86 0.37
2013-02-07 21.70 21.81 20.31 20.85 -4.62
2013-02-08 20.78 21.05 20.39 20.75 -0.48
23.CDLGRAVESTONEDOJI - Gravestone Doji
函数名:CDLGRAVESTONEDOJI
名称:Gravestone Doji 墓碑十字/倒T十字
简介:一日K线模式,开盘价与收盘价相同,上影线长,无下影线,预示底部反转。
语法:
integer = CDLGRAVESTONEDOJI(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-23 100
2000-06-28 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
2000-02-28 18.10 18.78 17.80 18.56 2.60
2000-02-29 18.60 18.99 18.05 18.32 -1.29
2000-03-01 18.40 19.50 18.15 18.81 2.67
2000-03-02 18.70 18.76 18.20 18.38 -2.29
2000-03-03 18.41 18.90 18.37 18.58 1.09open high low close pct_chg
trade_date
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
2000-07-07 17.75 18.05 17.70 17.94 1.24
24.CDLHAMMER - Hammer
函数名:CDLHAMMER
名称:Hammer 锤头
简介:一日K线模式,实体较短,无上影线,
下影线大于实体长度两倍,处于下跌趋势底部,预示反转。
语法:
integer = CDLHAMMER(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-11-20 100
2000-12-04 100
open high low close pct_chg
trade_date
2000-11-10 15.50 15.71 15.40 15.54 0.32
2000-11-13 15.52 15.80 15.50 15.67 0.84
2000-11-14 15.73 15.85 15.60 15.76 0.57
2000-11-15 15.78 16.19 15.77 15.98 1.40
2000-11-16 16.00 16.15 15.90 15.97 -0.06
2000-11-17 16.00 16.03 15.65 15.71 -1.63
2000-11-20 15.71 15.71 15.51 15.64 -0.45
2000-11-21 15.65 15.84 15.52 15.64 0.00
2000-11-22 15.64 15.85 15.64 15.79 0.96
2000-11-23 15.80 16.00 15.76 15.88 0.57
2000-11-24 15.95 16.36 15.70 15.83 -0.31
2000-11-27 15.80 15.80 15.60 15.63 -1.26
2000-11-28 15.63 15.75 15.60 15.67 0.26
2000-11-29 15.67 15.68 15.48 15.52 -0.96
2000-11-30 15.51 15.65 15.46 15.49 -0.19open high low close pct_chg
trade_date
2000-11-24 15.95 16.36 15.70 15.83 -0.31
2000-11-27 15.80 15.80 15.60 15.63 -1.26
2000-11-28 15.63 15.75 15.60 15.67 0.26
2000-11-29 15.67 15.68 15.48 15.52 -0.96
2000-11-30 15.51 15.65 15.46 15.49 -0.19
2000-12-01 15.50 15.60 15.44 15.49 0.00
2000-12-04 15.50 15.52 15.40 15.49 0.00
2000-12-05 15.50 15.64 15.50 15.51 0.13
2000-12-06 15.52 15.58 15.35 15.38 -0.84
2000-12-07 15.38 15.40 15.25 15.30 -0.52
2000-12-08 15.15 15.30 15.10 15.18 -0.78
2000-12-11 15.18 15.20 14.75 14.79 -2.57
2000-12-12 14.79 15.00 14.65 14.99 1.35
2000-12-13 15.00 15.11 14.81 14.84 -1.00
2000-12-14 14.99 15.16 14.84 14.96 0.81
25.CDLHANGINGMAN - Hanging Man
函数名:CDLHANGINGMAN
名称:Hanging Man 上吊线
简介:一日K线模式,形状与锤子类似,处于上升趋势的顶部,预示着趋势反转。
语法:
integer = CDLHANGINGMAN(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2001-10-23 -100
2001-11-21 -100
open high low close pct_chg
trade_date
2001-10-15 12.61 13.08 12.40 12.96 2.69
2001-10-16 12.96 13.00 12.65 12.81 -1.16
2001-10-17 12.80 13.38 12.72 13.03 1.72
2001-10-18 13.08 13.39 13.00 13.09 0.46
2001-10-19 13.05 13.06 12.35 12.72 -2.83
2001-10-22 12.68 13.09 12.58 12.81 0.71
2001-10-23 14.09 14.09 13.50 14.09 9.99
2001-10-24 14.33 14.50 13.81 14.11 0.14
2001-10-25 14.00 14.09 13.75 13.78 -2.34
2001-10-26 13.78 14.00 13.66 13.90 0.87
2001-10-29 13.92 14.10 13.80 13.89 -0.07
2001-10-30 13.89 13.90 13.58 13.62 -1.94
2001-10-31 13.60 13.82 13.50 13.81 1.40
2001-11-01 13.81 14.00 13.73 13.78 -0.22
2001-11-02 13.85 13.85 13.57 13.60 -1.31open high low close pct_chg
trade_date
2001-11-12 13.34 13.39 13.15 13.27 -0.38
2001-11-13 13.25 13.48 13.18 13.29 0.15
2001-11-14 13.27 13.35 13.18 13.19 -0.75
2001-11-15 13.18 13.27 13.00 13.09 -0.76
2001-11-16 13.88 14.20 13.20 13.25 1.22
2001-11-19 13.38 13.38 13.15 13.26 0.08
2001-11-20 13.35 13.57 13.25 13.49 1.73
2001-11-21 13.55 13.70 13.39 13.69 1.48
2001-11-22 13.69 13.80 13.60 13.70 0.07
2001-11-23 13.70 13.71 13.50 13.54 -1.17
2001-11-26 13.50 13.50 13.37 13.39 -1.11
2001-11-27 13.39 13.48 13.35 13.43 0.30
2001-11-28 13.48 13.75 13.44 13.50 0.52
2001-11-29 13.50 13.55 13.35 13.39 -0.81
2001-11-30 13.35 13.50 13.30 13.42 0.22
26.CDLHARAMI - Harami Pattern
函数名:CDLHARAMI
名称:Harami Pattern 母子线
简介:二日K线模式,分多头母子与空头母子,两者相反,以多头母子为例,在下跌趋势中,第一日K线长阴,
第二日开盘价收盘价在第一日价格振幅之内,为阳线,预示趋势反转,股价上升。
语法:
integer = CDLHARAMI(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-03-03 100
2000-04-25 100
open high low close pct_chg
trade_date
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
2000-02-28 18.10 18.78 17.80 18.56 2.60
2000-02-29 18.60 18.99 18.05 18.32 -1.29
2000-03-01 18.40 19.50 18.15 18.81 2.67
2000-03-02 18.70 18.76 18.20 18.38 -2.29
2000-03-03 18.41 18.90 18.37 18.58 1.09
2000-03-06 18.80 19.40 18.20 18.24 -1.83
2000-03-07 18.00 19.30 18.00 19.03 4.33
2000-03-08 19.07 19.19 18.51 18.73 -1.58
2000-03-09 18.77 20.59 18.46 20.08 7.21
2000-03-10 19.98 19.98 18.99 19.04 -5.18
2000-03-13 19.00 19.60 18.90 19.13 0.47open high low close pct_chg
trade_date
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
2000-04-25 18.58 18.92 18.57 18.69 0.65
2000-04-26 18.80 19.80 18.65 19.13 2.35
2000-04-27 19.30 19.40 18.71 18.76 -1.93
2000-04-28 18.74 19.20 18.65 19.06 1.60
27.CDLHARAMICROSS - Harami Cross Pattern
函数名:CDLHARAMICROSS
名称:Harami Cross Pattern 十字孕线
简介:二日K线模式,与母子县类似,若第二日K线是十字线,
便称为十字孕线,预示着趋势反转。
语法:
integer = CDLHARAMICROSS(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-07-31 100
2000-08-16 100
open high low close pct_chg
trade_date
2000-07-21 17.90 18.05 17.78 17.84 -0.34
2000-07-24 17.83 17.83 17.69 17.72 -0.67
2000-07-25 17.75 17.88 17.69 17.78 0.34
2000-07-26 17.58 17.97 17.58 17.70 -0.45
2000-07-27 17.88 19.47 17.85 18.98 7.23
2000-07-28 18.80 18.97 18.45 18.47 -2.69
2000-07-31 18.51 18.87 18.45 18.51 0.22
2000-08-01 18.55 18.85 18.53 18.57 0.32
2000-08-02 18.62 18.77 18.20 18.26 -1.67
2000-08-03 18.30 18.56 18.11 18.24 -0.11
2000-08-04 18.25 18.43 17.98 18.25 0.05
2000-08-07 18.31 18.60 18.20 18.30 0.27
2000-08-08 18.35 18.40 18.10 18.21 -0.49
2000-08-09 18.20 18.58 18.15 18.35 0.77
2000-08-10 18.35 18.43 18.20 18.22 -0.71open high low close pct_chg
trade_date
2000-08-07 18.31 18.60 18.20 18.30 0.27
2000-08-08 18.35 18.40 18.10 18.21 -0.49
2000-08-09 18.20 18.58 18.15 18.35 0.77
2000-08-10 18.35 18.43 18.20 18.22 -0.71
2000-08-11 18.23 18.45 18.20 18.29 0.38
2000-08-14 18.35 18.85 18.32 18.51 1.20
2000-08-15 18.50 18.59 18.28 18.30 -1.13
2000-08-16 18.40 18.59 18.24 18.42 0.66
2000-08-17 18.42 18.95 18.40 18.58 0.87
2000-08-18 18.60 18.70 18.45 18.48 -0.54
2000-08-21 18.50 18.70 18.38 18.40 -0.43
2000-08-22 18.40 18.50 18.10 18.16 -1.30
2000-08-23 18.10 18.30 17.71 18.09 -0.39
2000-08-24 18.08 18.39 17.95 18.10 0.06
2000-08-25 18.15 18.20 18.00 18.10 0.00
28.CDLHIGHWAVE - High-Wave Candle
函数名:CDLHIGHWAVE
名称:High-Wave Candle 风高浪大线
简介:三日K线模式,具有极长的上/下影线与短的实体,预示着趋势反转。
语法:
integer = CDLHIGHWAVE(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.41open 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
29.CDLHIKKAKE - Hikkake Pattern
函数名:CDLHIKKAKE
名称:Hikkake Pattern 陷阱
简介:三日K线模式,与母子类似,第二日价格在前一日实体范围内,
第三日收盘价高于前两日,反转失败,趋势继续。
语法:
integer = CDLHIKKAKE(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-01-19 100
2000-02-23 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.41open 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
2000-02-28 18.10 18.78 17.80 18.56 2.60
2000-02-29 18.60 18.99 18.05 18.32 -1.29
2000-03-01 18.40 19.50 18.15 18.81 2.67
2000-03-02 18.70 18.76 18.20 18.38 -2.29
2000-03-03 18.41 18.90 18.37 18.58 1.09
30.CDLHIKKAKEMOD - Modified Hikkake Pattern
函数名:CDLHIKKAKEMOD
名称:Modified Hikkake Pattern 修正陷阱
简介:三日K线模式,与陷阱类似,上升趋势中,第三日跳空高开;
下跌趋势中,第三日跳空低开,反转失败,趋势继续。
语法:
integer = CDLHIKKAKEMOD(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2019-06-25 100
2021-08-25 100
open high low close pct_chg
trade_date
2019-06-17 12.48 12.79 12.48 12.67 1.4412
2019-06-18 12.67 12.85 12.59 12.80 1.0260
2019-06-19 13.29 13.39 13.01 13.07 2.1094
2019-06-20 13.17 13.95 13.12 13.80 5.5853
2019-06-21 13.76 13.87 13.58 13.64 -1.1594
2019-06-24 13.69 13.83 13.61 13.69 0.3666
2019-06-25 13.72 13.72 13.07 13.43 -1.8992
2019-06-26 13.27 13.50 13.19 13.37 0.6020
2019-06-27 13.50 13.85 13.45 13.71 2.5430
2019-06-28 13.73 13.79 13.58 13.78 0.5106
2019-07-01 14.01 14.18 13.87 13.93 1.0885
2019-07-02 13.88 14.24 13.86 14.18 1.7947
2019-07-03 14.18 14.21 13.87 14.01 -1.1989
2019-07-04 14.01 14.28 13.88 13.99 -0.1428
2019-07-05 13.95 13.98 13.69 13.92 -0.5004open high low close pct_chg
trade_date
2021-08-16 20.09 20.20 19.57 19.95 0.3017
2021-08-17 19.85 20.22 19.61 19.67 -1.4035
2021-08-18 19.67 21.20 19.55 20.62 4.8297
2021-08-19 20.48 20.62 20.02 20.34 -1.3579
2021-08-20 19.97 20.07 18.70 19.42 -4.5231
2021-08-23 19.50 20.05 19.11 19.30 -0.6179
2021-08-24 19.35 19.97 19.21 19.36 0.3109
2021-08-25 19.42 19.47 18.95 19.16 -1.0331
2021-08-26 19.20 19.26 18.41 18.46 -3.6534
2021-08-27 18.56 18.88 18.31 18.39 -0.3792
2021-08-30 18.21 18.29 17.55 17.72 -3.6433
2021-08-31 17.72 17.93 17.31 17.80 0.4515
2021-09-01 17.48 17.92 17.01 17.88 0.4494
2021-09-02 18.00 18.78 17.80 18.40 2.9083
2021-09-03 18.50 18.50 17.70 18.04 -1.9565