factor_rank_autocorr

Defined in fynance.metrics

factor_rank_autocorr(factor, lag=1)[source]

Cross-sectional rank autocorrelation of a factor (turnover proxy).

At each bar the Spearman (rank) correlation between the factor’s cross-section at t and at t - lag measures how much the ranking is preserved from one bar to the next. A value near 1 means a stable ranking (low turnover); a value near 0 means the ranking is reshuffled each bar (high turnover). It is the standard turnover proxy of a factor tear-sheet.

Parameters:
factornp.ndarray[dtype, ndim=2]

Factor panel (T, N).

lagint, optional

Lag in bars between the two cross-sections (default 1), a positive integer.

Returns:
np.ndarray[np.float64, ndim=1]

Rank autocorrelation per bar, shape (T,). The first lag entries are np.nan, as is any bar where either cross-section has fewer than three finite entries.

See also

fynance.metrics.information_coefficient

Examples

A factor whose ranking never changes has a rank autocorrelation of 1:

>>> import numpy as np
>>> factor = np.tile(np.arange(5.), (4, 1))
>>> ac = factor_rank_autocorr(factor, lag=1)
>>> float(ac[0])
nan
>>> bool(np.allclose(ac[1:], 1.0))
True