#### Previous topic

fynance.features.roll_functions.roll_min

Scale

# fynance.features.roll_functions.roll_max¶

fynance.features.roll_functions.roll_max(X, w=None, axis=0, dtype=None)

Compute simple rolling maximum of size w for each X’ series.

$roll\_max^w_t(X) = max(X_{t - w}, ..., X_t)$
Parameters: X : np.ndarray[dtype, ndim=1 or 2] Elements to compute the rolling maximum. w : int, optional Size of the lagged window of the rolling maximum, must be positive. If w is None or w=0, then w=X.shape[axis]. Default is None. 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. np.ndarray[dtype, ndim=1 or 2] Simple rolling maximum of each series.

Examples

>>> X = np.array([60, 100, 80, 120, 160, 80])
>>> roll_max(X, w=3, dtype=np.float64, axis=0)
array([ 60., 100., 100., 120., 160., 160.])
>>> X = np.array([[60, 60], [100, 100], [80, 80],
...               [120, 120], [160, 160], [80, 80]])
>>> roll_max(X, w=3, dtype=np.float64, axis=0)
array([[ 60.,  60.],
[100., 100.],
[100., 100.],
[120., 120.],
[160., 160.],
[160., 160.]])
>>> roll_max(X, w=3, dtype=np.float64, axis=1)
array([[ 60.,  60.],
[100., 100.],
[ 80.,  80.],
[120., 120.],
[160., 160.],
[ 80.,  80.]])