qis.compute_ra_perf_table_with_benchmark

qis.compute_ra_perf_table_with_benchmark(prices, benchmark=None, benchmark_price=None, perf_params=None, is_log_returns=False, drop_benchmark=False, **kwargs)[source]

Compute the risk-adjusted performance table augmented with alpha/beta to a benchmark.

Extends compute_ra_perf_table by regressing each asset’s returns on the benchmark and appending alpha (raw and annualised), beta, R² and the p-value of alpha.

Parameters:
  • prices (DataFrame) – DataFrame of asset price levels.

  • benchmark (str) – Non-empty benchmark column name. Optional if a named benchmark_price is supplied. The resolved name must occur at most once in prices.

  • benchmark_price (Series) – Stand-alone benchmark price Series. Optional if benchmark is in prices. Its name must be a non-empty string when benchmark is omitted. See resolve_benchmark_source for the three-way branching.

  • perf_params (PerfParams) – Performance parameter object. If None, it is PerfParams(freq=pd.infer_freq(prices.index)), which sets freq_reg as well as freq_vol to the inferred index frequency: a regular business-day index regresses daily returns (freq_reg='B'), not the quarterly PerfParams() default freq_reg='QE'; an irregular index falls back to the defaults.

  • is_log_returns (bool) – If True, compute log returns instead of arithmetic returns for the regression.

  • drop_benchmark (bool) – If True, exclude the benchmark row from the output table.

  • **kwargs – Reserved for forward compatibility; currently unused.

Returns:

DataFrame indexed by asset with all base RA metrics plus ALPHA, ALPHA_AN, BETA, R2 and ALPHA_PVALUE columns. Each regression uses only the asset and benchmark’s joint sampled observed support; another column’s later dates do not extend that sample.

Raises:

ValueError – If the benchmark source has no non-empty string label, the selected label is duplicated in prices, or no usable benchmark source is available.

Return type:

DataFrame