TA-Lib学习研究笔记(九)——Pattern Recognition (2)
形态识别的函数的应用,通过使用A股实际的数据,验证形态识别函数,用K线显示出现标志的形态走势,由于入口参数基本上是open, high, low, close ,统一设置程序代码,只更换函数即可。
发现有的形态在一个股票上从未出现,选择多个股票参与计算测试。
函数返回值integer (values are -100, 0 or 100) ,0 是无形态信号。100 和 -100 是有正向或负向的形态信号。
11.CDLBREAKAWAY - Breakaway
函数名:CDLBREAKAWAY
名称:Breakaway 脱离
简介:五日K线模式,以看涨脱离为例,下跌趋势中,第一日长阴线,第二日跳空阴线,延续趋势开始震荡,
第五日长阳线,收盘价在第一天收盘价与第二天开盘价之间,预示价格上涨。
语法:
integer = CDLBREAKAWAY(open, high, low, close)
stock code: 000004.SZ
position Pattern date:
trade_date
2022-11-11 -100
open high low close pct_chg
trade_date
2022-11-01 8.68 8.89 8.68 8.81 0.8009
2022-11-02 8.81 8.97 8.81 8.85 0.4540
2022-11-03 8.75 8.83 8.70 8.76 -1.0169
2022-11-04 8.75 8.92 8.72 8.86 1.1416
2022-11-07 8.91 9.30 8.91 9.30 4.9661
2022-11-08 9.52 9.68 9.26 9.65 3.7634
2022-11-09 9.55 9.74 9.41 9.52 -1.3472
2022-11-10 9.45 9.93 9.42 9.61 0.9454
2022-11-11 9.77 9.87 9.38 9.38 -2.3933
2022-11-14 9.31 9.56 9.31 9.54 1.7058
2022-11-15 9.54 9.66 9.44 9.55 0.1048
2022-11-16 9.55 9.75 9.50 9.63 0.8377
2022-11-17 9.65 10.11 9.60 9.98 3.6345
2022-11-18 9.92 10.48 9.88 10.48 5.0100
2022-11-21 10.67 11.00 10.52 11.00 4.9618
12.CDLCLOSINGMARUBOZU - Closing Marubozu
函数名:CDLCLOSINGMARUBOZU
名称:Closing Marubozu 收盘缺影线
简介:一日K线模式,以阳线为例,最低价低于开盘价,收盘价等于最高价,
预示着趋势持续。
语法:
integer = CDLCLOSINGMARUBOZU(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-14 100
2000-02-22 -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.44open 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
stock code: 000002.SZ
13.CDLCONCEALBABYSWALL - Concealing Baby Swallow
函数名:CDLCONCEALBABYSWALL
名称: Concealing Baby Swallow 藏婴吞没
简介:四日K线模式,下跌趋势中,前两日阴线无影线
,第二日开盘、收盘价皆低于第二日,第三日倒锤头,
第四日开盘价高于前一日最高价,收盘价低于前一日最低价,预示着底部反转。
语法:
integer = CDLCONCEALBABYSWALL(open, high, low, close)
stock code: 000021.SZ
position Pattern date:
trade_date
2019-10-18 100
open high low close pct_chg
trade_date
2019-10-08 11.29 11.37 10.93 10.97 -1.4376
2019-10-09 10.96 11.34 10.71 11.24 2.4613
2019-10-10 11.28 11.45 11.15 11.34 0.8897
2019-10-11 11.30 11.31 10.91 11.09 -2.2046
2019-10-14 11.26 11.65 11.11 11.48 3.5167
2019-10-15 11.40 11.41 10.95 11.01 -4.0941
2019-10-16 11.06 11.09 10.84 10.87 -1.2716
2019-10-17 10.84 10.95 10.70 10.82 -0.4600
2019-10-18 10.73 11.07 10.40 10.41 -3.7893
2019-10-21 10.50 10.61 10.05 10.55 1.3449
2019-10-22 10.49 10.68 10.49 10.64 0.8531
2019-10-23 10.59 10.76 10.41 10.49 -1.4098
2019-10-24 10.50 10.52 10.24 10.39 -0.9533
2019-10-25 10.41 10.75 10.29 10.67 2.6949
2019-10-28 11.60 11.74 11.26 11.74 10.0281
14.CDLCOUNTERATTACK - Counterattack
函数名:CDLCOUNTERATTACK
名称:Counterattack 反击线
简介:二日K线模式,与分离线类似。
语法:
integer = CDLCOUNTERATTACK(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2006-03-31 100
2006-09-18 -100
open high low close pct_chg
trade_date
2006-03-21 6.28 6.42 6.23 6.35 1.11
2006-03-22 6.36 6.41 6.31 6.35 0.00
2006-03-23 6.35 6.44 6.35 6.40 0.79
2006-03-24 6.40 6.42 6.31 6.31 -1.41
2006-03-27 6.31 6.36 6.19 6.35 0.63
2006-03-28 6.35 6.41 6.32 6.39 0.63
2006-03-29 6.40 6.58 6.39 6.50 1.72
2006-03-30 6.49 6.54 6.31 6.37 -2.00
2006-03-31 6.30 6.47 6.26 6.37 0.00
2006-04-03 6.32 6.47 6.28 6.41 0.63
2006-04-04 6.41 6.63 6.37 6.57 2.50
2006-04-05 6.57 6.66 6.51 6.60 0.46
2006-04-06 6.63 6.69 6.49 6.52 -1.21
2006-04-07 6.52 6.56 6.41 6.47 -0.77
2006-04-10 6.48 6.75 6.48 6.74 4.17open high low close pct_chg
trade_date
2006-09-08 7.20 7.26 7.15 7.23 0.42
2006-09-11 7.14 7.45 7.14 7.42 2.63
2006-09-12 7.42 7.53 7.36 7.43 0.13
2006-09-13 7.42 7.58 7.35 7.40 -0.40
2006-09-14 7.40 7.69 7.39 7.50 1.35
2006-09-15 7.50 7.65 7.45 7.63 1.73
2006-09-18 7.70 7.73 7.56 7.62 -0.13
2006-09-19 7.62 7.82 7.58 7.71 1.18
2006-09-20 7.70 7.73 7.63 7.68 -0.39
2006-09-21 7.68 7.83 7.68 7.71 0.39
2006-09-22 7.72 7.80 7.40 7.49 -2.85
2006-09-25 7.42 7.66 7.41 7.59 1.34
2006-09-26 7.57 7.61 7.50 7.57 -0.26
2006-09-27 7.57 8.08 7.54 8.01 5.81
2006-09-28 8.00 8.02 7.85 7.95 -0.75
15.CDLDARKCLOUDCOVER - Dark Cloud Cover
函数名:CDLDARKCLOUDCOVER
名称:Dark Cloud Cover 乌云压顶
简介:二日K线模式,第一日长阳,第二日开盘价高于前一日最高价,
收盘价处于前一日实体中部以下,预示着股价下跌。
语法:
integer = CDLDARKCLOUDCOVER(open, high, low, close, penetration=0)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-15 -100
2000-03-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.50open high low close pct_chg
trade_date
2000-03-20 17.90 18.37 17.68 18.22 0.28
2000-03-21 18.22 18.39 18.00 18.26 0.22
2000-03-22 18.26 18.65 18.15 18.48 1.20
2000-03-23 18.50 18.72 18.26 18.61 0.70
2000-03-24 19.11 19.48 18.46 18.50 -0.59
2000-03-27 18.50 18.84 18.40 18.79 1.57
2000-03-28 18.89 19.00 18.60 18.69 -0.53
2000-03-29 18.80 18.88 18.33 18.49 -1.07
2000-03-30 18.45 18.70 18.38 18.57 0.43
2000-03-31 18.57 18.60 18.31 18.37 -1.08
2000-04-03 18.38 18.50 18.20 18.28 -0.49
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
16.CDLDOJI - Doji
函数名:CDLDOJI
名称:Doji 十字
简介:一日K线模式,开盘价与收盘价基本相同。
语法:
integer = CDLDOJI(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
17.CDLDOJISTAR - Doji Star
函数名:CDLDOJISTAR
名称:Doji Star 十字星
简介:一日K线模式,开盘价与收盘价基本相同,上下影线不会很长,预示着当前趋势反转。
语法:
integer = CDLDOJISTAR(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-02-23 100
2000-05-31 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-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
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
18.CDLDRAGONFLYDOJI - Dragonfly Doji
函数名:CDLDRAGONFLYDOJI
名称:Dragonfly Doji 蜻蜓十字/T形十字
简介:一日K线模式,开盘后价格一路走低,
之后收复,收盘价与开盘价相同,预示趋势反转。
语法:
integer = CDLDRAGONFLYDOJI(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-12-04 100
2001-02-16 100
open 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.81open high low close pct_chg
trade_date
2001-02-06 14.59 14.80 14.38 14.68 0.62
2001-02-07 14.69 14.80 14.50 14.54 -0.95
2001-02-08 14.54 14.60 14.00 14.13 -2.82
2001-02-09 14.15 14.50 14.15 14.39 1.84
2001-02-12 14.40 14.50 14.12 14.39 0.00
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
19.CDLENGULFING - Engulfing Pattern
函数名:CDLENGULFING
名称:Engulfing Pattern 吞噬模式
简介:两日K线模式,分多头吞噬和空头吞噬,以多头吞噬为例,第一日为阴线,
第二日阳线,第一日的开盘价和收盘价在第二日开盘价收盘价之内,但不能完全相同。
语法:
integer = CDLENGULFING(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-01-06 100
2000-01-11 -100
open high low close pct_chg
trade_date
2000-01-04 17.50 18.55 17.20 18.29 4.81
2000-01-05 18.35 18.85 18.00 18.06 -1.26
2000-01-06 18.02 19.05 17.75 18.78 3.99
2000-01-07 19.00 19.77 18.90 19.54 4.05
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.43open high low close pct_chg
trade_date
2000-01-04 17.50 18.55 17.20 18.29 4.81
2000-01-05 18.35 18.85 18.00 18.06 -1.26
2000-01-06 18.02 19.05 17.75 18.78 3.99
2000-01-07 19.00 19.77 18.90 19.54 4.05
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
20.CDLEVENINGDOJISTAR - Evening Doji Star
函数名:CDLEVENINGDOJISTAR
名称:Evening Doji Star 十字暮星
简介:三日K线模式,基本模式为暮星,第二日收盘价和开盘价相同,预示顶部反转。
语法:
integer = CDLEVENINGDOJISTAR(open, high, low, close, penetration=0)
stock code: 000001.SZ
position Pattern date:
trade_date
2001-01-03 -100
2001-07-06 -100