qis.plot_brinson_totals_table¶
- qis.plot_brinson_totals_table(totals_table, var_format='{:.0%}', ax=None, **kwargs)[source]¶
Create formatted table visualization of Brinson attribution summary.
Generates a professional-looking table with: - Color-coded sections for different data types - Edge lines separating logical groups - Formatted numeric values - Highlighted totals row
- Parameters:
totals_table (DataFrame) – Summary statistics DataFrame with attribution results.
var_format (str) – String format for numeric values (default: percentage format).
ax (Axes | None) – Optional matplotlib axis for plotting. If None, creates new figure.
**kwargs – Additional arguments passed to plot_df_table function.
- Returns:
matplotlib Figure object containing the formatted table.
- Return type:
Figure | None
Example
Compute a summary from synthetic arithmetic return contributions and beginning-of-period weights for two daily-rebalanced portfolios.
>>> 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) >>> totals_table, *_ = 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']) >>> fig = plot_brinson_totals_table(totals_table, var_format='{:.2%}') >>> isinstance(fig, plt.Figure) True >>> plt.close(fig)