qis.ewm_xy_convolution¶
- qis.ewm_xy_convolution(returns, freq, signals=None, convolution_type=ConvolutionType.AUTO_CORR, signal_agg_type=SignalAggType.LAST_VALUE, is_ra_returns=False, estimates_smoothing_lambda=None, mean_adj_type=MeanAdjType.NONE, var_init_type=InitType.ZERO)[source]¶
EWM correlation or beta of rolling h-row returns with their own lag or with a signal.
The horizon h is
get_annualization_factor(freq)as an integer number of rows ofreturns, which are assumed daily: 252 for'B', 12 for'ME', 4 for'QE'. y is the rolling sum of the last h returns; x is y lagged by h rows (AUTO_CORR) or the signal lagged by h rows (SIGNAL_CORR,SIGNAL_BETA). The EWM decay is1 - 2 / (h + 1). When h is one the returns are not summed and the decay is 0.2.- Parameters:
returns (DataFrame) – returns, rows are dates and columns are assets
freq (str) – frequency whose annualisation factor sets the horizon h
signals (DataFrame) – signals aligned to
returns; required for the signal convolution typesconvolution_type (ConvolutionType) – what x is, and whether a correlation or a beta is returned
signal_agg_type (SignalAggType) – a signal enters at its last value or as its mean over h rows
is_ra_returns (bool) – divide returns by their EWM volatility (lambda 0.94) lagged one row first
estimates_smoothing_lambda (float) – if given, smooth the output with a further EWM of this decay
mean_adj_type (MeanAdjType) – mean removed from x and y before the moments; none by default
var_init_type (InitType) – seed of the EWM second moments of x and y. The default
InitType.ZEROis point in time, like the zero seed of the cross moment;InitType.MEANseeds them with full-sample means, which looks ahead
- Returns:
the EWM estimates, indexed like
returns; NaN until x and y are both available- Raises:
ValueError – if
freqdoes not give a whole number of rows of at least one, orconvolution_typeis not implemented- Return type: