qis.compute_sharpe_difference_table¶
- qis.compute_sharpe_difference_table(multi_portfolio_data, base_portfolio_id=0, time_period=None, freq='ME', af=None, n_lags=3, is_convert_to_str=False)[source]¶
Compare every non-base portfolio with one base on a common return sample.
NAVs are sliced before return conversion: the first sampled NAV in the requested window is a baseline, not a return. Use the previous period’s closing NAV as the start to include the desired first return. Resampling uses QIS period-end conventions and excludes incomplete boundary periods. No stored NaN NAV is forward-filled. Returns are computed before complete rows across all portfolios are retained, so a missing NAV cannot create a return spanning multiple observations. HAC lags count retained rows.
- Parameters:
multi_portfolio_data (MultiPortfolioData) – Portfolios containing NAVs with unique portfolio names and a unique DatetimeIndex. External benchmark_prices are not included.
base_portfolio_id (int) – Zero-based position in portfolio_datas, also the NAV column order. The base is excluded from the output rows; differences are portfolio minus base.
time_period (TimePeriod | None) – Inclusive NAV window. None uses the full available history.
freq (str | None) – Return sampling frequency; default ME uses complete calendar month ends. None retains the native NAV grid and requires an explicit af.
af (float | None) – Periods per year. None uses QIS get_annualization_factor(freq), including 252 for B and 12 for ME. Pass 260 explicitly for the TF daily reporting convention.
n_lags (int | None) – Bartlett HAC truncation; defaults to 3 retained return observations. Explicit None uses sharpe_difference_test’s automatic lag rule.
is_convert_to_str (bool) – Format floats to two decimals and counts as integers for display. False preserves full numerical precision.
- Returns:
DataFrame in original portfolio order with Base Sharpe, Portfolio Sharpe, Sharpe difference, HAC SE, HAC z, p-value, Observations and HAC lags. Attributes record the base, sampling frequency, annualisation and first/last retained return dates. Sharpes use arithmetic simple returns and ddof=0. Costs and fees already embedded in NAVs are preserved; no extra fees or risk-free adjustment are applied. P-values are individual two-sided asymptotic normal tests, without multiple-testing correction.
- Raises:
ValueError – If the base, NAVs or sampling settings are invalid, fewer than 24 common returns remain, or any Sharpe comparison is undefined.
- Return type: