qis.compute_returns_transform¶
- qis.compute_returns_transform(returns, returns_transform=ReturnsTransform.ROLLING_RA_RETURNS, momentum_span=31, vol_span=33, rolling_ra_returns_span=31)[source]¶
apply the returns transform selected by
returns_transform.ROLLING_RA_RETURNScallscompute_rolling_ra_returns(span=rolling_ra_returns_span, weight_shift=1);EWMA_RETURNS_MOMENTUMcallscompute_ewm_ra_returns_momentum( momentum_span, vol_span, weight_shift=1).The defaults of this dispatcher,
momentum_span=31andvol_span=33, differ on purpose from those ofcompute_ewm_ra_returns_momentum(63 and 31): they make the two transforms comparable. An EWM of span 31 has mean age (31 - 1) / 2 = 15 rows, the same as the 31-row rolling window ofROLLING_RA_RETURNS, and span 33 gives the decay 1 - 2/34 = 0.941 of the RiskMetrics daily volatility (0.94). Pass the spans explicitly to reproduce the underlying function’s defaults.- Parameters:
returns (DataFrame) – periodic returns, one column per asset
returns_transform (ReturnsTransform) – the transform to apply
momentum_span (int) – EWM span of the momentum filter of
EWMA_RETURNS_MOMENTUMvol_span (int) – EWM span of the volatility normaliser of
EWMA_RETURNS_MOMENTUMrolling_ra_returns_span (int) – summation window, in rows, of
ROLLING_RA_RETURNS
- Returns:
the transformed returns, in the shape of
returns- Raises:
TypeError – for a
returns_transformthat is not implemented- Return type: