Moving Averages API Reference
Moving Averages Module
This module provides various moving average implementations for financial time series analysis. All functions use numpy arrays for input and output to ensure high performance.
alma(data, period=9, offset=0.85, sigma=6.0)
Arnaud Legoux Moving Average (ALMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
offset
|
float
|
Controls tradeoff between smoothness and responsiveness (0-1) |
0.85
|
sigma
|
float
|
Controls the filter width |
6.0
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Arnaud Legoux moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If offset is not between 0 and 1 If sigma is not positive |
ema(data, period=9, alpha=None)
Exponential Moving Average (EMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
alpha
|
float
|
Smoothing factor. If None, alpha = 2/(period+1) |
None
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Exponential moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
frama(data, period=9, fc_period=198)
Fractal Adaptive Moving Average (FRAMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
fc_period
|
int
|
Fractal cycle period |
198
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Fractal adaptive moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period or fc_period is not positive |
hma(data, period=9)
Hull Moving Average (HMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Hull moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
jma(data, period=9, phase=0)
Jurik Moving Average (JMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
phase
|
float
|
Phase parameter (-100 to 100) |
0
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Jurik moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If phase is not between -100 and 100 |
kama(data, period=9, fast_period=2, slow_period=30)
Kaufman Adaptive Moving Average (KAMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the efficiency ratio calculation |
9
|
fast_period
|
int
|
Fast EMA period |
2
|
slow_period
|
int
|
Slow EMA period |
30
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Kaufman adaptive moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If fast_period is not positive If slow_period is not positive If fast_period is not less than slow_period |
laguerre_filter(data, gamma=0.8)
Laguerre Filter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
gamma
|
float
|
Damping factor (0-1) |
0.8
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Laguerre filter values |
Raises:
Type | Description |
---|---|
ValueError
|
If gamma is not between 0 and 1 |
lsma(data, period=9)
Least Squares Moving Average (LSMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Least squares moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
mcginley_dynamic(data, period=9, k=0.6)
McGinley Dynamic Indicator
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
k
|
float
|
Adjustment factor |
0.6
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
McGinley dynamic indicator values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If k is not between 0 and 1 |
modular_filter(data, period=9, phase=0.5)
Modular Filter
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the filter |
9
|
phase
|
float
|
Phase parameter (0-1) |
0.5
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Modular filter values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If phase is not between 0 and 1 |
rdma(data)
Rex Dog Moving Average (RDMA)
This implementation follows the original RexDog definition, which is the average of six SMAs with periods 5, 9, 24, 50, 100, and 200.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Rex Dog moving average values |
sma(data, period=9)
Simple Moving Average (SMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Simple moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
smma(data, period=9)
Smoothed Moving Average (SMMA) or Running Moving Average (RMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Smoothed moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
t3(data, period=9, vfactor=0.7)
Tillson T3 Moving Average
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
vfactor
|
float
|
Volume factor (0-1) |
0.7
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
T3 moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If volume factor is not between 0 and 1 |
tma(data, period=9)
Triangular Moving Average (TMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Triangular moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
vama(data, volatility, period=9)
Volatility-Adjusted Moving Average (VAMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
volatility
|
ArrayLike
|
Volatility data corresponding to price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Volatility-adjusted moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If price and volatility arrays have different lengths |
vwma(data, volume, period=9)
Volume-Weighted Moving Average (VWMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
volume
|
ArrayLike
|
Volume data corresponding to price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Volume-weighted moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive If price and volume arrays have different lengths |
wma(data, period=9)
Weighted Moving Average (WMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Weighted moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |
zlma(data, period=9)
Zero-Lag Moving Average (ZLMA)
Parameters:
Name | Type | Description | Default |
---|---|---|---|
data
|
ArrayLike
|
Input price data |
required |
period
|
int
|
Window size for the moving average |
9
|
Returns:
Type | Description |
---|---|
NDArray[float64]
|
Zero-lag moving average values |
Raises:
Type | Description |
---|---|
ValueError
|
If period is not positive |