ic_decay

Defined in fynance.metrics

ic_decay(factor, prices, horizons=(1, 5, 10, 21), method='spearman')[source]

Information Coefficient decay across forward horizons.

Measures how quickly a factor’s predictive power fades as the prediction horizon lengthens. For each horizon h the mean per-bar cross-sectional IC is computed between the factor and the h-bar non-overlapping forward return from fynance.features.horizon_returns (non-overlapping so the labels do not share price moves and inflate the IC). A signal with real short-horizon edge shows a high IC at h = 1 that decays toward zero as h grows.

Alignment. factor[t] is aligned with the forward return starting at t; both share the same time index (the first axis of prices).

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

Factor panel (T, N).

pricesnp.ndarray[dtype, ndim=2]

Price panel (T, N) from which the forward returns are built; same time index as factor.

horizonstuple of int, optional

Forward horizons in bars (default (1, 5, 10, 21)). A horizon that is not shorter than T yields np.nan.

method{‘spearman’, ‘pearson’}, optional

Correlation used for the IC (default 'spearman').

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

Mean IC per horizon, shape (len(horizons),).

See also

fynance.features.horizon_returns, fynance.metrics.information_coefficient

Examples

A factor equal to the realized one-bar forward return is a perfect one-bar predictor, so its IC at horizon 1 is 1:

>>> import numpy as np
>>> rng = np.random.default_rng(0)
>>> prices = 100. * np.cumprod(1. + rng.normal(0., 0.01, (200, 5)), axis=0)
>>> fwd1 = prices[1:] / prices[:-1] - 1.
>>> factor = np.vstack([fwd1, np.full((1, 5), np.nan)])
>>> decay = ic_decay(factor, prices, horizons=(1, 5))
>>> bool(decay[0] > 0.99)
True