mintalib

mintalib.functions module

Calculation functions for technical analysis indicators.

The function names are all lower case and may conflict with standard functions, so the best way to use this module is to alias it to a short name like ta and access all functions as attributes.

The first parameter series or prices indicates whether the function accepts a single series or a prices dataframe.

Functions that accept a series usually have an optional parameter item to specify which column to use if the input is a dataframe.

All functions wrap their output to match the type of their input.

In particular the result of a function applied to a pandas series or dataframes will have the same index as the input.

price function

price(prices, item: str = None)

Generic Price

Args:

avgprice function

avgprice(prices)

Average Price

Value of (open + high + low + close) / 4

typprice function

typprice(prices)

Typical Price

Value of (high + low + close ) / 3

wclprice function

wclprice(prices)

Weighted Close Price

Value of (high + low + 2 * close) / 4

midprice function

midprice(prices)

Mid Price

Value of (high + low) / 2

crossover function

crossover(series, level: float = 0.0, *, item: str = None)

Cross Over

Yields a value of 1 at the point where series crosses over level

Args:

crossunder function

crossunder(series, level: float = 0.0, *, item: str = None)

Cross Under

Yields a value of 1 at the point where series crosses under level

Args:

flag function

flag(series, *, item: str = None)

Flag Value

Flag value of 1 for positive, 0 for zero or negative, and NaN otherwize

updown function

updown(series, up_level: float = 0.0, down_level: float = 0.0, *, item: str = None)

Flag for value crossing up & down levels

Args:

sign function

sign(series, na_value: float = nan, *, item: str = None)

Sign

step function

step(series, threshold: float = 1.0, *, item: str = None)

Step Function

Limit value changes to threshold (in absolute value)

Args:

clag function

clag(series, period: int = 1, *, item: str = None)

Confirmation Lag

Changes value only after a confirmation period

Args:

abs function

abs(series, *, item: str = None)

Absolute Value

log function

log(series, *, item: str = None)

Logarithm

exp function

exp(series, *, item: str = None)

Exponential

shift function

shift(series, period: int, *, item: str = None)

Shift Function

Args:

diff function

diff(series, period: int = 1, *, item: str = None)

Difference

Difference between current value and the one offset by period

Args:

lag function

lag(series, period: int, *, item: str = None)

Lag Function

Args:

min function

min(series, period: int, *, item: str = None)

Rolling Minimum

Args:

max function

max(series, period: int, *, item: str = None)

Rolling Maximum

sum function

sum(series, period: int, *, item: str = None)

Rolling sum

Args:

roc function

roc(series, period: int = 1, *, item: str = None)

Rate of Change

Args:

lroc function

lroc(series, period: int = 1, *, item: str = None)

Logarithmic Rate of Change

Equivalent to the difference of log values

Args:

mad function

mad(series, period: int = 14, *, item: str = None)

Rolling Mean Absolute Deviation

stdev function

stdev(series, period: int = 20, *, item: str = None)

Standard Deviation

Args:

mav function

mav(series, period: int = 20, *, ma_type: str = 'SMA', item: str = None)

Generic Moving Average

Moving average computed according to ma_type

Args:

sma function

sma(series, period: int, *, item: str = None)

Simple Moving Average

Args:

ema function

ema(series, period: int, *, adjust: bool = False, item: str = None)

Exponential Moving Average

Args:

Formula:

rma function

rma(series, period: int, *, item: str = None)

Rolling Moving Average (RSI style)

Exponential moving average with alpha = 2 / period, that starts as a simple moving average until number of bars is equal to period.

wma function

wma(series, period: int, *, item: str = None)

Weighted Moving Average

Args:

hma function

hma(series, period: int, *, item: str = None)

Hull Moving Average

Args:

dema function

dema(series, period: int, *, item: str = None)

Double Exponential Moving Average

Args:

tema function

tema(series, period: int = 20, *, item: str = None)

Triple Exponential Moving Average

Args:

alma function

alma(series, period: int = 9, offset: float = 0.85, sigma: float = 6.0, *, item: str = None)

Arnaud Legoux Moving Average

rsi function

rsi(series, period: int = 14, *, item: str = None)

Relative Strength Index

Args:

dmi function

dmi(prices, period: int = 14)

Directional Movement Indicator

Args:

adx function

adx(prices, period: int = 14)

Average Directional Index

Args:

pdi function

pdi(prices, period: int = 14)

Plus Directional Index

Args:

mdi function

mdi(prices, period: int = 14)

Minus Directional Index

Args:

trange function

trange(prices, *, log_prices: bool = False, percent: bool = False)

True Range

Args:

atr function

atr(prices, period: int = 14)

Average True Range

Args:

natr function

natr(prices, period: int = 14)

Average True Range (normalized)

Args:

sar function

sar(prices, afs: float = 0.02, maxaf: float = 0.2)

Parabolic Stop and Reverse

Args:

cci function

cci(prices, period: int = 20)

Commodity Channel Index

Args:

cmf function

cmf(prices, period: int = 20)

Chaikin Money Flow

Args:

mfi function

mfi(prices, period: int = 14)

Money Flow Index

Args:

bop function

bop(prices, period: int = 20)

Balance of Power

Args:

bbands function

bbands(prices, period: int = 20, nbdev: float = 2.0)

Bollinger Bands

Args:

keltner function

keltner(prices, period: int = 20, nbatr: float = 2.0)

Keltner Channel

Args:

ker function

ker(series, period: int = 10, *, item: str = None)

Kaufman Efficiency Ratio

Args:

kama function

kama(series, period: int = 10, fastn: int = 2, slown: int = 30, *, item: str = None)

Kaufman Adaptive Moving Average

Args:

macd function

macd(series, n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)

Moving Average Convergenge Divergence

Args:

Outputs:

ppo function

ppo(series, n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)

Price Percentage Oscillator

Args:

Outputs:

slope function

slope(series, period: int = 20, *, item: str = None)

Slope (linear regression)

Args:

rvalue function

rvalue(series, period: int = 20, *, item: str = None)

R-Value (linear regression)

Args:

tsf function

tsf(series, period: int = 20, offset: int = 0, *, item: str = None)

Time Series Forecast (linear regression)

Args:

curve function

curve(series, period: int = 20, *, item: str = None)

Curve (quadratic regression)

qsf function

qsf(series, period: int = 20, offset: int = 0, *, item: str = None)

Quadratic Series Forecast (quadratic regression)

Args:

stoch function

stoch(prices, period: int = 14, fastn: int = 3, slown: int = 3)

Stochastic Oscillator

Args:

streak function

streak(series, *, item: str = None)

Consecutive streak of ups or downs

Length of streak of values all up or down, times +1 or -1 whether ups or downs.

eval function

eval(prices, expr: str, *, as_flag: bool = False)

Expression Eval (pandas only)

Args: