ic_summary¶
Defined in fynance.metrics
- ic_summary(pred, real, method='spearman')[source]
Summary statistics of the per-bar cross-sectional Information Coefficient.
Reduces a
(T, N)panel to the headline numbers of a factor tear-sheet. The per-bar cross-sectional IC (one value per bar, across theNassets) is computed withfynance.metrics.information_coefficient, then summarized.icir(the IC information ratio) andt_statgauge whether the mean IC is distinguishable from zero given its bar-to-bar variability.Alignment.
pred[t]is the score known attandreal[t]the outcome realized aftert.- Parameters:
- prednp.ndarray[dtype, ndim=2]
Factor/score panel
(T, N).- realnp.ndarray[dtype, ndim=2]
Aligned forward-return panel
(T, N).- method{‘spearman’, ‘pearson’}, optional
Correlation used for the IC (default
'spearman').
- Returns:
- dict of str to float
mean_ic(mean per-bar IC),icir(mean / std of the per-bar IC),t_stat(icir * sqrt(n_bars)),hit_rate(share of bars with a positive IC) andn_bars(number of bars with a finite IC).icirandt_statarenanwhen the IC has zero variance.
See also
fynance.metrics.information_coefficient,roll_information_coefficient
Notes
With \(IC_t\) the per-bar IC over the \(n\) bars with a finite value,
\[\mathrm{ICIR} = \frac{\overline{IC}}{\sigma_{IC}}, \qquad t = \mathrm{ICIR}\,\sqrt{n}\]where \(\sigma_{IC}\) is the sample standard deviation (
ddof=1).Examples
A factor equal to the realized outcome has a perfect per-bar IC:
>>> import numpy as np >>> rng = np.random.default_rng(1) >>> real = rng.normal(size=(100, 10)) >>> pred = real.copy() >>> s = ic_summary(pred, real) >>> round(s['mean_ic'], 6) 1.0 >>> round(s['hit_rate'], 2) 1.0 >>> s['n_bars'] 100