qis.plot_brinson_attribution_table¶
- qis.plot_brinson_attribution_table(totals_table, active_total, grouped_allocation_return, grouped_selection_return, grouped_interaction_return, var_format='{:.0%}', total_column='Total Sum', is_exclude_interaction_term=True, axs=(None, None, None, None, None), **kwargs)[source]¶
Create comprehensive visualization of Brinson attribution results.
Generates a multi-panel visualization including: 1. Summary table with attribution statistics 2. Time series of cumulative total attribution effects 3. Time series of cumulative active effects by asset class when interaction is excluded 4. Time series of cumulative allocation effects by asset class 5. Time series of cumulative selection effects by asset class
When interaction is reported separately, panel 3 is omitted and panel 5 shows cumulative interaction effects instead.
- Parameters:
totals_table (DataFrame) – Summary statistics table from compute_brinson_attribution_table.
active_total (DataFrame) – Time series of total attribution effects.
grouped_allocation_return (DataFrame) – Allocation effects by asset class over time.
grouped_selection_return (DataFrame) – Selection effects by asset class over time.
grouped_interaction_return (DataFrame) – Interaction effects by asset class over time.
var_format (str) – Format string for displaying numeric values (default: percentage).
total_column (str) – Name of the total column for portfolio-level aggregation.
is_exclude_interaction_term (bool) – Whether interaction terms are assigned entirely to instrument selection instead of reported separately.
axs (List[Axes]) – Optional list of matplotlib axes for plotting (if None, creates new figures).
**kwargs – Additional arguments passed to plotting functions.
- Returns:
- (table_fig, active_fig, allocation_fig, selection_fig,
final_fig).
final_figis grouped active effects when interaction is excluded and interaction effects otherwise.
- Return type:
Tuple of matplotlib figures
Example
Attribute two daily-rebalanced synthetic portfolios. The constant weights are beginning-of-period weights, and P&L inputs are arithmetic return contributions.
>>> from qis.datasets import generate_synthetic_universe >>> universe = generate_synthetic_universe( ... start='2024-01-02', end='2024-03-28', apply_quirks=False) >>> prices = universe.prices[['SEQ_US', 'SBD_TSY']] >>> returns = qis.to_returns(prices, is_log_returns=False).dropna() >>> strategy_weights = pd.DataFrame( ... {'SEQ_US': 0.7, 'SBD_TSY': 0.3}, index=returns.index) >>> benchmark_weights = pd.DataFrame( ... {'SEQ_US': 0.6, 'SBD_TSY': 0.4}, index=returns.index) >>> results = compute_brinson_attribution_table( ... benchmark_pnl=returns * benchmark_weights, ... strategy_pnl=returns * strategy_weights, ... strategy_weights=strategy_weights, benchmark_weights=benchmark_weights, ... asset_class_data=universe.group_data, group_order=['Equities', 'Bonds'] ... ) >>> figs = plot_brinson_attribution_table(*results) >>> table_fig, active_fig, alloc_fig, select_fig, final_fig = figs >>> all(isinstance(fig, plt.Figure) for fig in figs) True >>> for fig in figs: ... plt.close(fig)