qis.compute_brinson_attribution_table

qis.compute_brinson_attribution_table(benchmark_pnl, strategy_pnl, strategy_weights, benchmark_weights, asset_class_data=None, group_order=None, total_column='Total Sum', is_exclude_interaction_term=True, strategy_name='Strategy', benchmark_name='Benchmark', *, is_linked=True, group_data=None, lookthrough_matrix=None)[source]

Compute BHB attribution from weighted arithmetic return contributions.

Divide each grouped contribution by its corresponding beginning-of-period weight before applying allocation and selection formulas. Interaction is the residual; by default it is included in selection. A zero-weight group has zero defined sector return, with any residual P&L retained in interaction.

Frongello linking is on by default: summing returned adjusted increments reproduces compounded strategy return minus compounded benchmark return at every date. Set is_linked=False for ordinary arithmetic period effects. The authoritative methodology is docs/brinson_attribution.md in the repository: https://github.com/ArturSepp/QuantInvestStrats/blob/main/docs/brinson_attribution.md.

Parameters:
  • benchmark_pnl (DataFrame) – Benchmark instrument arithmetic return contributions, not unweighted instrument returns or currency P&L; rows sum to benchmark returns.

  • strategy_pnl (DataFrame) – Strategy contributions on the same basis and return dates.

  • strategy_weights (DataFrame) – Beginning-of-period strategy weights corresponding to the P&L.

  • benchmark_weights (DataFrame) – Beginning-of-period benchmark weights corresponding to the P&L.

  • asset_class_data (Series | None) – Legacy alias for the ordinary group_data Series.

  • group_data (Series | None) – Ordinary instrument labels; must remain a Series.

  • lookthrough_matrix (DataFrame | None) – Static instrument-by-sleeve overrides. Supplied rows are finite, nonnegative and sum to one. Omitted rows use group_data. Fractions split BOTH weights and contributions, not separate underlying returns.

  • group_order (Sequence[str] | None) – Preferred group order; other observed groups are appended.

  • total_column (str) – Name reserved for the total row and effect-series total column.

  • is_exclude_interaction_term (bool) – Include interaction in selection when True.

  • strategy_name (str) – Strategy label in summary column headers. Matching strategy and benchmark labels are qualified by portfolio role.

  • benchmark_name (str) – Benchmark label in summary column headers. Matching strategy and benchmark labels are qualified by portfolio role.

  • is_linked (bool) – Link period effects to compounded active return when True.

Returns:

totals table, aggregate effect increments, grouped allocation increments, grouped selection increments and grouped interaction increments. Use cumsum() on increments for curves. Return Total columns are contributions to each portfolio’s compounded return; arithmetic mode uses Return Sum.

Return type:

Five DataFrames

Raises:

ValueError – For empty/mismatched/duplicate dates, duplicate instruments, missing classifications, infinite inputs, a conflicting total label, or a linked portfolio return at or below -100%.