fynance.features.indicators.hma¶
-
fynance.features.indicators.
hma
(X, w=21, kind='w', axis=0, dtype=None)¶ Compute the Hull Moving Average of size w for each X’ series’.
The Hull Moving Average, developed by A. Hull [3], is a financial indicator. It tries to reduce the lag in a moving average.
Parameters: - X : np.ndarray[dtype, ndim=1 or 2]
Elements to compute the indicator. If X is a two-dimensional array, then an indicator is computed for each series along axis.
- w : int, optional
Size of the main lagged window of the moving average, must be positive. If
w is None
orw=0
, thenw=X.shape[axis]
. Default is 21.- kind : {‘e’, ‘s’, ‘w’}
- axis : {0, 1}, optional
Axis along wich the computation is done. Default is 0.
- dtype : np.dtype, optional
The type of the output array. If dtype is not given, infer the data type from X input.
Returns: - np.ndarray[dtype, ndim=1 or 2]
Hull moving average of each series.
See also
Notes
Let \(ma^w\) the moving average function of lagged window size w.
\[hma^w_t(X) = ma^{\sqrt{w}}_t(2 \times ma^{\frac{w}{2}}_t(X)) - ma^w_t(X))\]References
[3] https://alanhull.com/hull-moving-average Examples
>>> X = np.array([60, 100, 80, 120, 160, 80]) >>> hma(X, w=3, dtype=np.float64) array([ 60. , 113.33333333, 76.66666667, 136.66666667, 186.66666667, 46.66666667])