mintalib.functions
moduleCalculation 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
functionprice(prices, item: str = None)
Generic Price
Args:
avgprice
functionavgprice(prices)
Average Price
Value of (open + high + low + close) / 4
typprice
functiontypprice(prices)
Typical Price
Value of (high + low + close ) / 3
wclprice
functionwclprice(prices)
Weighted Close Price
Value of (high + low + 2 * close) / 4
midprice
functionmidprice(prices)
Mid Price
Value of (high + low) / 2
crossover
functioncrossover(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
functioncrossunder(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
functionflag(series, *, item: str = None)
Flag Value
Flag value of 1 for positive, 0 for zero or negative, and NaN otherwize
updown
functionupdown(series, up_level: float = 0.0, down_level: float = 0.0, *, item: str = None)
Flag for value crossing up & down levels
Args:
sign
functionsign(series, na_value: float = nan, *, item: str = None)
Sign
step
functionstep(series, threshold: float = 1.0, *, item: str = None)
Step Function
Limit value changes to threshold (in absolute value)
Args:
clag
functionclag(series, period: int = 1, *, item: str = None)
Confirmation Lag
Changes value only after a confirmation period
Args:
abs
functionabs(series, *, item: str = None)
Absolute Value
log
functionlog(series, *, item: str = None)
Logarithm
exp
functionexp(series, *, item: str = None)
Exponential
shift
functionshift(series, period: int, *, item: str = None)
Shift Function
Args:
diff
functiondiff(series, period: int = 1, *, item: str = None)
Difference
Difference between current value and the one offset by period
Args:
lag
functionlag(series, period: int, *, item: str = None)
Lag Function
Args:
min
functionmin(series, period: int, *, item: str = None)
Rolling Minimum
Args:
max
functionmax(series, period: int, *, item: str = None)
Rolling Maximum
sum
functionsum(series, period: int, *, item: str = None)
Rolling sum
Args:
roc
functionroc(series, period: int = 1, *, item: str = None)
Rate of Change
Args:
lroc
functionlroc(series, period: int = 1, *, item: str = None)
Logarithmic Rate of Change
Equivalent to the difference of log values
Args:
mad
functionmad(series, period: int = 14, *, item: str = None)
Rolling Mean Absolute Deviation
stdev
functionstdev(series, period: int = 20, *, item: str = None)
Standard Deviation
Args:
mav
functionmav(series, period: int = 20, *, ma_type: str = 'SMA', item: str = None)
Generic Moving Average
Moving average computed according to ma_type
Args:
sma
functionsma(series, period: int, *, item: str = None)
Simple Moving Average
Args:
ema
functionema(series, period: int, *, adjust: bool = False, item: str = None)
Exponential Moving Average
Args:
Formula:
rma
functionrma(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
functionwma(series, period: int, *, item: str = None)
Weighted Moving Average
Args:
hma
functionhma(series, period: int, *, item: str = None)
Hull Moving Average
Args:
dema
functiondema(series, period: int, *, item: str = None)
Double Exponential Moving Average
Args:
tema
functiontema(series, period: int = 20, *, item: str = None)
Triple Exponential Moving Average
Args:
alma
functionalma(series, period: int = 9, offset: float = 0.85, sigma: float = 6.0, *, item: str = None)
Arnaud Legoux Moving Average
rsi
functionrsi(series, period: int = 14, *, item: str = None)
Relative Strength Index
Args:
dmi
functiondmi(prices, period: int = 14)
Directional Movement Indicator
Args:
adx
functionadx(prices, period: int = 14)
Average Directional Index
Args:
pdi
functionpdi(prices, period: int = 14)
Plus Directional Index
Args:
mdi
functionmdi(prices, period: int = 14)
Minus Directional Index
Args:
trange
functiontrange(prices, *, log_prices: bool = False, percent: bool = False)
True Range
Args:
atr
functionatr(prices, period: int = 14)
Average True Range
Args:
natr
functionnatr(prices, period: int = 14)
Average True Range (normalized)
Args:
sar
functionsar(prices, afs: float = 0.02, maxaf: float = 0.2)
Parabolic Stop and Reverse
Args:
cci
functioncci(prices, period: int = 20)
Commodity Channel Index
Args:
cmf
functioncmf(prices, period: int = 20)
Chaikin Money Flow
Args:
mfi
functionmfi(prices, period: int = 14)
Money Flow Index
Args:
bop
functionbop(prices, period: int = 20)
Balance of Power
Args:
bbands
functionbbands(prices, period: int = 20, nbdev: float = 2.0)
Bollinger Bands
Args:
keltner
functionkeltner(prices, period: int = 20, nbatr: float = 2.0)
Keltner Channel
Args:
ker
functionker(series, period: int = 10, *, item: str = None)
Kaufman Efficiency Ratio
Args:
kama
functionkama(series, period: int = 10, fastn: int = 2, slown: int = 30, *, item: str = None)
Kaufman Adaptive Moving Average
Args:
macd
functionmacd(series, n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)
Moving Average Convergenge Divergence
Args:
Outputs:
ppo
functionppo(series, n1: int = 12, n2: int = 26, n3: int = 9, *, item: str = None)
Price Percentage Oscillator
Args:
Outputs:
slope
functionslope(series, period: int = 20, *, item: str = None)
Slope (linear regression)
Args:
rvalue
functionrvalue(series, period: int = 20, *, item: str = None)
R-Value (linear regression)
Args:
tsf
functiontsf(series, period: int = 20, offset: int = 0, *, item: str = None)
Time Series Forecast (linear regression)
Args:
curve
functioncurve(series, period: int = 20, *, item: str = None)
Curve (quadratic regression)
qsf
functionqsf(series, period: int = 20, offset: int = 0, *, item: str = None)
Quadratic Series Forecast (quadratic regression)
Args:
stoch
functionstoch(prices, period: int = 14, fastn: int = 3, slown: int = 3)
Stochastic Oscillator
Args:
streak
functionstreak(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
functioneval(prices, expr: str, *, as_flag: bool = False)
Expression Eval (pandas only)
Args: