TA-Lib学习研究笔记(九)——Pattern Recognition (4)
最全面的形态识别的函数的应用,通过使用A股实际的数据,验证形态识别函数,用K线显示出现标志的形态走势,由于入口参数基本上是open, high, low, close ,统一设置程序代码,只更换函数即可。
发现有的形态在一个股票上从未出现,选择多个股票参与计算测试。
函数返回值integer (values are -100, 0 or 100) ,0 是无形态信号。100 和 -100 是有正向或负向的形态信号。
31.CDLHOMINGPIGEON - Homing Pigeon
函数名:CDLHOMINGPIGEON
名称:Homing Pigeon 家鸽
简介:二日K线模式,与母子线类似,不同的的是二日K线颜色相同,
第二日最高价、最低价都在第一日实体之内,预示着趋势反转。
语法:
integer = CDLHOMINGPIGEON(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-09-29 100
2000-12-14 100
open high low close pct_chg
trade_date
2000-09-19 16.80 16.80 16.38 16.40 -2.50
2000-09-20 16.38 16.67 16.10 16.52 0.73
2000-09-21 16.58 16.80 16.27 16.46 -0.36
2000-09-22 16.46 16.58 16.21 16.26 -1.22
2000-09-25 16.32 16.60 16.32 16.42 0.98
2000-09-26 16.45 16.79 16.45 16.60 1.10
2000-09-27 16.65 17.25 16.65 17.07 2.83
2000-09-28 17.10 17.26 16.86 16.89 -1.05
2000-09-29 16.98 17.08 16.90 16.96 0.41
2000-10-09 17.00 17.18 16.66 16.75 -1.24
open high low close pct_chg
trade_date
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
2000-12-15 15.04 15.36 14.96 15.26 2.01
2000-12-18 15.26 15.35 14.90 15.27 0.07
2000-12-19 15.30 15.30 14.88 14.95 -2.10
2000-12-20 14.98 15.00 14.80 14.86 -0.60
2000-12-21 14.87 14.99 14.82 14.82 -0.27
2000-12-22 14.82 14.85 14.60 14.65 -1.15
32.CDLIDENTICAL3CROWS - Identical Three Crows
函数名:CDLIDENTICAL3CROWS
名称:Identical Three Crows 三胞胎乌鸦
简介:三日K线模式,上涨趋势中,三日都为阴线,长度大致相等,
每日开盘价等于前一日收盘价,收盘价接近当日最低价,预示价格下跌。
语法:
integer = CDLIDENTICAL3CROWS(open, high, low, close)
stock code: 000001.SZ
stock code: 000002.SZ
position Pattern date:
trade_date
2020-12-08 -100
open high low close pct_chg
trade_date
2020-11-30 31.70 32.73 30.70 30.70 -2.8788
2020-12-01 30.81 30.96 30.14 30.75 0.1629
2020-12-02 30.89 31.96 30.71 31.13 1.2358
2020-12-03 31.37 31.43 30.55 30.90 -0.7388
2020-12-04 31.12 31.14 29.94 30.00 -2.9126
2020-12-07 30.05 30.18 29.36 29.41 -1.9667
2020-12-08 29.45 29.59 29.12 29.18 -0.7820
2020-12-09 29.40 29.44 28.66 28.66 -1.7820
2020-12-10 28.81 28.96 28.41 28.58 -0.2791
2020-12-11 28.70 28.72 28.20 28.46 -0.4199
2020-12-14 28.60 28.99 28.39 28.92 1.6163
2020-12-15 28.76 28.79 28.29 28.55 -1.2794
2020-12-16 28.65 28.75 28.24 28.60 0.1751
2020-12-17 28.61 28.93 28.30 28.84 0.8392
2020-12-18 28.84 28.85 28.35 28.50 -1.1789
33.CDLINNECK - In-Neck Pattern
函数名:CDLINNECK
名称:In-Neck Pattern 颈内线
简介:二日K线模式,下跌趋势中,第一日长阴线,
第二日开盘价较低,收盘价略高于第一日收盘价,阳线,实体较短,预示着下跌继续。
语法:
integer = CDLINNECK(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2002-01-22 -100
2002-08-13 -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-08-05 15.19 15.19 14.83 14.85 -2.17
2002-08-06 14.84 15.24 14.77 14.99 0.94
2002-08-07 15.01 15.01 14.78 14.98 -0.07
2002-08-08 14.98 15.08 14.85 14.92 -0.40
2002-08-09 14.90 15.02 14.80 14.85 -0.47
2002-08-12 14.80 14.88 14.65 14.66 -1.28
2002-08-13 14.60 14.80 14.60 14.67 0.07
2002-08-14 14.71 14.85 14.70 14.85 1.23
2002-08-15 14.87 14.89 14.76 14.84 -0.07
2002-08-16 14.79 14.88 14.51 14.76 -0.54
2002-08-19 14.75 15.18 14.66 15.03 1.83
2002-08-20 15.07 15.69 15.03 15.68 4.32
2002-08-21 15.69 15.80 15.40 15.50 -1.15
2002-08-22 15.50 15.69 15.37 15.49 -0.06
2002-08-23 15.51 15.70 15.48 15.53 0.26
34.CDLINVERTEDHAMMER - Inverted Hammer
函数名:CDLINVERTEDHAMMER
名称:Inverted Hammer 倒锤头
简介:一日K线模式,上影线较长,长度为实体2倍以上,
无下影线,在下跌趋势底部,预示着趋势反转。
语法:
integer = CDLINVERTEDHAMMER(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-23 100
2000-05-11 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.09
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
35.CDLKICKING - Kicking
函数名:CDLKICKING
名称:Kicking 反冲形态
简介:二日K线模式,与分离线类似,两日K线为秃线,颜色相反,存在跳空缺口。
语法:
integer = CDLKICKING(open, high, low, close)
stock code: 000006.SZ
position Pattern date:
trade_date
2016-09-12 100
open high low close pct_chg
trade_date
2016-09-02 8.14 8.26 8.02 8.10 -0.98
2016-09-05 8.14 8.33 8.10 8.25 1.85
2016-09-06 8.20 8.28 8.09 8.23 -0.24
2016-09-07 8.23 8.30 8.20 8.23 0.00
2016-09-08 8.18 8.28 8.12 8.23 0.00
2016-09-09 8.23 8.24 8.10 8.11 -1.46
2016-09-12 8.35 8.92 8.35 8.92 9.99
2016-09-13 9.25 9.81 9.20 9.56 7.17
2016-09-14 9.37 9.58 8.94 8.94 -6.49
2016-09-19 9.03 9.16 8.83 9.07 1.45
2016-09-20 9.01 9.29 8.89 9.28 2.32
2016-09-21 9.14 9.15 8.97 8.98 -3.23
2016-09-22 9.08 9.23 9.01 9.02 0.45
36.CDLKICKINGBYLENGTH - Kicking - bull/bear determined by the longer marubozu
函数名:CDLKICKINGBYLENGTH
名称:Kicking - bull/bear determined by the longer marubozu 由较长缺影线决定的反冲形态
简介:二日K线模式,与反冲形态类似,较长缺影线决定价格的涨跌。
语法:
integer = CDLKICKINGBYLENGTH(open, high, low, close)
stock code: 000006.SZ
position Pattern date:
trade_date
2016-09-12 100
open high low close pct_chg
trade_date
2016-09-02 8.14 8.26 8.02 8.10 -0.98
2016-09-05 8.14 8.33 8.10 8.25 1.85
2016-09-06 8.20 8.28 8.09 8.23 -0.24
2016-09-07 8.23 8.30 8.20 8.23 0.00
2016-09-08 8.18 8.28 8.12 8.23 0.00
2016-09-09 8.23 8.24 8.10 8.11 -1.46
2016-09-12 8.35 8.92 8.35 8.92 9.99
2016-09-13 9.25 9.81 9.20 9.56 7.17
2016-09-14 9.37 9.58 8.94 8.94 -6.49
2016-09-19 9.03 9.16 8.83 9.07 1.45
2016-09-20 9.01 9.29 8.89 9.28 2.32
2016-09-21 9.14 9.15 8.97 8.98 -3.23
2016-09-22 9.08 9.23 9.01 9.02 0.45
37.CDLLADDERBOTTOM - Ladder Bottom
函数名:CDLLADDERBOTTOM
名称:Ladder Bottom 梯底
简介:五日K线模式,下跌趋势中,前三日阴线,
开盘价与收盘价皆低于前一日开盘、收盘价,第四日倒锤头,第五日开盘价高于前一日开盘价,
阳线,收盘价高于前几日价格振幅,预示着底部反转。
语法:
integer = CDLLADDERBOTTOM(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-07-19 100
2001-07-27 100
open high low close pct_chg
trade_date
2000-07-10 18.00 18.10 17.70 17.71 -1.28
2000-07-11 17.74 18.16 17.73 18.03 1.81
2000-07-12 18.03 18.55 17.98 18.21 1.00
2000-07-13 18.21 18.40 17.95 18.00 -1.15
2000-07-14 18.00 18.08 17.85 17.96 -0.22
2000-07-17 17.98 18.00 17.75 17.82 -0.78
2000-07-18 17.85 18.00 17.78 17.84 0.11
2000-07-19 17.95 18.29 17.84 18.04 1.12
2000-07-20 18.08 18.15 17.80 17.90 -0.78
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
open high low close pct_chg
trade_date
2001-07-17 14.95 14.96 14.65 14.80 -1.00
2001-07-18 14.85 16.00 14.85 15.16 2.43
2001-07-19 15.16 15.20 14.88 15.12 -0.26
2001-07-20 15.20 15.38 15.05 15.20 0.53
2001-07-23 15.25 15.36 15.08 15.11 -0.59
2001-07-24 15.08 15.08 14.93 14.99 -0.79
2001-07-25 14.98 15.02 14.75 14.79 -1.33
2001-07-26 14.79 14.85 14.61 14.77 -0.14
2001-07-27 14.85 15.02 14.62 14.99 1.49
2001-07-30 14.90 14.90 13.60 14.00 -6.60
2001-07-31 13.81 14.20 13.75 13.83 -1.21
2001-08-01 13.85 14.22 13.85 14.21 2.75
2001-08-02 14.21 14.22 13.78 13.95 -1.83
2001-08-03 13.95 13.99 13.65 13.81 -1.00
2001-08-06 13.75 13.78 12.60 13.05 -5.50
38.CDLLONGLEGGEDDOJI - Long Legged Doji
函数名:CDLLONGLEGGEDDOJI
名称:Long Legged Doji 长脚十字
简介:一日K线模式,开盘价与收盘价相同居当日价格中部,上下影线长,
表达市场不确定性。
语法:
integer = CDLLONGLEGGEDDOJI(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
39.CDLLONGLINE - Long Line Candle
函数名:CDLLONGLINE
名称:Long Line Candle 长蜡烛
简介:一日K线模式,K线实体长,无上下影线。
语法:
integer = CDLLONGLINE(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-22 -100
2000-03-02 -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.09
open high low close pct_chg
trade_date
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
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
40.CDLMARUBOZU - Marubozu
函数名:CDLMARUBOZU
名称:Marubozu 光头光脚/缺影线
简介:一日K线模式,上下两头都没有影线的实体,
阴线预示着熊市持续或者牛市反转,阳线相反。
语法:
integer = CDLMARUBOZU(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-03-10 -100
2000-05-08 -100
open high low close pct_chg
trade_date
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.47
2000-03-14 18.89 18.98 18.30 18.59 -2.82
2000-03-15 18.50 18.90 18.30 18.44 -0.81
2000-03-16 18.36 18.36 17.83 17.92 -2.82
2000-03-17 17.80 18.32 17.78 18.17 1.40
2000-03-20 17.90 18.37 17.68 18.22 0.28
open high low close pct_chg
trade_date
2000-04-28 18.74 19.20 18.65 19.06 1.60
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