TA-Lib学习研究笔记(九)——Pattern Recognition (6)
最全面的形态识别的函数的应用,通过使用A股实际的数据,验证形态识别函数,用K线显示出现标志的形态走势,由于入口参数基本上是open, high, low, close ,统一设置程序代码,只更换函数即可。
发现有的形态在一个股票上从未出现,选择多个股票参与计算测试。
函数返回值integer (values are -100, 0 or 100) ,0 是无形态信号。100 和 -100 是有正向或负向的形态信号。
51.CDLSHORTLINE - Short Line Candle
函数名:CDLSHORTLINE
名称:Short Line Candle 短蜡烛
简介:一日K线模式,实体短,无上下影线
语法:
integer = CDLSHORTLINE(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-01-18 -100
2000-01-19 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-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
52.CDLSPINNINGTOP - Spinning Top
函数名:CDLSPINNINGTOP
名称:Spinning Top 纺锤
简介:一日K线,实体小。
语法:
integer = CDLSPINNINGTOP(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-01-20 100
2000-01-26 -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-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
53.CDLSTALLEDPATTERN - Stalled Pattern
函数名:CDLSTALLEDPATTERN
名称:Stalled Pattern 停顿形态
简介:三日K线模式,上涨趋势中,第二日长阳线,
第三日开盘于前一日收盘价附近,短阳线,预示着上涨结束
语法:
integer = CDLSTALLEDPATTERN(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2002-11-29 -100
2006-02-06 -100
open high low close pct_chg
trade_date
2002-11-19 12.20 12.35 12.00 12.29 0.57
2002-11-20 12.28 12.31 12.07 12.15 -1.14
2002-11-21 12.12 12.15 11.80 11.81 -2.80
2002-11-22 11.81 12.00 11.60 11.80 -0.08
2002-11-25 11.78 11.90 11.65 11.83 0.25
2002-11-26 11.83 11.95 11.55 11.60 -1.94
2002-11-27 11.50 11.74 11.40 11.70 0.86
2002-11-28 11.70 12.00 11.58 11.99 2.48
2002-11-29 12.00 12.35 11.90 12.10 0.92
2002-12-02 12.09 12.09 11.60 11.62 -3.97
2002-12-03 11.63 11.79 11.58 11.76 1.20
2002-12-04 11.76 11.94 11.68 11.79 0.26
2002-12-05 11.78 11.78 11.50 11.64 -1.27
2002-12-06 11.64 11.78 11.52 11.64 0.00
2002-12-09 11.59 11.74 11.50 11.57 -0.60
open high low close pct_chg
trade_date
2006-02-06 6.35 6.47 6.32 6.40 0.79
2006-02-07 6.40 6.40 6.20 6.30 -1.56
2006-02-08 6.27 6.31 6.18 6.30 0.00
2006-02-09 6.28 6.29 6.18 6.19 -1.75
2006-02-10 6.20 6.24 6.15 6.21 0.32
2006-02-13 6.21 6.26 6.16 6.21 0.00
2006-02-14 6.19 6.29 6.16 6.23 0.32
2006-02-15 6.27 6.44 6.27 6.32 1.44
2006-02-16 6.30 6.30 6.17 6.17 -2.37
54.CDLSTICKSANDWICH - Stick Sandwich
函数名:CDLSTICKSANDWICH
名称:Stick Sandwich 条形三明治
简介:三日K线模式,第一日长阴线,第二日阳线,开盘价高于前一日收盘价,
第三日开盘价高于前两日最高价,收盘价于第一日收盘价相同。
语法:
integer = CDLSTICKSANDWICH(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2010-02-22 100
open high low close pct_chg
trade_date
2010-02-12 22.17 22.60 22.17 22.45 1.54
2010-02-22 22.31 22.45 22.08 22.10 -1.56
2010-02-23 22.03 22.05 21.40 21.55 -2.49
2010-02-24 21.41 21.79 21.22 21.71 0.74
2010-02-25 21.67 22.41 21.61 22.15 2.03
2010-02-26 22.01 22.62 21.98 22.45 1.35
2010-03-02 22.89 23.96 22.89 23.11 2.94
2010-03-03 23.11 23.35 22.80 23.30 0.82
2010-03-04 23.32 23.63 23.00 23.10 -0.86
55.CDLTAKURI - Takuri (Dragonfly Doji with very long lower shadow)
函数名:CDLTAKURI
名称:Takuri (Dragonfly Doji with very long lower shadow)
探水竿
简介:一日K线模式,大致与蜻蜓十字相同,下影线长度长。
语法:
integer = CDLTAKURI(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.81
open 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
56.CDLTASUKIGAP - Tasuki Gap
函数名:CDLTASUKIGAP
名称:Tasuki Gap 跳空并列阴阳线
简介:三日K线模式,分上涨和下跌,以上升为例,
前两日阳线,第二日跳空,第三日阴线,收盘价于缺口中,上升趋势持续。
语法:
integer = CDLTASUKIGAP(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-08-15 100
2007-08-30 -100
open 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
open high low close pct_chg
trade_date
2007-08-20 36.00 38.15 36.00 37.90 8.66
2007-08-21 38.45 39.26 37.70 38.56 1.74
2007-08-22 37.85 39.58 37.63 38.59 0.08
2007-08-23 38.40 38.80 37.70 38.39 -0.52
2007-08-24 38.34 40.02 38.20 39.60 3.15
2007-08-27 39.58 40.86 38.41 39.20 -1.01
2007-08-28 38.52 38.80 37.50 37.99 -3.09
2007-08-29 37.48 37.68 36.60 36.84 -3.03
2007-08-30 37.28 38.08 36.58 37.70 2.33
2007-08-31 37.65 38.10 36.95 38.00 0.80
2007-09-03 38.10 38.58 37.86 37.88 -0.32
2007-09-04 37.82 37.85 36.70 37.00 -2.32
2007-09-05 37.00 37.28 36.04 36.79 -0.57
2007-09-06 37.02 38.12 36.70 37.20 1.11
2007-09-07 37.30 38.00 37.00 37.10 -0.27
57.CDLTHRUSTING - Thrusting Pattern
函数名:CDLTHRUSTING
名称:Thrusting Pattern 插入
简介:二日K线模式,与颈上线类似,下跌趋势中,第一日长阴线,第二日开盘价跳空,
收盘价略低于前一日实体中部,与颈上线相比实体较长,预示着趋势持续。
语法:
integer = CDLTHRUSTING(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-07-04 -100
2001-12-25 -100
open high low close pct_chg
trade_date
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
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
open high low close pct_chg
trade_date
2001-12-17 12.69 12.77 12.58 12.60 -0.87
2001-12-18 12.60 12.70 12.58 12.70 0.79
2001-12-19 12.72 12.80 12.50 12.54 -1.26
2001-12-20 12.50 12.54 12.25 12.31 -1.83
2001-12-21 12.30 12.35 12.28 12.33 0.16
2001-12-24 12.40 12.41 12.04 12.10 -1.87
2001-12-25 12.03 12.18 11.99 12.13 0.25
2001-12-26 12.13 12.30 12.05 12.30 1.40
2001-12-27 12.30 12.42 12.08 12.10 -1.63
2001-12-28 12.10 12.25 12.08 12.16 0.50
2001-12-31 12.20 12.30 12.10 12.25 0.74
2002-01-04 12.28 12.30 12.07 12.11 -1.14
58.CDLTRISTAR - Tristar Pattern
函数名:CDLTRISTAR
名称:Tristar Pattern 三星
简介:三日K线模式,由三个十字组成,
第二日十字必须高于或者低于第一日和第三日,预示着反转。
语法:
integer = CDLTRISTAR(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2013-02-19 -100
2015-01-26 -100
open high low close pct_chg
trade_date
2013-02-18 20.91 21.49 20.73 20.90 0.72
2013-02-19 20.80 21.11 20.67 20.81 -0.43
2013-02-20 20.85 20.99 19.69 20.30 -2.45
2013-02-21 20.00 20.00 19.06 19.60 -3.45
2013-02-22 19.50 19.69 18.95 19.12 -2.45
2013-02-25 19.26 20.30 19.22 20.01 4.65
2013-02-26 19.81 21.97 19.70 20.85 4.20
2013-02-27 21.01 21.82 20.85 21.02 0.82
2013-02-28 21.14 23.00 21.03 23.00 9.42
2013-03-01 22.93 23.24 22.37 23.06 0.26
open high low close pct_chg
trade_date
2015-01-16 15.40 15.62 15.18 15.37 0.13
2015-01-19 14.01 14.57 13.83 13.83 -10.02
2015-01-20 13.83 14.06 13.56 13.83 0.00
2015-01-21 13.88 14.60 13.75 14.42 4.27
2015-01-22 14.34 14.52 14.16 14.30 -0.83
2015-01-23 14.36 14.63 14.30 14.40 0.70
2015-01-26 14.36 14.44 14.16 14.34 -0.42
2015-01-27 14.35 14.37 13.83 13.99 -2.44
2015-01-28 13.87 14.30 13.80 14.06 0.50
2015-01-29 13.82 14.01 13.75 13.90 -1.14
2015-01-30 13.93 14.12 13.76 13.93 0.22
2015-02-02 13.60 13.80 13.55 13.63 -2.15
2015-02-03 13.78 13.99 13.62 13.95 2.35
2015-02-04 14.00 14.04 13.70 13.71 -1.72
2015-02-05 14.30 14.43 13.76 13.79 0.58
59.CDLUNIQUE3RIVER - Unique 3 River
函数名:CDLUNIQUE3RIVER
名称:Unique 3 River 奇特三河床
简介:三日K线模式,下跌趋势中,第一日长阴线,第二日为锤头,最低价创新低,第三日开盘价低于第二日收盘价,收阳线,
收盘价不高于第二日收盘价,预示着反转,第二日下影线越长可能性越大。
语法:
integer = CDLUNIQUE3RIVER(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2001-11-20 100
2007-10-22 100
open 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
open high low close pct_chg
trade_date
2007-10-12 41.30 41.40 38.10 39.41 -3.90
2007-10-15 40.00 40.70 38.70 39.80 0.99
2007-10-16 40.10 42.50 39.76 41.95 5.40
2007-10-17 41.79 43.26 40.96 41.85 -0.24
2007-10-18 42.00 42.20 39.48 39.50 -5.62
2007-10-19 40.00 40.99 39.00 39.81 0.78
2007-10-22 39.60 40.60 38.50 39.81 0.00
2007-10-23 40.10 41.40 40.05 41.10 3.24
2007-10-24 41.30 43.12 41.27 41.80 1.70
2007-10-25 41.88 43.00 40.85 41.13 -1.60
2007-10-26 41.70 45.13 41.59 44.58 8.39
2007-10-29 44.93 47.58 44.59 45.25 1.50
2007-10-30 45.25 45.60 44.20 45.10 -0.33
2007-10-31 45.98 48.80 45.30 48.05 6.54
2007-11-01 47.11 48.98 47.01 47.20 -1.77
60.CDLUPSIDEGAP2CROWS - Upside Gap Two Crows
函数名:CDLUPSIDEGAP2CROWS
名称:Upside Gap Two Crows 向上跳空的两只乌鸦
简介:三日K线模式,第一日阳线,第二日跳空以高于第一日最高价开盘,
收阴线,第三日开盘价高于第二日,收阴线,与第一日比仍有缺口。
语法:
integer = CDLUPSIDEGAP2CROWS(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2007-06-25 -100
open high low close pct_chg
trade_date
2007-06-20 33.00 33.30 30.66 31.19 8.71
2007-06-21 32.44 34.31 31.25 34.31 10.00
2007-06-22 35.60 35.80 33.80 35.40 3.18
2007-06-25 36.01 36.58 34.35 35.20 -0.57
2007-06-27 31.68 33.79 31.68 32.22 -8.47
2007-06-28 31.50 32.37 30.03 30.14 -6.46
2007-06-29 29.80 29.98 27.22 27.52 -8.69
2007-07-02 26.81 27.86 26.57 27.40 -0.44
2007-07-03 27.55 28.15 26.73 27.23 -0.62
2007-07-04 27.45 27.55 26.10 26.20 -3.78
2007-07-05 25.70 26.87 25.14 25.20 -3.82
61.CDLXSIDEGAP3METHODS - Upside/Downside Gap Three Methods
函数名:CDLXSIDEGAP3METHODS
名称:Upside/Downside Gap Three Methods 上升/下降跳空三法
简介:五日K线模式,以上升跳空三法为例,上涨趋势中,第一日长阳线,第二日短阳线,第三日跳空阳线,第四日阴线,开盘价与收盘价于前两日实体内,
第五日长阳线,收盘价高于第一日收盘价,预示股价上升。
语法:
integer = CDLXSIDEGAP3METHODS(open, high, low, close)
stock code: 000001.SZ
position Pattern date:
trade_date
2000-06-01 -100
2003-05-20 100
open 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
open high low close pct_chg
trade_date
2003-05-12 12.20 12.76 11.98 12.59 1.29
2003-05-13 12.62 12.73 11.92 11.96 -5.00
2003-05-14 11.91 12.17 11.80 12.07 0.92
2003-05-15 12.10 12.31 11.90 12.25 1.49
2003-05-16 12.27 13.18 12.25 12.60 2.86
2003-05-19 12.65 12.95 12.47 12.80 1.59
2003-05-20 12.78 12.78 12.45 12.53 -2.11
2003-05-21 12.50 12.79 12.36 12.39 -1.12
2003-05-22 12.39 12.61 12.18 12.53 1.13
2003-05-23 12.58 12.85 12.48 12.59 0.48
2003-05-26 12.59 12.83 12.57 12.73 1.11
2003-05-27 12.76 12.88 12.64 12.72 -0.08
2003-05-28 12.75 13.00 12.60 12.61 -0.86
2003-05-29 12.58 12.66 12.30 12.64 0.24
2003-05-30 12.70 12.77 12.37 12.55 -0.71
61个函数,终于整理完了,大家共同学习,点赞收藏!!!