qis.MultiPortfolioData¶
- class qis.MultiPortfolioData(portfolio_datas, benchmark_prices=None, covar_dict=None, navs=None)[source]¶
Bases:
objectseveral portfolios reported together, against a common benchmark.
The input to the multi-strategy and strategy-versus-benchmark factsheets. Each member keeps its own weights, costs and grouping; what this adds is the shared benchmark and the shared covariance, so cross-portfolio statistics are computed on one risk model rather than on each portfolio’s own.
- Variables:
portfolio_datas (List[qis.portfolio.portfolio_data.PortfolioData]) – the portfolios, in report order
benchmark_prices (pandas.DataFrame | pandas.Series) – benchmark panel shared by all members
covar_dict (Dict[pandas.Timestamp, pandas.DataFrame] | None) – annualised covariance matrix per date for the investable universe. Required for tracking error, which is a property of the pair rather than of either portfolio alone
navs (pandas.DataFrame) – navs of the members collected into one frame; computed in
__post_init__, not supplied
- Parameters:
- __init__(portfolio_datas, benchmark_prices=None, covar_dict=None, navs=None)¶
Methods
__init__(portfolio_datas[, ...])add_regime_shadows(ax, regime_benchmark[, ...])Shade the displayed date window using the benchmark at its native frequency.
compute_brinson_attribution([strategy_idx, ...])Compute native-period BHB effects, then aggregate increments for display.
compute_rolling_benchmark_alpha(benchmark_price)Compute annualised rolling alpha using the displayed lagged portfolio betas.
compute Ex ante tracking error = (strategy_weights - benchmark_weights) @ covar @ (strategy_weights - benchmark_weights).T
compute_tracking_error_table([strategy_idx, ...])Compute per-instrument performance, information ratio, turnover, and costs.
get_aligned_turnover([strategy_idx, ...])Grouped report using Series labels and optional static look-through fractions.
get_aligned_weights([strategy_idx, ...])Grouped report using Series labels and optional static look-through fractions.
get_benchmark_price(benchmark[, time_period])get_group_navs([portfolio_idx, benchmark, ...])Grouped report using Series labels and optional static look-through fractions.
get_grouped_weights([is_input_weights, ...])compute dictionary of ac weights each portfolio may have different group data and group order
get_navs([add_benchmarks_to_navs, ...])get portfolio navs double check that benchmark is not part of portfolio
get_ra_perf_table([benchmark, time_period, ...])get_sharpe_difference_table([...])Return paired HAC comparisons of all other portfolios with one base.
get_turnover([time_period, ...])plot_ac_ra_perf_table(benchmark_price[, ...])Grouped report using Series labels and optional static look-through fractions.
plot_brinson_attribution([strategy_idx, ...])Plot canonical Brinson effects; see compute_brinson_attribution for conventions.
plot_corr_table([time_period, freq, ...])plot_costs([cost_rolling_period, freq_cost, ...])plot_drawdowns([time_period, ...])plot_exposures([regime_benchmark, ...])plot_exposures_diff([portfolio_idx1, ...])Grouped report using Series labels and optional static look-through fractions.
plot_factor_betas(benchmark_prices[, ...])plot benchmarks betas by factor exposures
plot_group_exposures_and_pnl([...])report total exposures by portfolio
plot_instrument_pnl_diff([portfolio_idx1, ...])Grouped report using Series labels and optional static look-through fractions.
plot_nav([time_period, regime_benchmark, ...])plot_nav_with_dd([time_period, perf_params, axs])plot_performance_attribution([...])plot_performance_bars([time_period, ...])plot_periodic_returns([time_period, ...])plot_ra_perf_table([benchmark, ...])plot_regime_data(benchmark[, ...])Grouped report using Series labels and optional static look-through fractions.
plot_returns_scatter(benchmark[, ...])plot_rolling_benchmark_alpha(benchmark_price)Plot annualised rolling alpha using the adjacent panel's lagged betas.
plot_rolling_perf([rolling_perf_stat, ...])plot_rolling_time_under_water([time_period, ...])plot_sharpe_difference_table([...])Draw the HAC comparison table and return its figure and numeric DataFrame.
plot_tre_time_series([strategy_idx, ...])Grouped report using Series labels and optional static look-through fractions.
plot_turnover([regime_benchmark, ...])plot_weights_boxplot([strategy_idx, ...])Grouped report using Series labels and optional static look-through fractions.
set_benchmark_prices(benchmark_prices)set_navs([freq])Attributes
- portfolio_datas: List[PortfolioData]¶
- Parameters:
freq (str | None)
- Return type:
None
- set_benchmark_prices(benchmark_prices)[source]¶
- Parameters:
benchmark_prices (DataFrame)
- Return type:
None
get portfolio navs double check that benchmark is not part of portfolio
- Parameters:
add_benchmarks_to_navs (bool)
benchmark (str)
time_period (TimePeriod)
- Return type:
- get_benchmark_price(benchmark, time_period=None)[source]¶
- Parameters:
benchmark (str)
time_period (TimePeriod)
- Return type:
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
portfolio_idx (int)
benchmark (str)
time_period (TimePeriod)
is_add_group_total (bool)
- Return type:
- get_ra_perf_table(benchmark=None, time_period=None, drop_benchmark=False, is_convert_to_str=True, perf_params=PerfParams(freq='W-WED', freq_vol='W-WED', freq_skewness='ME', freq_drawdown='D', freq_reg='W-WED', freq_excess_return='W-WED', return_type=<ReturnTypes.LOG: 'Log'>, sharpe_convention=<SharpeConvention.PA: 1>, rates_data=None), perf_columns=(PerfStat.P.a. return, PerfStat.Vol, PerfStat.Sharpe (rf=0), PerfStat.Max DD, PerfStat.Skewness, PerfStat.An Alpha, PerfStat.Beta, PerfStat.R2, PerfStat.p-Alpha), **kwargs)[source]¶
- Parameters:
benchmark (str)
time_period (TimePeriod)
drop_benchmark (bool)
is_convert_to_str (bool)
perf_params (PerfParams)
- Return type:
- get_sharpe_difference_table(base_portfolio_id=0, time_period=None, freq='ME', af=None, n_lags=3, is_convert_to_str=False)[source]¶
Return paired HAC comparisons of all other portfolios with one base.
- Parameters:
base_portfolio_id (int) – Zero-based position of the base portfolio, omitted from rows.
time_period (TimePeriod | None) – NAV window; its first sampled NAV is the return baseline.
freq (str | None) – Return frequency; ME by default, None for the native NAV grid.
af (float | None) – Periods per year; required with freq=None, otherwise inferred from freq.
n_lags (int | None) – Bartlett HAC truncation; defaults to 3 retained return observations. Explicit None uses the automatic lag rule.
is_convert_to_str (bool) – Display floats to two decimals; False keeps numeric precision.
- Returns:
The compute_sharpe_difference_table DataFrame, on common complete return dates. Differences are portfolio minus base; no fees or cash adjustment are added.
- Return type:
- plot_sharpe_difference_table(base_portfolio_id=0, time_period=None, freq='ME', af=None, n_lags=3, ax=None, **kwargs)[source]¶
Draw the HAC comparison table and return its figure and numeric DataFrame.
- Parameters:
base_portfolio_id (int) – Zero-based base portfolio position, omitted from rows.
time_period (TimePeriod | None) – NAV window; its first sampled NAV is the return baseline.
freq (str | None) – Return frequency; ME by default, None for the native NAV grid.
af (float | None) – Periods per year; required with freq=None, otherwise inferred from freq.
n_lags (int | None) – Bartlett HAC truncation; defaults to 3 retained return observations. Explicit None uses the automatic lag rule.
ax (Axes | None) – Optional existing axes; then the returned figure is None.
**kwargs – Display settings for plot_df_table, including title.
- Returns:
(figure, numeric table), with floats displayed to two decimals.
- Return type:
- get_aligned_weights(strategy_idx=0, benchmark_idx=1, freq=None, is_input_weights=True, time_period=None, is_grouped=False, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
freq (str | None)
is_input_weights (bool)
time_period (TimePeriod)
is_grouped (bool)
- Return type:
- get_aligned_turnover(strategy_idx=0, benchmark_idx=1, turnover_rolling_period=260, freq_turnover='B', time_period=None, is_grouped=False, turnover_computation_type=None, is_unit_based_traded_volume=None, vols=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
turnover_rolling_period (int | None)
freq_turnover (str | None)
time_period (TimePeriod)
is_grouped (bool)
turnover_computation_type (TurnoverComputationType | None)
is_unit_based_traded_volume (bool | None)
vols (DataFrame | None)
- Return type:
- compute_tracking_error_implied_by_covar(strategy_idx=0, benchmark_idx=1, is_grouped=False, group_data=None, group_order=None, total_column='Total', *, lookthrough_matrix=None)[source]¶
compute Ex ante tracking error = (strategy_weights - benchmark_weights) @ covar @ (strategy_weights - benchmark_weights).T
Delegates the computation to
qis.portfolio.risk.risk_model.RiskModel.- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
is_grouped (bool)
total_column (str | None)
- Return type:
- compute_tracking_error_table(strategy_idx=0, benchmark_idx=1, freq='B', time_period=None, annualization_factor=260, is_unit_based_traded_volume=None, turnover_computation_type=None, vols=None, **kwargs)[source]¶
Compute per-instrument performance, information ratio, turnover, and costs.
The
IRcolumn is the per-instrument information ratio of P&L differences,mean(pnl_diff) / std(pnl_diff); it is not a tracking error. For realised tracking error from portfolio and benchmark NAVs usecompute_ewma_realised_tracking_error. For ex-ante tracking error from weights and a covariance usecompute_tracking_error_implied_by_covar.- Parameters:
strategy_idx (int) – Index of the strategy portfolio.
benchmark_idx (int) – Index of the benchmark portfolio.
freq (str | None) – Frequency of the attribution P&L tables.
time_period (TimePeriod) – Optional reporting period.
annualization_factor (float) – Scale applied to average turnover and costs.
turnover_computation_type (TurnoverComputationType | None) – Turnover convention; None uses each portfolio default.
vols (DataFrame | None) – Annualized volatility panel for volatility-normalized weight turnover.
is_unit_based_traded_volume (bool | None) – Whether costs use unit-based traded volume.
**kwargs – Reserved for compatibility with report callers.
- Returns:
Per-instrument table with the information ratio labelled
IR.- Return type:
- add_regime_shadows(ax, regime_benchmark, index=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>)[source]¶
Shade the displayed date window using the benchmark at its native frequency.
- Parameters:
ax (Axes)
regime_benchmark (str)
index (Index)
regime_classifier (BenchmarkReturnsQuantilesRegime)
- Return type:
None
- Parameters:
time_period (TimePeriod)
regime_benchmark (str)
perf_params (PerfParams)
regime_classifier (BenchmarkReturnsQuantilesRegime)
add_benchmarks_to_navs (bool)
ax (Axes)
- Return type:
None
- plot_rolling_perf(rolling_perf_stat=RollingPerfStat.SHARPE, regime_benchmark=None, time_period=None, sharpe_rolling_window=260, freq_sharpe=None, sharpe_title=None, legend_stats=LegendStats.AVG_LAST, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, add_benchmarks_to_navs=False, ax=None, **kwargs)[source]¶
- Parameters:
rolling_perf_stat (RollingPerfStat)
regime_benchmark (str)
time_period (TimePeriod)
sharpe_rolling_window (int)
freq_sharpe (str | None)
sharpe_title (str | None)
legend_stats (LegendStats)
regime_classifier (BenchmarkReturnsQuantilesRegime)
add_benchmarks_to_navs (bool)
ax (Axes)
- Return type:
- plot_periodic_returns(time_period=None, heatmap_freq='YE', date_format='%Y', transpose=True, add_benchmarks_to_navs=False, title=None, ax=None, **kwargs)[source]¶
- plot_performance_bars(time_period=None, perf_column=PerfStat.Sharpe (rf=0), perf_params=PerfParams(freq='W-WED', freq_vol='W-WED', freq_skewness='ME', freq_drawdown='D', freq_reg='W-WED', freq_excess_return='W-WED', return_type=<ReturnTypes.LOG: 'Log'>, sharpe_convention=<SharpeConvention.PA: 1>, rates_data=None), add_benchmarks_to_navs=False, title=None, ax=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
perf_column (PerfStat)
perf_params (PerfParams)
add_benchmarks_to_navs (bool)
title (str)
ax (Axes)
- Return type:
None
- plot_corr_table(time_period=None, freq='W-WED', add_benchmarks_to_navs=False, ax=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
freq (str)
add_benchmarks_to_navs (bool)
ax (Axes)
- Return type:
None
- plot_drawdowns(time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, regime_benchmark=None, dd_legend_type=DdLegendType.SIMPLE, add_benchmarks_to_navs=False, ax=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
regime_benchmark (str)
dd_legend_type (DdLegendType)
add_benchmarks_to_navs (bool)
ax (Axes)
- Return type:
None
- plot_rolling_time_under_water(time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, regime_benchmark=None, dd_legend_type=DdLegendType.SIMPLE, add_benchmarks_to_navs=False, ax=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
regime_benchmark (str)
dd_legend_type (DdLegendType)
add_benchmarks_to_navs (bool)
ax (Axes)
- Return type:
None
- plot_ra_perf_table(benchmark=None, drop_benchmark=False, add_benchmarks_to_navs=False, time_period=None, perf_params=PerfParams(freq='W-WED', freq_vol='W-WED', freq_skewness='ME', freq_drawdown='D', freq_reg='W-WED', freq_excess_return='W-WED', return_type=<ReturnTypes.LOG: 'Log'>, sharpe_convention=<SharpeConvention.PA: 1>, rates_data=None), perf_columns=(PerfStat.P.a. return, PerfStat.Vol, PerfStat.Sharpe (rf=0), PerfStat.Max DD, PerfStat.Skewness, PerfStat.An Alpha, PerfStat.Beta, PerfStat.R2, PerfStat.p-Alpha), strategy_idx=0, benchmark_idx=1, add_turnover=False, ax=None, **kwargs)[source]¶
- plot_ac_ra_perf_table(benchmark_price, add_benchmarks_to_navs=False, time_period=None, perf_params=PerfParams(freq='W-WED', freq_vol='W-WED', freq_skewness='ME', freq_drawdown='D', freq_reg='W-WED', freq_excess_return='W-WED', return_type=<ReturnTypes.LOG: 'Log'>, sharpe_convention=<SharpeConvention.PA: 1>, rates_data=None), perf_columns=(PerfStat.P.a. return, PerfStat.Vol, PerfStat.Sharpe (rf=0), PerfStat.Max DD, PerfStat.Skewness, PerfStat.An Alpha, PerfStat.Beta, PerfStat.R2, PerfStat.p-Alpha), is_grouped=True, ax=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
benchmark_price (Series)
add_benchmarks_to_navs (bool)
time_period (TimePeriod)
perf_params (PerfParams)
is_grouped (bool)
ax (Axes)
- Return type:
None
- Parameters:
time_period (TimePeriod)
perf_params (PerfParams)
- Return type:
None
- plot_exposures(regime_benchmark=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, time_period=None, var_format='{:.0%}', ax=None, **kwargs)[source]¶
- Parameters:
regime_benchmark (str)
regime_classifier (BenchmarkReturnsQuantilesRegime)
time_period (TimePeriod)
var_format (str)
ax (Axes)
- Return type:
None
- compute_rolling_benchmark_alpha(benchmark_price, freq_beta='B', factor_beta_span=260, time_period=None)[source]¶
Compute annualised rolling alpha using the displayed lagged portfolio betas.
- Parameters:
benchmark_price (Series) – Benchmark price index used by the adjacent beta panel.
freq_beta (str) – Return frequency used to estimate beta and realised alpha.
factor_beta_span (int) – Shared EWMA span for the beta and rolling-alpha estimates.
time_period (TimePeriod) – Performance measurement period. The first eligible return ends after its start and uses the previous period’s beta. Earlier prices can warm up beta.
- Returns:
Annualised rolling alpha for every portfolio in report order. Unobserved residuals are missing. The first eligible residual seeds each portfolio’s EWMA.
- Return type:
- plot_rolling_benchmark_alpha(benchmark_price, regime_benchmark=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, time_period=None, freq_beta='B', factor_beta_span=260, var_format='{:.1%}', ax=None, **kwargs)[source]¶
Plot annualised rolling alpha using the adjacent panel’s lagged betas.
- Parameters:
benchmark_price (Series)
regime_benchmark (str)
regime_classifier (BenchmarkReturnsQuantilesRegime)
time_period (TimePeriod)
freq_beta (str)
factor_beta_span (int)
var_format (str)
ax (Axes)
- Return type:
None
- plot_instrument_pnl_diff(portfolio_idx1=0, portfolio_idx2=1, is_grouped=True, regime_benchmark=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, time_period=None, var_format='{:.0%}', ax=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
portfolio_idx1 (int)
portfolio_idx2 (int)
is_grouped (bool)
regime_benchmark (str)
regime_classifier (BenchmarkReturnsQuantilesRegime)
time_period (TimePeriod)
var_format (str)
ax (Axes)
- Return type:
None
- plot_exposures_diff(portfolio_idx1=0, portfolio_idx2=1, regime_benchmark=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, time_period=None, var_format='{:.0%}', ax=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
portfolio_idx1 (int)
portfolio_idx2 (int)
regime_benchmark (str)
regime_classifier (BenchmarkReturnsQuantilesRegime)
time_period (TimePeriod)
var_format (str)
ax (Axes)
- Return type:
None
- get_turnover(time_period=None, turnover_rolling_period=12, freq_turnover='ME', is_unit_based_traded_volume=None, turnover_computation_type=None, vols=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
turnover_rolling_period (int | None)
freq_turnover (str | None)
is_unit_based_traded_volume (bool | None)
turnover_computation_type (TurnoverComputationType | None)
vols (DataFrame | None)
- plot_turnover(regime_benchmark=None, time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, turnover_rolling_period=260, freq_turnover='B', var_format='{:.0%}', is_unit_based_traded_volume=None, ax=None, turnover_computation_type=None, vols=None, **kwargs)[source]¶
- Parameters:
regime_benchmark (str)
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
turnover_rolling_period (int | None)
freq_turnover (str | None)
var_format (str)
is_unit_based_traded_volume (bool | None)
ax (Axes)
turnover_computation_type (TurnoverComputationType | None)
vols (DataFrame | None)
- Return type:
None
- plot_costs(cost_rolling_period=260, freq_cost='B', cost_title=None, regime_benchmark=None, time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, var_format='{:.2%}', is_unit_based_traded_volume=None, ax=None, **kwargs)[source]¶
- Parameters:
cost_rolling_period (int | None)
freq_cost (str | None)
cost_title (str | None)
regime_benchmark (str)
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
var_format (str)
is_unit_based_traded_volume (bool | None)
ax (Axes)
- Return type:
None
- plot_factor_betas(benchmark_prices, regime_benchmark=None, time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, freq_beta='B', factor_beta_span=260, var_format='{:, .2f}', axs=None, **kwargs)[source]¶
plot benchmarks betas by factor exposures
- Parameters:
benchmark_prices (DataFrame)
regime_benchmark (str)
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
freq_beta (str)
factor_beta_span (int)
var_format (str)
- Return type:
None
- plot_returns_scatter(benchmark, time_period=None, freq='QE', order=2, ax=None, **kwargs)[source]¶
- Parameters:
benchmark (str)
time_period (TimePeriod)
freq (str)
order (int)
ax (Axes)
- Return type:
None
- plot_performance_attribution(portfolio_ids=(0,), time_period=None, attribution_metric=AttributionMetric.PNL, ax=None, **kwargs)[source]¶
- Parameters:
time_period (TimePeriod)
attribution_metric (AttributionMetric)
ax (Axes)
- Return type:
None
- plot_performance_periodic_table(portfolio_id=0, time_period=None, freq='YE', ax=None, **kwargs)[source]¶
- Parameters:
portfolio_id (int)
time_period (TimePeriod)
freq (str)
ax (Axes)
- Return type:
None
- plot_regime_data(benchmark, add_benchmarks_to_navs=False, is_grouped=False, portfolio_idx=0, regime_data_to_plot=RegimeData.REGIME_SHARPE, time_period=None, var_format=None, is_conditional_sharpe=True, is_use_vbar=False, perf_params=PerfParams(freq='W-WED', freq_vol='W-WED', freq_skewness='ME', freq_drawdown='D', freq_reg='W-WED', freq_excess_return='W-WED', return_type=<ReturnTypes.LOG: 'Log'>, sharpe_convention=<SharpeConvention.PA: 1>, rates_data=None), regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, title=None, legend_loc='upper center', ax=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
benchmark (str)
add_benchmarks_to_navs (bool)
is_grouped (bool)
portfolio_idx (int)
regime_data_to_plot (RegimeData)
time_period (TimePeriod)
var_format (str | None)
is_conditional_sharpe (bool)
is_use_vbar (bool)
perf_params (PerfParams)
regime_classifier (BenchmarkReturnsQuantilesRegime)
title (str)
legend_loc (str | None)
ax (Axes)
- Return type:
None
- compute_brinson_attribution(strategy_idx=0, benchmark_idx=1, group_data=None, group_order=None, freq=None, total_column='Total Sum', time_period=None, is_exclude_interaction_term=True, *, is_linked=True, is_net=False, lookthrough_matrix=None)[source]¶
Compute native-period BHB effects, then aggregate increments for display.
The first shared NAV inside time_period is the baseline, not a return. Each contribution uses its preceding stored weight. Native return grids inside the common window must match; missing interior dates are not filled.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
strategy_idx (int) – Strategy position in portfolio_datas.
benchmark_idx (int) – Benchmark position in portfolio_datas.
group_data (Series | None) – Ordinary instrument labels as a Series. Defaults to the union of both portfolios’ labels, with strategy labels taking precedence.
group_order (List[str] | None) – Preferred group order; other observed groups are appended.
freq (str | None) – Display frequency; None retains native observations. Linking is performed before aggregation, preserving intra-period trades.
total_column (str) – Summary row and effect-series total label.
time_period (TimePeriod) – Requested NAV window; the first shared NAV is the baseline.
is_exclude_interaction_term (bool) – Merge interaction into selection when True.
is_linked (bool) – Frongello-linked increments by default; False gives arithmetic effects.
is_net (bool) – Deduct realised trading costs when True. Default gross instrument attribution excludes them. Neither mode attributes management fees, funding or other cash flows absent from instrument_pnl.
- Returns:
The five DataFrames from compute_brinson_attribution_table. Totals and native-observation mean weights do not depend on display frequency.
- Raises:
ValueError – If there is no common return interval or native dates do not match.
- Return type:
Tuple[DataFrame, DataFrame, DataFrame, DataFrame, DataFrame]
- plot_brinson_attribution(strategy_idx=0, benchmark_idx=1, freq=None, axs=(None, None, None, None, None), total_column='Total Sum', time_period=None, is_exclude_interaction_term=True, is_linked=True, is_net=False, group_data=None, group_order=None, *, lookthrough_matrix=None, **kwargs)[source]¶
Plot canonical Brinson effects; see compute_brinson_attribution for conventions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
freq (str | None)
total_column (str)
time_period (TimePeriod)
is_exclude_interaction_term (bool)
is_linked (bool)
is_net (bool)
- Return type:
- get_grouped_weights(is_input_weights=True, time_period=None, group_data=None, freq='W-WED', group_order=None, *, lookthrough_matrix=None)[source]¶
compute dictionary of ac weights each portfolio may have different group data and group order
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
is_input_weights (bool)
time_period (TimePeriod)
freq (str)
- Return type:
- plot_weights_boxplot(strategy_idx=0, benchmark_idx=1, freq='ME', time_period=None, is_grouped=False, ax=None, *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
freq (str | None)
time_period (TimePeriod)
is_grouped (bool)
ax (Axes)
- Return type:
None
- plot_group_exposures_and_pnl(regime_benchmark=None, time_period=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, total_name='Total', weights_freq='W-WED', figsize=(8.3, 11.7), *, group_data=None, lookthrough_matrix=None, **kwargs)[source]¶
report total exposures by portfolio
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series | None) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
regime_benchmark (str)
time_period (TimePeriod)
regime_classifier (BenchmarkReturnsQuantilesRegime)
total_name (str)
weights_freq (str | None)
- Return type:
- plot_tre_time_series(strategy_idx=0, benchmark_idx=1, is_grouped=False, group_data=None, group_order=None, regime_benchmark=None, regime_classifier=<qis.perfstats.regime_classifier.BenchmarkReturnsQuantilesRegime object>, time_period=None, title='Tracking error', total_column='Total', var_format='{:.2%}', tre_max_clip=None, ax=None, *, lookthrough_matrix=None, **kwargs)[source]¶
Grouped report using Series labels and optional static look-through fractions.
- Parameters:
lookthrough_matrix (DataFrame | None) – Optional static instrument-by-sleeve fractions. Supplied rows are finite, nonnegative and sum to one; omitted rows use group_data. None preserves categorical reporting. This is an accounting split.
group_data (Series) – Ordinary instrument labels as a Series; defaults to portfolio metadata where available. Fractional memberships belong in lookthrough_matrix.
strategy_idx (int)
benchmark_idx (int)
is_grouped (bool)
regime_benchmark (str)
regime_classifier (BenchmarkReturnsQuantilesRegime)
time_period (TimePeriod)
title (str | None)
total_column (str | None)
var_format (str)
tre_max_clip (float | None)
ax (Axes)
- Return type:
None