# 简介：

Talib一直缺乏有效的中文文档，自己又有空闲时间，且在研究量化对冲系统，就发点时间，做一下翻译。

TA-Lib is widely used by trading software developers requiring to perform
technical analysis of financial market data.
TA-Lib广泛应用与交易软件，和金融市场数据进行技术分析。

• Includes 150+ indicators such as ADX, MACD, RSI, Stochastic, Bollinger
Bands, etc.
• Candlestick pattern recognition
• Open-source API for C/C++, Java, Perl, Python and 100% Managed .NET
• 包含了150多个指标,包括：ADX, MACD, RSI, Stochastic, Bollinger Bands, 等.
• K线形态识别
• 完全开源，支持 C/C++, Java, Perl, Python and 100% Managed .NET

## 案例（快速开始）

Similar to TA-Lib, the function interface provides a lightweight wrapper of
the exposed TA-Lib indicators.

Each function returns an output array and have default values for their
parameters, unless specified as keyword arguments. Typically, these functions
will have an initial “lookback” period (a required number of observations
before an output is generated) set to NaN.

All of the following examples use the function API:

import numpyimport talibclose = numpy.random.random(100)

output = talib.SMA(close)

from talib import MA_Typeupper, middle, lower = talib.BBANDS(close, matype=MA_Type.T3)

output = talib.MOM(close, timeperiod=5)

## Abstract API Quick Start 抽象 API 快速入门

If you’re already familiar with using the function API, you should feel right
at home using the abstract API. Every function takes the same input, passed
as a dictionary of Numpy arrays:

import numpy as np# note that all ndarrays must be the same length!inputs = {    'open': np.random.random(100),    'high': np.random.random(100),    'low': np.random.random(100),    'close': np.random.random(100),    'volume': np.random.random(100)}

from talib import abstractsma = abstract.SMAsma = abstract.Function('sma')

from talib.abstract import *output = SMA(input_arrays, timeperiod=25) # SMA均线价格计算收盘价output = SMA(input_arrays, timeperiod=25, price='open') # SMA均线价格计算收盘价upper, middle, lower = BBANDS(input_arrays, 20, 2, 2)slowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0) # uses high, low, close by defaultslowk, slowd = STOCH(input_arrays, 5, 3, 0, 3, 0, prices=['high', 'low', 'open'])

## Supported Indicators 支持的指标

We can show all the TA functions supported by TA-Lib, either as a list or
as a dict sorted by group (e.g. “Overlap Studies”, “Momentum Indicators”,
etc):

import talibprint talib.get_functions()print talib.get_function_groups()

### Function Groups

#### Overlap Studies

BBANDS               Bollinger Bands #布林带DEMA                 Double Exponential Moving Average #双指数移动平均线EMA                  Exponential Moving Average #指数滑动平均HT_TRENDLINE         Hilbert Transform - Instantaneous Trendline #希尔伯特变换瞬时趋势KAMA                 Kaufman Adaptive Moving Average #卡玛考夫曼自适应移动平均MA                   Moving average #均线MAMA                 MESA Adaptive Moving Average #自适应移动平均 MAVP                 Moving average with variable period #变周期移动平均MIDPOINT             MidPoint over period #在周期的中点MIDPRICE             Midpoint Price over period #中间时段价格SAR                  Parabolic SAR #抛物线转向指标SAREXT               Parabolic SAR - Extended #抛物线转向指标 - 扩展SMA                  Simple Moving Average# 简单移动平均线T3                   Triple Exponential Moving Average (T3)TEMA                 Triple Exponential Moving AverageTRIMA                Triangular Moving AverageWMA                  Weighted Moving Average#加权移动平均线

#### Momentum Indicators

ADX                  Average Directional Movement IndexADXR                 Average Directional Movement Index RatingAPO                  Absolute Price OscillatorAROON                AroonAROONOSC             Aroon OscillatorBOP                  Balance Of PowerCCI                  Commodity Channel IndexCMO                  Chande Momentum OscillatorDX                   Directional Movement IndexMACD                 Moving Average Convergence/DivergenceMACDEXT              MACD with controllable MA typeMACDFIX              Moving Average Convergence/Divergence Fix 12/26MFI                  Money Flow IndexMINUS_DI             Minus Directional IndicatorMINUS_DM             Minus Directional MovementMOM                  MomentumPLUS_DI              Plus Directional IndicatorPLUS_DM              Plus Directional MovementPPO                  Percentage Price OscillatorROC                  Rate of change : ((price/prevPrice)-1)*100ROCP                 Rate of change Percentage: (price-prevPrice)/prevPriceROCR                 Rate of change ratio: (price/prevPrice)ROCR100              Rate of change ratio 100 scale: (price/prevPrice)*100RSI                  Relative Strength IndexSTOCH                StochasticSTOCHF               Stochastic FastSTOCHRSI             Stochastic Relative Strength IndexTRIX                 1-day Rate-Of-Change (ROC) of a Triple Smooth EMAULTOSC               Ultimate OscillatorWILLR                Williams' %R

#### Volume Indicators

AD                   Chaikin A/D LineADOSC                Chaikin A/D OscillatorOBV                  On Balance Volume

#### Volatility Indicators

ATR                  Average True RangeNATR                 Normalized Average True RangeTRANGE               True Range

#### Price Transform

AVGPRICE             Average PriceMEDPRICE             Median PriceTYPPRICE             Typical PriceWCLPRICE             Weighted Close Price

#### Cycle Indicators

HT_DCPERIOD          Hilbert Transform - Dominant Cycle PeriodHT_DCPHASE           Hilbert Transform - Dominant Cycle PhaseHT_PHASOR            Hilbert Transform - Phasor ComponentsHT_SINE              Hilbert Transform - SineWaveHT_TRENDMODE         Hilbert Transform - Trend vs Cycle Mode

#### Pattern Recognition

CDL2CROWS            Two CrowsCDL3BLACKCROWS       Three Black CrowsCDL3INSIDE           Three Inside Up/DownCDL3LINESTRIKE       Three-Line StrikeCDL3OUTSIDE          Three Outside Up/DownCDL3STARSINSOUTH     Three Stars In The SouthCDL3WHITESOLDIERS    Three Advancing White SoldiersCDLABANDONEDBABY     Abandoned BabyCDLADVANCEBLOCK      Advance BlockCDLBELTHOLD          Belt-holdCDLBREAKAWAY         BreakawayCDLCLOSINGMARUBOZU   Closing MarubozuCDLCONCEALBABYSWALL  Concealing Baby SwallowCDLCOUNTERATTACK     CounterattackCDLDARKCLOUDCOVER    Dark Cloud CoverCDLDOJI              DojiCDLDOJISTAR          Doji StarCDLDRAGONFLYDOJI     Dragonfly DojiCDLENGULFING         Engulfing PatternCDLEVENINGDOJISTAR   Evening Doji StarCDLEVENINGSTAR       Evening StarCDLGAPSIDESIDEWHITE  Up/Down-gap side-by-side white linesCDLGRAVESTONEDOJI    Gravestone DojiCDLHAMMER            HammerCDLHANGINGMAN        Hanging ManCDLHARAMI            Harami PatternCDLHARAMICROSS       Harami Cross PatternCDLHIGHWAVE          High-Wave CandleCDLHIKKAKE           Hikkake PatternCDLHIKKAKEMOD        Modified Hikkake PatternCDLHOMINGPIGEON      Homing PigeonCDLIDENTICAL3CROWS   Identical Three CrowsCDLINNECK            In-Neck PatternCDLINVERTEDHAMMER    Inverted HammerCDLKICKING           KickingCDLKICKINGBYLENGTH   Kicking - bull/bear determined by the longer marubozuCDLLADDERBOTTOM      Ladder BottomCDLLONGLEGGEDDOJI    Long Legged DojiCDLLONGLINE          Long Line CandleCDLMARUBOZU          MarubozuCDLMATCHINGLOW       Matching LowCDLMATHOLD           Mat HoldCDLMORNINGDOJISTAR   Morning Doji StarCDLMORNINGSTAR       Morning StarCDLONNECK            On-Neck PatternCDLPIERCING          Piercing PatternCDLRICKSHAWMAN       Rickshaw ManCDLRISEFALL3METHODS  Rising/Falling Three MethodsCDLSEPARATINGLINES   Separating LinesCDLSHOOTINGSTAR      Shooting StarCDLSHORTLINE         Short Line CandleCDLSPINNINGTOP       Spinning TopCDLSTALLEDPATTERN    Stalled PatternCDLSTICKSANDWICH     Stick SandwichCDLTAKURI            Takuri (Dragonfly Doji with very long lower shadow)CDLTASUKIGAP         Tasuki GapCDLTHRUSTING         Thrusting PatternCDLTRISTAR           Tristar PatternCDLUNIQUE3RIVER      Unique 3 RiverCDLUPSIDEGAP2CROWS   Upside Gap Two CrowsCDLXSIDEGAP3METHODS  Upside/Downside Gap Three Methods

#### Statistic Functions

BETA                 BetaCORREL               Pearson's Correlation Coefficient (r)LINEARREG            Linear RegressionLINEARREG_ANGLE      Linear Regression AngleLINEARREG_INTERCEPT  Linear Regression InterceptLINEARREG_SLOPE      Linear Regression SlopeSTDDEV               Standard DeviationTSF                  Time Series ForecastVAR                  Variance