Python Technical Analysis Library Guide
Python Technical Analysis Library Guide
Documentation
Release 0.1.4
1 Installation (python 3) 3
2 Examples 5
3 Motivation 7
4 Contents 9
4.1 Documentation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 9
Index 33
i
ii
Technical Analysis Library in Python Documentation, Release 0.1.4
It is a Technical Analysis library to financial time series datasets (open, close, high, low, volume). You can use it to do
feature engineering from financial datasets. It is builded on Python Pandas library.
Contents 1
Technical Analysis Library in Python Documentation, Release 0.1.4
2 Contents
CHAPTER 1
Installation (python 3)
3
Technical Analysis Library in Python Documentation, Release 0.1.4
Examples
import pandas as pd
from ta import *
# Load datas
df = pd.read_csv('[Link]', sep=',')
import pandas as pd
from ta import *
# Load datas
df = pd.read_csv('[Link]', sep=',')
5
Technical Analysis Library in Python Documentation, Release 0.1.4
6 Chapter 2. Examples
CHAPTER 3
Motivation
• English: [Link]
• Spanish: [Link]
A9cnico-sobre-series-temporales-financieras-para-machine-learning-con-cb28f9427d0
7
Technical Analysis Library in Python Documentation, Release 0.1.4
8 Chapter 3. Motivation
CHAPTER 4
Contents
4.1 Documentation
It is a technical analysis library to financial time series datasets. You can use it to do feature engineering from financial
datasets. It is builded on pandas python library.
Momentum Indicators.
[Link](high, low, s=5, len=34, fillna=False)
Awesome Oscillator
From: [Link]
The Awesome Oscillator is an indicator used to measure market momentum. AO calculates the difference of a
34 Period and 5 Period Simple Moving Averages. The Simple Moving Averages that are used are not calculated
using closing price but rather each bar’s midpoints. AO is generally used to affirm trends or to anticipate possible
reversals.
From: [Link]
Awesome Oscillator is a 34-period simple moving average, plotted through the central points of the bars
(H+L)/2, and subtracted from the 5-period simple moving average, graphed across the central points of the
bars (H+L)/2.
MEDIAN PRICE = (HIGH+LOW)/2
AO = SMA(MEDIAN PRICE, 5)-SMA(MEDIAN PRICE, 34)
where
SMA — Simple Moving Average.
Parameters
• high ([Link]) – dataset ‘High’ column.
9
Technical Analysis Library in Python Documentation, Release 0.1.4
10 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
the current price with the price “n” periods ago. The plot forms an oscillator that fluctuates above and below
the zero line as the Rate-of-Change moves from positive to negative. As a momentum oscillator, ROC signals
include centerline crossovers, divergences and overbought-oversold readings. Divergences fail to foreshadow
reversals more often than not, so this article will forgo a detailed discussion on them. Even though centerline
crossovers are prone to whipsaw, especially short-term, these crossovers can be used to identify the overall trend.
Identifying overbought or oversold extremes comes naturally to the Rate-of-Change oscillator.
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n periods.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link](close, n=14, fillna=False)
Relative Strength Index (RSI)
Compares the magnitude of recent gains and losses over a specified time period to measure speed and change of
price movements of a security. It is primarily used to attempt to identify overbought or oversold conditions in
the trading of an asset.
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link](high, low, close, n=14, fillna=False)
Stochastic Oscillator
Developed in the late 1950s by George Lane. The stochastic oscillator presents the location of the closing price
of a stock in relation to the high and low range of the price of a stock over a period of time, typically a 14-day
period.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
4.1. Documentation 11
Technical Analysis Library in Python Documentation, Release 0.1.4
12 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
Volume Indicators.
[Link].acc_dist_index(high, low, close, volume, fillna=False)
Accumulation/Distribution Index (ADI)
Acting as leading indicator of price movements.
4.1. Documentation 13
Technical Analysis Library in Python Documentation, Release 0.1.4
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• volume ([Link]) – dataset ‘Volume’ column.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].chaikin_money_flow(high, low, close, volume, n=20, fillna=False)
Chaikin Money Flow (CMF)
It measures the amount of Money Flow Volume over a specific period.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• volume ([Link]) – dataset ‘Volume’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].ease_of_movement(high, low, close, volume, n=20, fillna=False)
Ease of movement (EoM, EMV)
It relate an asset’s price change to its volume and is particularly useful for assessing the strength of a trend.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• volume ([Link]) – dataset ‘Volume’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
14 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
4.1. Documentation 15
Technical Analysis Library in Python Documentation, Release 0.1.4
Parameters
• close ([Link]) – dataset ‘Close’ column.
• volume ([Link]) – dataset ‘Volume’ column.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].put_call_ratio()
Put/Call ratio (PCR) [Link]
[Link].volume_price_trend(close, volume, fillna=False)
Volume-price trend (VPT)
Is based on a running cumulative volume that adds or substracts a multiple of the percentage change in share
price trend and current volume, depending upon the investment’s upward or downward movements.
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• volume ([Link]) – dataset ‘Volume’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
Volatility Indicators.
[Link].average_true_range(high, low, close, n=14, fillna=False)
Average True Range (ATR)
The indicator provide an indication of the degree of price volatility. Strong moves, in either direction, are often
accompanied by large ranges, or large True Ranges.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
Returns New feature generated.
Return type [Link]
[Link].bollinger_hband(close, n=20, ndev=2, fillna=False)
Bollinger Bands (BB)
Upper band at K times an N-period standard deviation above the moving average (MA + Kdeviation).
16 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• ndev (int) – n factor standard deviation
Returns New feature generated.
Return type [Link]
[Link].bollinger_hband_indicator(close, n=20, ndev=2, fillna=False)
Bollinger High Band Indicator
Returns 1, if close is higher than bollinger high band. Else, return 0.
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• ndev (int) – n factor standard deviation
Returns New feature generated.
Return type [Link]
[Link].bollinger_lband(close, n=20, ndev=2, fillna=False)
Bollinger Bands (BB)
Lower band at K times an N-period standard deviation below the moving average (MA Kdeviation).
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• ndev (int) – n factor standard deviation
Returns New feature generated.
Return type [Link]
[Link].bollinger_lband_indicator(close, n=20, ndev=2, fillna=False)
Bollinger Low Band Indicator
Returns 1, if close is lower than bollinger low band. Else, return 0.
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• ndev (int) – n factor standard deviation
Returns New feature generated.
Return type [Link]
4.1. Documentation 17
Technical Analysis Library in Python Documentation, Release 0.1.4
18 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
4.1. Documentation 19
Technical Analysis Library in Python Documentation, Release 0.1.4
Trend Indicators.
[Link](high, low, close, n=14, fillna=False)
Average Directional Movement Index (ADX)
The Plus Directional Indicator (+DI) and Minus Directional Indicator (-DI) are derived from smoothed aver-
ages of these differences, and measure trend direction over time. These two indicators are often referred to
collectively as the Directional Movement Indicator (DMI).
The Average Directional Index (ADX) is in turn derived from the smoothed averages of the difference between
+DI and -DI, and measures the strength of the trend (regardless of direction) over time.
Using these three indicators together, chartists can determine both the direction and strength of the trend.
20 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].adx_neg(high, low, close, n=14, fillna=False)
Average Directional Movement Index Negative (ADX)
The Plus Directional Indicator (+DI) and Minus Directional Indicator (-DI) are derived from smoothed aver-
ages of these differences, and measure trend direction over time. These two indicators are often referred to
collectively as the Directional Movement Indicator (DMI).
The Average Directional Index (ADX) is in turn derived from the smoothed averages of the difference between
+DI and -DI, and measures the strength of the trend (regardless of direction) over time.
Using these three indicators together, chartists can determine both the direction and strength of the trend.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].adx_pos(high, low, close, n=14, fillna=False)
Average Directional Movement Index Positive (ADX)
The Plus Directional Indicator (+DI) and Minus Directional Indicator (-DI) are derived from smoothed aver-
ages of these differences, and measure trend direction over time. These two indicators are often referred to
collectively as the Directional Movement Indicator (DMI).
The Average Directional Index (ADX) is in turn derived from the smoothed averages of the difference between
+DI and -DI, and measures the strength of the trend (regardless of direction) over time.
Using these three indicators together, chartists can determine both the direction and strength of the trend.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
4.1. Documentation 21
Technical Analysis Library in Python Documentation, Release 0.1.4
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].aroon_down(close, n=25, fillna=False)
Aroon Indicator (AI)
Identify when trends are likely to change direction (downtrend).
Aroon Down - ((N - Days Since N-day Low) / N) x 100
[Link] :Parameters: * close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
22 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
4.1. Documentation 23
Technical Analysis Library in Python Documentation, Release 0.1.4
24 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
4.1. Documentation 25
Technical Analysis Library in Python Documentation, Release 0.1.4
26 Chapter 4. Contents
Technical Analysis Library in Python Documentation, Release 0.1.4
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].vortex_indicator_pos(high, low, close, n=14, fillna=False)
Vortex Indicator (VI)
It consists of two oscillators that capture positive and negative trend movement. A bullish signal triggers when
the positive trend indicator crosses above the negative trend indicator or a key level.
[Link]
Parameters
• high ([Link]) – dataset ‘High’ column.
• low ([Link]) – dataset ‘Low’ column.
• close ([Link]) – dataset ‘Close’ column.
• n (int) – n period.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
Others Indicators.
[Link].cumulative_return(close, fillna=False)
Cumulative Return (CR)
Parameters
• close ([Link]) – dataset ‘Close’ column.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].daily_log_return(close, fillna=False)
Daily Log Return (DLR)
[Link]
Parameters
• close ([Link]) – dataset ‘Close’ column.
• fillna (bool) – if True, fill nan values.
Returns New feature generated.
Return type [Link]
[Link].daily_return(close, fillna=False)
Daily Return (DR)
Parameters
4.1. Documentation 27
Technical Analysis Library in Python Documentation, Release 0.1.4
28 Chapter 4. Contents
CHAPTER 5
• genindex
• modindex
• search
29
Technical Analysis Library in Python Documentation, Release 0.1.4
m
momentum, 9
o
others, 27
t
ta, 9
[Link], 9
[Link], 27
[Link], 20
[Link], 16
[Link], 13
trend, 20
v
volatility, 16
volume, 13
31
Technical Analysis Library in Python Documentation, Release 0.1.4
D M
macd() (in module [Link]), 25
daily_log_return() (in module [Link]), 27
macd_diff() (in module [Link]), 25
daily_return() (in module [Link]), 27
macd_signal() (in module [Link]), 25
donchian_channel_hband() (in module
mass_index() (in module [Link]), 26
[Link]), 18
momentum (module), 9
donchian_channel_hband_indicator() (in
money_flow_index() (in module [Link]), 10
module [Link]), 18
donchian_channel_lband() (in module
[Link]), 18
N
donchian_channel_lband_indicator() (in negative_volume_index() (in module [Link]),
module [Link]), 18 15
dpo() (in module [Link]), 23
O
E on_balance_volume() (in module [Link]), 15
ease_of_movement() (in module [Link]), 14 others (module), 27
33
Technical Analysis Library in Python Documentation, Release 0.1.4
P
put_call_ratio() (in module [Link]), 16
R
roc() (in module [Link]), 10
rsi() (in module [Link]), 11
S
stoch() (in module [Link]), 11
stoch_signal() (in module [Link]), 11
T
ta (module), 9
[Link] (module), 9
[Link] (module), 27
[Link] (module), 20
[Link] (module), 16
[Link] (module), 13
trend (module), 20
trix() (in module [Link]), 26
tsi() (in module [Link]), 12
U
uo() (in module [Link]), 12
V
volatility (module), 16
volume (module), 13
volume_price_trend() (in module [Link]), 16
vortex_indicator_neg() (in module [Link]), 26
vortex_indicator_pos() (in module [Link]), 27
W
wr() (in module [Link]), 13
34 Index









