mintalib

mintalib.indicators module

Factory functions for technical analysis indicators.

Indicator factory names are all upper case.

Indicators offer a composable interface where a calculation routine is bound together with its calculation parameters.

An indicator object is a callable that can be applied to prices or series data.

Indicators can be chained with the @ operator as in ROC(1) @ SMA(20).

The @ operator can also be used to apply an indicator to its parameter.

So for example SMA(50) @ prices can be used to compute the 50 period simple moving average on prices, instead of the more verbose SMA(50)(prices).

PRICE indicator

PRICE(item: str = None)

Generic Price

Args:

AVGPRICE indicator

AVGPRICE()

Average Price

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

TYPPRICE indicator

TYPPRICE()

Typical Price

Value of (high + low + close ) / 3

WCLPRICE indicator

WCLPRICE()

Weighted Close Price

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

MIDPRICE indicator

MIDPRICE()

Mid Price

Value of (high + low) / 2

CROSSOVER indicator

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

Cross Over

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

Args:

CROSSUNDER indicator

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

Cross Under

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

Args:

FLAG indicator

FLAG(*, item: str = None)

Flag Value

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

UPDOWN indicator

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

Flag for value crossing up & down levels

Args:

SIGN indicator

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

Sign

STEP indicator

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

Step Function

Limit value changes to threshold (in absolute value)

Args:

CLAG indicator

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

Confirmation Lag

Changes value only after a confirmation period

Args:

ABS indicator

ABS(*, item: str = None)

Absolute Value

LOG indicator

LOG(*, item: str = None)

Logarithm

EXP indicator

EXP(*, item: str = None)

Exponential

SHIFT indicator

SHIFT(period: int, *, item: str = None)

Shift Function

Args:

DIFF indicator

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

Difference

Difference between current value and the one offset by period

Args:

LAG indicator

LAG(period: int, *, item: str = None)

Lag Function

Args:

MIN indicator

MIN(period: int, *, item: str = None)

Rolling Minimum

Args:

MAX indicator

MAX(period: int, *, item: str = None)

Rolling Maximum

SUM indicator

SUM(period: int, *, item: str = None)

Rolling sum

Args:

ROC indicator

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

Rate of Change

Args:

LROC indicator

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

Logarithmic Rate of Change

Equivalent to the difference of log values

Args:

MAD indicator

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

Rolling Mean Absolute Deviation

STDEV indicator

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

Standard Deviation

Args:

MAV indicator

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

Generic Moving Average

Moving average computed according to ma_type

Args:

SMA indicator

SMA(period: int, *, item: str = None)

Simple Moving Average

Args:

EMA indicator

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

Exponential Moving Average

Args:

Formula:

RMA indicator

RMA(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 indicator

WMA(period: int, *, item: str = None)

Weighted Moving Average

Args:

HMA indicator

HMA(period: int, *, item: str = None)

Hull Moving Average

Args:

DEMA indicator

DEMA(period: int, *, item: str = None)

Double Exponential Moving Average

Args:

TEMA indicator

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

Triple Exponential Moving Average

Args:

ALMA indicator

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

Arnaud Legoux Moving Average

RSI indicator

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

Relative Strength Index

Args:

DMI indicator

DMI(period: int = 14)

Directional Movement Indicator

Args:

ADX indicator

ADX(period: int = 14)

Average Directional Index

Args:

PDI indicator

PDI(period: int = 14)

Plus Directional Index

Args:

MDI indicator

MDI(period: int = 14)

Minus Directional Index

Args:

TRANGE indicator

TRANGE(*, log_prices: bool = False, percent: bool = False)

True Range

Args:

ATR indicator

ATR(period: int = 14)

Average True Range

Args:

NATR indicator

NATR(period: int = 14)

Average True Range (normalized)

Args:

SAR indicator

SAR(afs: float = 0.02, maxaf: float = 0.2)

Parabolic Stop and Reverse

Args:

CCI indicator

CCI(period: int = 20)

Commodity Channel Index

Args:

CMF indicator

CMF(period: int = 20)

Chaikin Money Flow

Args:

MFI indicator

MFI(period: int = 14)

Money Flow Index

Args:

BOP indicator

BOP(period: int = 20)

Balance of Power

Args:

BBANDS indicator

BBANDS(period: int = 20, nbdev: float = 2.0)

Bollinger Bands

Args:

KELTNER indicator

KELTNER(period: int = 20, nbatr: float = 2.0)

Keltner Channel

Args:

KER indicator

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

Kaufman Efficiency Ratio

Args:

KAMA indicator

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

Kaufman Adaptive Moving Average

Args:

MACD indicator

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

Moving Average Convergenge Divergence

Args:

Outputs:

PPO indicator

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

Price Percentage Oscillator

Args:

Outputs:

SLOPE indicator

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

Slope (linear regression)

Args:

RVALUE indicator

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

R-Value (linear regression)

Args:

TSF indicator

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

Time Series Forecast (linear regression)

Args:

CURVE indicator

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

Curve (quadratic regression)

QSF indicator

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

Quadratic Series Forecast (quadratic regression)

Args:

STOCH indicator

STOCH(period: int = 14, fastn: int = 3, slown: int = 3)

Stochastic Oscillator

Args:

STREAK indicator

STREAK(*, 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 indicator

EVAL(expr: str, *, as_flag: bool = False)

Expression Eval (pandas only)

Args: