quantlab.risk.attribution.attribution_summary#

quantlab.risk.attribution.attribution_summary(attribution, bars_per_year, segment=None)[source]#

Summarize a run of bars (a segment) of factor_attribution’s dataset.

Parameters:
attributionxr.Dataset

factor_attribution’s dataset.

bars_per_yearfloat

Bars in a year, to annualize by: growth by bars_per_year / n over n bars, volatilities by its square root.

segmentnp.ndarray, optional

Booleans on timestamp: the bars of the segment; every bar when omitted.

Returns:
dict
  • annualized_log_return: each term’s, and total, their sum (the segment’s annualized NAV log growth); factor_annualized_log_return: each factor’s; group_annualized_log_return: each group’s (the groups the model has, in FACTOR_GROUPS order), summing to the factor term;

  • style_mean_exposure: each style factor’s mean net exposure, and industries: top and bottom (each at most TOP_INDUSTRIES, highest and lowest first, never the same industry twice) industries by annualized log growth, each a {"factor", "annualized_log_return", "mean_exposure"}, the means over the bars holding something;

  • ex_ante_risk: the means, over the bars with a forecast, of the annualized forecast volatility (volatility: total, factor, specific), of its x-sigma-rho split (contribution: factor and specific, summing to the total) and of each factor’s and group’s contribution;

  • ex_post_risk: the annualized realized volatility (volatility) and each term’s, factor’s and group’s cov(c, r) / sigma(r) contribution to it (the terms summing to it); None with fewer than two bars or a flat return;

  • coverage: mean_covered_weight and min_covered_weight over the bars holding something, and a note when the mean is below LOW_COVERAGE (else None).

A value without a bar to average over is None.

Examples

>>> summary = attribution_summary(attribution, bars_per_year=252)
>>> sorted(summary)
['annualized_log_return', 'coverage', 'ex_ante_risk', 'ex_post_risk',
 'factor_annualized_log_return', 'group_annualized_log_return', 'industries',
 'style_mean_exposure']