mintalib.indicators
moduleFactory 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
indicatorPRICE(item: str = None)
Generic Price
Args:
AVGPRICE
indicatorAVGPRICE()
Average Price
Value of (open + high + low + close) / 4
TYPPRICE
indicatorTYPPRICE()
Typical Price
Value of (high + low + close ) / 3
WCLPRICE
indicatorWCLPRICE()
Weighted Close Price
Value of (high + low + 2 * close) / 4
MIDPRICE
indicatorMIDPRICE()
Mid Price
Value of (high + low) / 2
CROSSOVER
indicatorCROSSOVER(level: float = 0.0, *, item: str = None)
Cross Over
Yields a value of 1 at the point where series crosses over level
Args:
CROSSUNDER
indicatorCROSSUNDER(level: float = 0.0, *, item: str = None)
Cross Under
Yields a value of 1 at the point where series crosses under level
Args:
FLAG
indicatorFLAG(*, item: str = None)
Flag Value
Flag value of 1 for positive, 0 for zero or negative, and NaN otherwize
UPDOWN
indicatorUPDOWN(up_level: float = 0.0, down_level: float = 0.0, *, item: str = None)
Flag for value crossing up & down levels
Args:
SIGN
indicatorSIGN(na_value: float = nan, *, item: str = None)
Sign
STEP
indicatorSTEP(threshold: float = 1.0, *, item: str = None)
Step Function
Limit value changes to threshold (in absolute value)
Args:
CLAG
indicatorCLAG(period: int = 1, *, item: str = None)
Confirmation Lag
Changes value only after a confirmation period
Args:
ABS
indicatorABS(*, item: str = None)
Absolute Value
LOG
indicatorLOG(*, item: str = None)
Logarithm
EXP
indicatorEXP(*, item: str = None)
Exponential
SHIFT
indicatorSHIFT(period: int, *, item: str = None)
Shift Function
Args:
DIFF
indicatorDIFF(period: int = 1, *, item: str = None)
Difference
Difference between current value and the one offset by period
Args:
LAG
indicatorLAG(period: int, *, item: str = None)
Lag Function
Args:
MIN
indicatorMIN(period: int, *, item: str = None)
Rolling Minimum
Args:
MAX
indicatorMAX(period: int, *, item: str = None)
Rolling Maximum
SUM
indicatorSUM(period: int, *, item: str = None)
Rolling sum
Args:
ROC
indicatorROC(period: int = 1, *, item: str = None)
Rate of Change
Args:
LROC
indicatorLROC(period: int = 1, *, item: str = None)
Logarithmic Rate of Change
Equivalent to the difference of log values
Args:
MAD
indicatorMAD(period: int = 14, *, item: str = None)
Rolling Mean Absolute Deviation
STDEV
indicatorSTDEV(period: int = 20, *, item: str = None)
Standard Deviation
Args:
MAV
indicatorMAV(period: int = 20, *, ma_type: str = 'SMA', item: str = None)
Generic Moving Average
Moving average computed according to ma_type
Args:
SMA
indicatorSMA(period: int, *, item: str = None)
Simple Moving Average
Args:
EMA
indicatorEMA(period: int, *, adjust: bool = False, item: str = None)
Exponential Moving Average
Args:
Formula:
RMA
indicatorRMA(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
indicatorWMA(period: int, *, item: str = None)
Weighted Moving Average
Args:
HMA
indicatorHMA(period: int, *, item: str = None)
Hull Moving Average
Args:
DEMA
indicatorDEMA(period: int, *, item: str = None)
Double Exponential Moving Average
Args:
TEMA
indicatorTEMA(period: int = 20, *, item: str = None)
Triple Exponential Moving Average
Args:
ALMA
indicatorALMA(period: int = 9, offset: float = 0.85, sigma: float = 6.0, *, item: str = None)
Arnaud Legoux Moving Average
RSI
indicatorRSI(period: int = 14, *, item: str = None)
Relative Strength Index
Args:
DMI
indicatorDMI(period: int = 14)
Directional Movement Indicator
Args:
ADX
indicatorADX(period: int = 14)
Average Directional Index
Args:
PDI
indicatorPDI(period: int = 14)
Plus Directional Index
Args:
MDI
indicatorMDI(period: int = 14)
Minus Directional Index
Args:
TRANGE
indicatorTRANGE(*, log_prices: bool = False, percent: bool = False)
True Range
Args:
ATR
indicatorATR(period: int = 14)
Average True Range
Args:
NATR
indicatorNATR(period: int = 14)
Average True Range (normalized)
Args:
SAR
indicatorSAR(afs: float = 0.02, maxaf: float = 0.2)
Parabolic Stop and Reverse
Args:
CCI
indicatorCCI(period: int = 20)
Commodity Channel Index
Args:
CMF
indicatorCMF(period: int = 20)
Chaikin Money Flow
Args:
MFI
indicatorMFI(period: int = 14)
Money Flow Index
Args:
BOP
indicatorBOP(period: int = 20)
Balance of Power
Args:
BBANDS
indicatorBBANDS(period: int = 20, nbdev: float = 2.0)
Bollinger Bands
Args:
KELTNER
indicatorKELTNER(period: int = 20, nbatr: float = 2.0)
Keltner Channel
Args:
KER
indicatorKER(period: int = 10, *, item: str = None)
Kaufman Efficiency Ratio
Args:
KAMA
indicatorKAMA(period: int = 10, fastn: int = 2, slown: int = 30, *, item: str = None)
Kaufman Adaptive Moving Average
Args:
MACD
indicatorMACD(n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)
Moving Average Convergenge Divergence
Args:
Outputs:
PPO
indicatorPPO(n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)
Price Percentage Oscillator
Args:
Outputs:
SLOPE
indicatorSLOPE(period: int = 20, *, item: str = None)
Slope (linear regression)
Args:
RVALUE
indicatorRVALUE(period: int = 20, *, item: str = None)
R-Value (linear regression)
Args:
TSF
indicatorTSF(period: int = 20, offset: int = 0, *, item: str = None)
Time Series Forecast (linear regression)
Args:
CURVE
indicatorCURVE(period: int = 20, *, item: str = None)
Curve (quadratic regression)
QSF
indicatorQSF(period: int = 20, offset: int = 0, *, item: str = None)
Quadratic Series Forecast (quadratic regression)
Args:
STOCH
indicatorSTOCH(period: int = 14, fastn: int = 3, slown: int = 3)
Stochastic Oscillator
Args:
STREAK
indicatorSTREAK(*, 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
indicatorEVAL(expr: str, *, as_flag: bool = False)
Expression Eval (pandas only)
Args: