#### Previous topic

fynance.features.metrics.z_score

#### Next topic

fynance.features.metrics.roll_annual_volatility

# fynance.features.metrics.roll_annual_return¶

fynance.features.metrics.roll_annual_return(X, period=252, w=None, axis=0, dtype=None, ddof=0)

Compute rolling compouned annual returns of each X’ series.

The annualised return  is the process of converting returns on a whole period to returns per year.

Parameters: X : np.ndarray[dtype, ndim=1 or 2] Time-series of price, performance or index. period : int, optional Number of period per year, default is 252 (trading days per year). w : int, optional Size of the lagged window of the rolling function, 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. ddof : int, optional Means Delta Degrees of Freedom, the divisor used in calculations is t - ddof, where t represents the number of elements in time axis. Default is 0. np.ndarray[dtype, ndim=1 or 2] Values of rolling compouned annual returns of each series.

Notes

The rolling annual compouned returns is computed such that $$\forall t \in [1: T]$$:

$annualReturn_t = \frac{X_t}{X_1}^{\frac{period}{t}} - 1$

References

Examples

Assume series of monthly prices:

>>> X = np.array([100, 110, 80, 120, 160, 108]).astype(np.float64)
>>> roll_annual_return(X, period=12)
array([ 0.        ,  0.771561  , -0.5904    ,  0.728     ,  2.08949828,
0.1664    ])
>>> X = np.array([[100, 101], [80, 81], [110, 108]]).astype(np.float64)
>>> roll_annual_return(X, period=12, axis=1)
array([[ 0.        ,  0.06152015],
[ 0.        ,  0.07738318],
[ 0.        , -0.10425081]])