Home

Awesome

CircleCI Documentation Status Coverage Status Code style: black Linter: Prospector PyPI PyPI - Downloads Donate PayPal

Technical Analysis Library in Python

It is a Technical Analysis library useful to do feature engineering from financial time series datasets (Open, Close, High, Low, Volume). It is built on Pandas and Numpy.

Bollinger Bands graph example

The library has implemented 43 indicators:

Volume

IDNameClassdefs
1Money Flow Index (MFI)MFIIndicatormoney_flow_index
2Accumulation/Distribution Index (ADI)AccDistIndexIndicatoracc_dist_index
3On-Balance Volume (OBV)OnBalanceVolumeIndicatoron_balance_volume
4Chaikin Money Flow (CMF)ChaikinMoneyFlowIndicatorchaikin_money_flow
5Force Index (FI)ForceIndexIndicatorforce_index
6Ease of Movement (EoM, EMV)EaseOfMovementIndicatorease_of_movement<br>sma_ease_of_movement
7Volume-price Trend (VPT)VolumePriceTrendIndicatorvolume_price_trend
8Negative Volume Index (NVI)NegativeVolumeIndexIndicatornegative_volume_index
9Volume Weighted Average Price (VWAP)VolumeWeightedAveragePricevolume_weighted_average_price
<br>

Volatility

IDNameClassdefs
10Average True Range (ATR)AverageTrueRangeaverage_true_range
11Bollinger Bands (BB)BollingerBandsbollinger_hband<br>bollinger_hband_indicator<br>bollinger_lband<br>bollinger_lband_indicator<br>bollinger_mavg<br>bollinger_pband<br>bollinger_wband
12Keltner Channel (KC)KeltnerChannelkeltner_channel_hband<br>keltner_channel_hband_indicator<br>keltner_channel_lband<br>keltner_channel_lband_indicator<br>keltner_channel_mband<br>keltner_channel_pband<br>keltner_channel_wband
13Donchian Channel (DC)DonchianChanneldonchian_channel_hband<br>donchian_channel_lband<br>donchian_channel_mban<br>donchian_channel_pband<br>donchian_channel_wband
14Ulcer Index (UI)UlcerIndexulcer_index
<br>

Trend

IDNameClassdefs
15Simple Moving Average (SMA)SMAIndicatorsma_indicator
16Exponential Moving Average (EMA)EMAIndicatorema_indicator
17Weighted Moving Average (WMA)WMAIndicatorwma_indicator
18Moving Average Convergence Divergence (MACD)MACDmacd <br>macd_diff<br>macd_signal
19Average Directional Movement Index (ADX)ADXIndicatoradx<br>adx_neg<br>adx_pos
20Vortex Indicator (VI)VortexIndicatorvortex_indicator_neg <br>vortex_indicator_pos
21Trix (TRIX)TRIXIndicatortrix
22Mass Index (MI)MassIndexmass_index
23Commodity Channel Index (CCI)CCIIndicatorcci
24Detrended Price Oscillator (DPO)DPOIndicatordpo
25KST Oscillator (KST)KSTIndicatorkst<br>kst_sig
26Ichimoku Kinkō Hyō (Ichimoku)IchimokuIndicatorichimoku_a<br>ichimoku_b<br>ichimoku_base_line<br>ichimoku_conversion_line
27Parabolic Stop And Reverse (Parabolic SAR)PSARIndicatorpsar_down <br>psar_down_indicator<br>psar_up<br>psar_up_indicator
28Schaff Trend Cycle (STC)STCIndicatorstc
29Aroon IndicatorAroonIndicatoraroon_down<br>aroon_up
<br>

Momentum

IDNameClassdefs
30Relative Strength Index (RSI)RSIIndicatorrsi
31Stochastic RSI (SRSI)StochRSIIndicatorstochrsi<br>stochrsi_d<br>stochrsi_k
32True strength index (TSI)TSIIndicatortsi
33Ultimate Oscillator (UO)UltimateOscillatorultimate_oscillator
34Stochastic Oscillator (SR)StochasticOscillatorstoch<br>stoch_signal
35Williams %R (WR)WilliamsRIndicatorwilliams_r
36Awesome Oscillator (AO)AwesomeOscillatorIndicatorawesome_oscillator
37Kaufman's Adaptive Moving Average (KAMA)KAMAIndicatorkama
38Rate of Change (ROC)ROCIndicatorroc
39Percentage Price Oscillator (PPO)PercentagePriceOscillatorppo<br>ppo_hist<br>ppo_signal
40Percentage Volume Oscillator (PVO)PercentageVolumeOscillatorpvo<br>pvo_hist<br>pvo_signal
<br>

Others

IDNameClassdefs
41Daily Return (DR)DailyReturnIndicatordaily_return
42Daily Log Return (DLR)DailyLogReturnIndicatordaily_log_return
43Cumulative Return (CR)CumulativeReturnIndicatorcumulative_return
<br>

Documentation

https://technical-analysis-library-in-python.readthedocs.io/en/latest/

Motivation to use

How to use (Python 3)

$ pip install --upgrade ta

To use this library you should have a financial time series dataset including Timestamp, Open, High, Low, Close and Volume columns.

You should clean or fill NaN values in your dataset before add technical analysis features.

You can get code examples in examples_to_use folder.

You can visualize the features in this notebook.

Example adding all features

import pandas as pd
from ta import add_all_ta_features
from ta.utils import dropna


# Load datas
df = pd.read_csv('ta/tests/data/datas.csv', sep=',')

# Clean NaN values
df = dropna(df)

# Add all ta features
df = add_all_ta_features(
    df, open="Open", high="High", low="Low", close="Close", volume="Volume_BTC")

Example adding particular feature

import pandas as pd
from ta.utils import dropna
from ta.volatility import BollingerBands


# Load datas
df = pd.read_csv('ta/tests/data/datas.csv', sep=',')

# Clean NaN values
df = dropna(df)

# Initialize Bollinger Bands Indicator
indicator_bb = BollingerBands(close=df["Close"], window=20, window_dev=2)

# Add Bollinger Bands features
df['bb_bbm'] = indicator_bb.bollinger_mavg()
df['bb_bbh'] = indicator_bb.bollinger_hband()
df['bb_bbl'] = indicator_bb.bollinger_lband()

# Add Bollinger Band high indicator
df['bb_bbhi'] = indicator_bb.bollinger_hband_indicator()

# Add Bollinger Band low indicator
df['bb_bbli'] = indicator_bb.bollinger_lband_indicator()

# Add Width Size Bollinger Bands
df['bb_bbw'] = indicator_bb.bollinger_wband()

# Add Percentage Bollinger Bands
df['bb_bbp'] = indicator_bb.bollinger_pband()

Deploy and develop (for developers)

$ git clone https://github.com/bukosabino/ta.git
$ cd ta
$ pip install -r requirements-play.txt
$ make test

Sponsor

Logo OpenSistemas

Thank you to OpenSistemas! It is because of your contribution that I am able to continue the development of this open source library.

Based on

In Progress

TODO

Changelog

Check the changelog of project.

Donation

If you think ta library help you, please consider buying me a coffee.

Credits

Developed by Darío López Padial (aka Bukosabino) and other contributors.

Please, let me know about any comment or feedback.

Also, I am a software engineer freelance focused on Data Science using Python tools such as Pandas, Scikit-Learn, Backtrader, Zipline or Catalyst. Don't hesitate to contact me if you need to develop something related with this library, Python, Technical Analysis, AlgoTrading, Machine Learning, etc.