quantlab.runs.backtest_attribution.excess_decomposition#
- quantlab.runs.backtest_attribution.excess_decomposition(strategy, gross, universe, benchmark, years)[source]#
Split the strategy’s annualised log growth over the benchmark into its three parts.
strategyis the value curve after costs,grossthe same weights simulated without costs (Nonewhen the engine cannot),universethe equal-weighted universe (rebalanced_group_valueswith one group) andbenchmarkthe benchmark’s (Nonewithout one). Each part is the difference of two curves’annualized_log_growth:universeis universe over benchmark,selectiongross over universe,costsstrategy over gross, andtotaltheir sum, the strategy over the benchmark. Without a benchmarkuniverseis left out andtotalis measured over the universe; withoutgrosscostsis left out andselectionis the strategy over the universe.- Parameters:
- strategy, universearray-like
Value curves on the window’s bars.
- gross, benchmarkarray-like or None
Value curves on the window’s bars, or
None.- yearsfloat
The window’s length in years.
- Returns:
- dict of str to float
universe(with a benchmark),selection,costs(withgross) andtotal.
Examples
>>> parts = excess_decomposition([1.0, 1.21], [1.0, 1.331], [1.0, 1.1], [1.0, 1.0], years=1.0) >>> {k: round(v, 4) for k, v in parts.items()} {'universe': 0.0953, 'selection': 0.1906, 'costs': -0.0953, 'total': 0.1906}