qis.compute_ewm_corr_df¶
- qis.compute_ewm_corr_df(df, corr_matrix_output=CorrMatrixOutput.FULL, span=None, ewm_lambda=0.94, init_value=None, init_type=InitType.ZERO)[source]¶
uncentred EWM correlation of every requested pair of columns, one column per pair.
Runs
S_t = lambda S_{t-1} + (1 - lambda) x_t x_t'on the rows ofdfwithout removing a mean, from the seedinit_value, and normalises each matrix to a correlation. With the default zero seed the first row is the sign ofx_i x_j, so the path needs a warm-up. For float32/float64 data, scalar smoothing and no explicit seed,TOP_ROWstores only the requested row’s history, while retaining the full current covariance for normalization. EligibleFULL/SUB_TOPcalls likewise retain only the returned lower-triangle history.- Parameters:
df (DataFrame) – returns, rows are dates and columns are assets
corr_matrix_output (CorrMatrixOutput) – which pairs are returned:
FULLgives (i, j) with j < i, named"<column i> - <column j>"; seeCorrMatrixOutputspan (int | ndarray) – if given, overrides
ewm_lambdavialambda = 1 - 2 / (span + 1)ewm_lambda (float) – EWM decay, used when
spanis Noneinit_value (ndarray) – seed matrix, shape (n, n). None uses
init_typeinit_type (InitType) – seed when
init_valueis None;InitType.ZEROandInitType.X0both give a zero matrix
- Returns:
the correlation paths, indexed like
df- Return type: