TA-Lib
(重定向自Talib)
TA-Lib(Technical Analysis Library)是一个多平台的技术分析库,多种编程语言的开源API,包括C/C++、Java、Perl、Python版等。包含200多个技术指标,如ADX、MACD、RSI、布林带等,还支持烛台模式识别。Ta-Lib使用BSD许可,允许将它集成到您自己的开源或商业应用程序中。
TA-Lib的Python版本是使用 SWIG 封装C/C++版本的API,难安装,速度稍慢。开源项目mrjbq7/ta-lib使用Cython和Numpy封装TA-Lib的C/C++版,速度比TA-Lib的Python版快,所以在Python中一般使用该版本。
简介
时间轴
安装
使用pip安装
mrjbq7/ta-lib有发布在PyPI上,可以使用pip安装:
pip install TA-Lib
了解更多 >> mrjbq7/ta-lib:安装
故障排除
了解更多 >> mrjbq7/ta-lib:故障排除
函数
Overlap Studies 重叠指标
函数名 | 描述 | 代码 |
---|---|---|
MA Moving average |
移动平均线 按照计算方法可分多种,一般指简单移动平均(SMA)。 参数: matype:默认0(简单移动平均),0=SMA,1=EMA,2=WMA,3=DEMA,4=TEMA,5=TRIMA,6=KAMA,7=MAMA,8=T3 |
MA(close, timeperiod=30, matype=0) |
SMA Simple Moving Average |
简单移动平均 | SMA(close, timeperiod=30) |
EMA Exponential Moving Average |
指数移动平均 是以指数式递减加权的移动平均。 |
EMA(close, timeperiod=30) |
WMA Weighted Moving Average |
WMA(close, timeperiod=30) | |
DEMA Double Exponential Moving Average |
DEMA(close, timeperiod=30) | |
TEMA Triple Exponential Moving Average |
TEMA(close, timeperiod=30) | |
TRIMA Triangular Moving Average |
TRIMA(close, timeperiod=30) | |
KAMA Kaufman Adaptive Moving Average |
KAMA(close, timeperiod=30) | |
MAMA MESA Adaptive Moving Average |
mama, fama = MAMA(close, fastlimit=0, slowlimit=0) | |
T3 Triple Exponential Moving Average (T3) |
T3(close, timeperiod=5, vfactor=0) | |
BBANDS Bollinger Bands |
upperband, middleband, lowerband = BBANDS(close, timeperiod=5, nbdevup=2, nbdevdn=2, matype=0) | |
HT_TRENDLINE Hilbert Transform |
HT_TRENDLINE(close) | |
MAVP Moving average with variable period |
MAVP(close, periods, minperiod=2, maxperiod=30, matype=0) | |
MIDPOINT MidPoint over period |
MIDPOINT(close, timeperiod=14) | |
MIDPRICE Midpoint Price over period |
MIDPRICE(high, low, timeperiod=14) | |
SAR Parabolic SAR |
SAR(high, low, acceleration=0, maximum=0) | |
SAREXT Parabolic SAR |
SAREXT(high, low, startvalue=0, offsetonreverse=0, accelerationinitlong=0, accelerationlong=0, accelerationmaxlong=0, accelerationinitshort=0, accelerationshort=0, accelerationmaxshort=0) |
Momentum Indicator 动量指标
函数名 | 描述 | 代码 |
---|---|---|
ADX Average Directional Movement Index |
ADX(high, low, close, timeperiod=14) | |
ADXR Average Directional Movement Index Rating |
ADXR(high, low, close, timeperiod=14) | |
APO Absolute Price Oscillator |
APO(close, fastperiod=12, slowperiod=26, matype=0) | |
AROON Aroon |
oondown, aroonup = AROON(high, low, timeperiod=14) | |
AROONOSC Aroon Oscillator |
AROONOSC(high, low, timeperiod=14) | |
BOP Balance Of Power |
BOP(open, high, low, close) | |
CCI Commodity Channel Index |
CCI(high, low, close, timeperiod=14) | |
CMO Chande Momentum Oscillator |
CMO(close, timeperiod=14) | |
DX Directional Movement Index |
DX(high, low, close, timeperiod=14) | |
MACD Moving Average Convergence/Divergence |
macd, macdsignal, macdhist = MACD(close, fastperiod=12, slowperiod=26, signalperiod=9) | |
MACDEXT MACD with controllable MA type |
macd, macdsignal, macdhist = MACDEXT(close, fastperiod=12, fastmatype=0, slowperiod=26, slowmatype=0, signalperiod=9, signalmatype=0) | |
MACDFIX Moving Average Convergence/Divergence Fix 12/26 |
macd, macdsignal, macdhist = MACDFIX(close, signalperiod=9) | |
MFI Money Flow Index |
MFI(high, low, close, volume, timeperiod=14) | |
MINUS_DI Minus Directional Indicator |
MINUS_DI(high, low, close, timeperiod=14) | |
MINUS_DM Minus Directional Movement |
MINUS_DM(high, low, timeperiod=14) | |
MOM Momentum |
MOM(close, timeperiod=10) | |
PLUS_DI Plus Directional Indicator |
PLUS_DI(high, low, close, timeperiod=14) | |
PLUS_DM Plus Directional Movement |
PLUS_DM(high, low, timeperiod=14) | |
PPO Percentage Price Oscillator |
PPO(close, fastperiod=12, slowperiod=26, matype=0) | |
ROC Rate of change : ((price/prevPrice) |
ROC(close, timeperiod=10) | |
ROCP Rate of change Percentage: (price |
ROCP(close, timeperiod=10) | |
ROCR Rate of change ratio: (price/prevPrice) |
ROCR(close, timeperiod=10) | |
ROCR100 Rate of change ratio 100 scale: (price/prevPrice)*100 |
ROCR100(close, timeperiod=10) | |
RSI Relative Strength Index |
RSI(close, timeperiod=14) | |
STOCH Stochastic |
slowk, slowd = STOCH(high, low, close, fastk_period=5, slowk_period=3, slowk_matype=0, slowd_period=3, slowd_matype=0) | |
STOCHF Stochastic Fast |
fastk, fastd = STOCHF(high, low, close, fastk_period=5, fastd_period=3, fastd_matype=0) | |
STOCHRSI Stochastic Relative Strength Index |
fastk, fastd = STOCHRSI(close, timeperiod=14, fastk_period=5, fastd_period=3, fastd_matype=0) | |
TRIX 1-day Rate-Of-Change (ROC) of a Triple Smooth EMA |
TRIX(close, timeperiod=30) | |
ULTOSC Ultimate Oscillator |
ULTOSC(high, low, close, timeperiod1=7, timeperiod2=14, timeperiod3=28) | |
WILLR Williams' %R |
WILLR(high, low, close, timeperiod=14) |
Volume Indicators
函数名 | 描述 | 代码 |
---|---|---|
AD Chaikin A/D Line |
AD(high, low, close, volume) | |
ADOSC Chaikin A/D Oscillator |
ADOSC(high, low, close, volume, fastperiod=3, slowperiod=10) | |
OBV On Balance Volume |
OBV(close, volume) |
Volatility Indicators
函数名 | 描述 | 代码 |
---|---|---|
ATR Average True Range |
ATR(high, low, close, timeperiod=14) | |
NATR Normalized Average True Range |
NATR(high, low, close, timeperiod=14) | |
TRANGE True Range |
TRANGE(high, low, close) |
Price Transform
函数名 | 描述 | 代码 |
---|---|---|
AVGPRICE Average Price |
AVGPRICE(open, high, low, close) | |
MEDPRICE Median Price |
MEDPRICE(high, low) | |
TYPPRICE Typical Price |
TYPPRICE(high, low, close) | |
WCLPRICE Weighted Close Price |
WCLPRICE(high, low, close) |
了解更多 >> mrjbq7/ta-lib 文档:Price Transform
Cycle Indicators
函数名 | 描述 | 代码 |
---|---|---|
HT_DCPERIOD Hilbert Transform - Dominant Cycle Period |
HT_DCPERIOD(close) | |
HT_DCPHASE Hilbert Transform - Dominant Cycle Phase |
HT_DCPHASE(close) | |
HT_PHASOR Hilbert Transform - Phasor Components |
inphase, quadrature = HT_PHASOR(close) | |
HT_SINE Hilbert Transform - SineWave |
sine, leadsine = HT_SINE(close) | |
HT_TRENDMODE Hilbert Transform - Trend vs Cycle Mode |
HT_TRENDMODE(close) |
Pattern Recognition
函数名 | 描述 | 代码 |
---|---|---|
CDL2CROWS Two Crows |
CDL2CROWS(open, high, low, close) | |
CDL3BLACKCROWS Three Black Crows |
CDL3BLACKCROWS(open, high, low, close) | |
CDL3INSIDE Three Inside Up/Down |
CDL3INSIDE(open, high, low, close) | |
CDL3LINESTRIKE Three-Line Strike |
CDL3LINESTRIKE(open, high, low, close) | |
CDL3OUTSIDE Three Outside Up/Down |
CDL3OUTSIDE(open, high, low, close) | |
CDL3STARSINSOUTH Three Stars In The South |
CDL3STARSINSOUTH(open, high, low, close) | |
CDL3WHITESOLDIERS Three Advancing White Soldiers |
CDL3WHITESOLDIERS(open, high, low, close) | |
CDLABANDONEDBABY Abandoned Baby |
CDLABANDONEDBABY(open, high, low, close, penetration=0) | |
CDLADVANCEBLOCK Advance Block |
CDLADVANCEBLOCK(open, high, low, close) | |
CDLBELTHOLD Belt-hold |
CDLBELTHOLD(open, high, low, close) | |
CDLBREAKAWAY Breakaway |
CDLBREAKAWAY(open, high, low, close) | |
CDLCLOSINGMARUBOZU Closing Marubozu |
CDLCLOSINGMARUBOZU(open, high, low, close) | |
CDLCONCEALBABYSWALL Concealing Baby Swallow |
CDLCONCEALBABYSWALL(open, high, low, close) | |
CDLCOUNTERATTACK Counterattack |
CDLCOUNTERATTACK(open, high, low, close) | |
CDLDARKCLOUDCOVER Dark Cloud Cover |
CDLDARKCLOUDCOVER(open, high, low, close, penetration=0) | |
CDLDOJI Doji |
CDLDOJI(open, high, low, close) | |
CDLDOJISTAR Doji Star |
CDLDOJISTAR(open, high, low, close) | |
CDLDRAGONFLYDOJI Dragonfly Doji |
CDLDRAGONFLYDOJI(open, high, low, close) | |
CDLENGULFING Engulfing Pattern |
CDLENGULFING(open, high, low, close) | |
CDLEVENINGDOJISTAR Evening Doji Star |
CDLEVENINGDOJISTAR(open, high, low, close, penetration=0) | |
CDLEVENINGSTAR Evening Star |
CDLEVENINGSTAR(open, high, low, close, penetration=0) | |
CDLGAPSIDESIDEWHITE Up/Down-gap side-by-side white lines |
CDLGAPSIDESIDEWHITE(open, high, low, close) | |
CDLGRAVESTONEDOJI Gravestone Doji |
CDLGRAVESTONEDOJI(open, high, low, close) | |
CDLHAMMER Hammer |
CDLHAMMER(open, high, low, close) | |
CDLHANGINGMAN Hanging Man |
CDLHANGINGMAN(open, high, low, close) | |
CDLHARAMI Harami Pattern |
CDLHARAMI(open, high, low, close) | |
CDLHARAMICROSS Harami Cross Pattern |
CDLHARAMICROSS(open, high, low, close) | |
CDLHIGHWAVE High-Wave Candle |
CDLHIGHWAVE(open, high, low, close) | |
CDLHIKKAKE Hikkake Pattern |
CDLHIKKAKE(open, high, low, close) | |
CDLHIKKAKEMOD Modified Hikkake Pattern |
CDLHIKKAKEMOD(open, high, low, close) | |
CDLHOMINGPIGEON Homing Pigeon |
CDLHOMINGPIGEON(open, high, low, close) | |
CDLIDENTICAL3CROWS Identical Three Crows |
CDLIDENTICAL3CROWS(open, high, low, close) | |
CDLINNECK In-Neck Pattern |
CDLINNECK(open, high, low, close) | |
CDLINVERTEDHAMMER Inverted Hammer |
CDLINVERTEDHAMMER(open, high, low, close) | |
CDLKICKING Kicking |
CDLKICKING(open, high, low, close) | |
CDLKICKINGBYLENGTH Kicking - bull/bear determined by the longer marubozu |
CDLKICKINGBYLENGTH(open, high, low, close) | |
CDLLADDERBOTTOM Ladder Bottom |
CDLLADDERBOTTOM(open, high, low, close) | |
CDLLONGLEGGEDDOJI Long Legged Doji |
CDLLONGLEGGEDDOJI(open, high, low, close) | |
CDLLONGLINE Long Line Candle |
CDLLONGLINE(open, high, low, close) | |
CDLMARUBOZU Marubozu |
CDLMARUBOZU(open, high, low, close) | |
CDLMATCHINGLOW Matching Low |
CDLMATCHINGLOW(open, high, low, close) | |
CDLMATHOLD Mat Hold |
CDLMATHOLD(open, high, low, close, penetration=0) | |
CDLMORNINGDOJISTAR Morning Doji Star |
CDLMORNINGDOJISTAR(open, high, low, close, penetration=0) | |
CDLMORNINGSTAR Morning Star |
CDLMORNINGSTAR(open, high, low, close, penetration=0) | |
CDLONNECK On-Neck Pattern |
CDLONNECK(open, high, low, close) | |
CDLPIERCING Piercing Pattern |
CDLPIERCING(open, high, low, close) | |
CDLRICKSHAWMAN Rickshaw Man |
CDLRICKSHAWMAN(open, high, low, close) | |
CDLRISEFALL3METHODS Rising/Falling Three Methods |
CDLRISEFALL3METHODS(open, high, low, close) | |
CDLSEPARATINGLINES Separating Lines |
CDLSEPARATINGLINES(open, high, low, close) | |
CDLSHOOTINGSTAR Shooting Star |
CDLSHOOTINGSTAR(open, high, low, close) | |
CDLSHORTLINE Short Line Candle |
CDLSHORTLINE(open, high, low, close) | |
CDLSPINNINGTOP Spinning Top |
CDLSPINNINGTOP(open, high, low, close) | |
CDLSTALLEDPATTERN Stalled Pattern |
CDLSTALLEDPATTERN(open, high, low, close) | |
CDLSTICKSANDWICH Stick Sandwich |
CDLSTICKSANDWICH(open, high, low, close) | |
CDLTAKURI Takuri (Dragonfly Doji with very long lower shadow) |
CDLTAKURI(open, high, low, close) | |
CDLTASUKIGAP Tasuki Gap |
CDLTASUKIGAP(open, high, low, close) | |
CDLTHRUSTING Thrusting Pattern |
CDLTHRUSTING(open, high, low, close) | |
CDLTRISTAR Tristar Pattern |
CDLTRISTAR(open, high, low, close) | |
CDLUNIQUE3RIVER Unique 3 River |
CDLUNIQUE3RIVER(open, high, low, close) | |
CDLUPSIDEGAP2CROWS Upside Gap Two Crows |
CDLUPSIDEGAP2CROWS(open, high, low, close) | |
CDLXSIDEGAP3METHODS Upside/Downside Gap Three Methods |
CDLXSIDEGAP3METHODS(open, high, low, close) |
Statistic Functions
函数名 | 描述 | 代码 |
---|---|---|
BETA Beta |
BETA(high, low, timeperiod=5) | |
CORREL Pearson's Correlation Coefficient (r) |
CORREL(high, low, timeperiod=30) | |
LINEARREG Linear Regression |
LINEARREG(close, timeperiod=14) | |
LINEARREG_ANGLE Linear Regression Angle |
LINEARREG_ANGLE(close, timeperiod=14) | |
LINEARREG_INTERCEPT Linear Regression Intercept |
LINEARREG_INTERCEPT(close, timeperiod=14) | |
LINEARREG_SLOPE Linear Regression Slope |
LINEARREG_SLOPE(close, timeperiod=14) | |
STDDEV Standard Deviation |
STDDEV(close, timeperiod=5, nbdev=1) | |
TSF Time Series Forecast |
TSF(close, timeperiod=14) | |
VAR Variance |
VAR(close, timeperiod=5, nbdev=1) |
Math Transform
函数名 | 描述 | 代码 |
---|---|---|
ACOS Vector Trigonometric ACos |
ACOS(close) | |
ASIN Vector Trigonometric ASin |
ASIN(close) | |
ATAN Vector Trigonometric ATan |
ATAN(close) | |
CEIL Vector Ceil |
CEIL(close) | |
COS Vector Trigonometric Cos |
COS(close) | |
COSH Vector Trigonometric Cosh |
COSH(close) | |
EXP Vector Arithmetic Exp |
EXP(close) | |
FLOOR Vector Floor |
FLOOR(close) | |
LN Vector Log Natural |
LN(close) | |
LOG10 Vector Log10 |
LOG10(close) | |
SIN Vector Trigonometric Sin |
SIN(close) | |
SINH Vector Trigonometric Sinh |
SINH(close) | |
SQRT Vector Square Root |
SQRT(close) | |
TAN Vector Trigonometric Tan |
TAN(close) | |
TANH Vector Trigonometric Tanh |
TANH(close) |
了解更多 >> mrjbq7/ta-lib 文档:Math Transform
Math Operators
函数名 | 描述 | 代码 |
---|---|---|
ADD Vector Arithmetic Add |
ADD(high, low) | |
DIV Vector Arithmetic Div |
DIV(high, low) | |
MAX Highest value over a specified period |
MAX(close, timeperiod=30) | |
MAXINDEX Index of highest value over a specified period |
MAXINDEX(close, timeperiod=30) | |
MIN Lowest value over a specified period |
MIN(close, timeperiod=30) | |
MININDEX Index of lowest value over a specified period |
MININDEX(close, timeperiod=30) | |
MINMAX Lowest and highest values over a specified period |
min, max = MINMAX(close, timeperiod=30) | |
MINMAXINDEX Indexes of lowest and highest values over a specified period |
minidx, maxidx = MINMAXINDEX(close, timeperiod=30) | |
MULT Vector Arithmetic Mult |
MULT(high, low) | |
SUB Vector Arithmetic Substraction |
SUB(high, low) | |
SUM Summation |
SUM(close, timeperiod=30) |
了解更多 >> mrjbq7/ta-lib 文档:Math Operators