quantlab.runs.backtest_attribution#

Backtest attribution: where a strategy’s excess over its benchmark comes from.

A model backtest picks a few names from a universe and pays to trade them, so its excess over the benchmark has three parts:

  • universe: the universe held equally weighted against the benchmark, which the strategy earns or loses whatever it picks;

  • selection: the strategy before costs against that equal-weighted universe, what the scores and the portfolio rule add;

  • costs: the strategy after costs against before them.

The parts are differences of log growth, so they add up to the strategy’s log growth over the benchmark exactly. rebalanced_group_values gives the universe curve, and the curves of the universe cut into groups by score, which show where in the ranking the scores carry information. attribution_metrics assembles a run’s attribution block from an account record (quantlab.runs.run_metrics.AccountRecord), so both backtests report it the same way.

Functions

annualized_log_growth

Return a value curve's log growth from its first to its last value, per year.

attribution_metrics

Return an account's attribution block and its curves.

excess_decomposition

Split the strategy's annualised log growth over the benchmark into its three parts.

rebalanced_group_values

Return the value curves of the score groups, each held equally weighted between rebalances.