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 / novernbars, 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, andtotal, 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, inFACTOR_GROUPSorder), summing to the factor term;style_mean_exposure: each style factor’s mean net exposure, andindustries:topandbottom(each at mostTOP_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:factorandspecific, 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’scov(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_weightandmin_covered_weightover the bars holding something, and anotewhen the mean is belowLOW_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']