The performance-statistic catalogue¶
Author: Artur Sepp / First recorded: 2026-09-25
Implemented in qis — Quantitative Investment Strategies. Software citation: CITATION.cff.
A performance statistic in qis is a column of a table indexed by asset, and each column is named
by a member of qis.PerfStat. This chapter defines all 61 members: the formula the code
computes, the grid on which its inputs are sampled, the return basis, and the units. Where a
published measure such as the Sortino ratio, the Calmar ratio or sample skewness is defined
differently in the literature, the chapter states the implemented definition and the difference.
Overview¶
Four functions produce the columns:
qis.compute_ra_perf_tablebuilds the risk-adjusted table: dates, counts, total and per-annum returns, the Sharpe family, volatility, downside volatility, Sortino, Calmar, drawdowns, skewness, kurtosis and extreme returns.qis.compute_desc_tableandqis.compute_desc_freq_tabledescribe any panel: mean, standard deviation, t-statistic, quantiles, share of positive values, last value and its rank, and a normality test.qis.compute_ra_perf_table_with_benchmarkadds the regression columns: alpha, annualised alpha, beta, \(R^2\) and the p-value of alpha.The regime classifiers, through
qis.compute_bnb_regimes_pa_perf_table, add the bear, normal and bull columns.
One object, qis.PerfParams, assigns a sampling grid to each group of statistics. That design
gives the reader three things to watch. A single table mixes grids: by default the maximum
drawdown is daily while the volatility it is divided by is monthly. Visible return columns use
each asset’s native first and last observations, while ratio numerators use complete sampling
boundaries. And calling compute_ra_perf_table without perf_params infers the grid from the
index, so a single missing row can change the reported volatility.
This chapter defines each column compactly. The Sharpe columns are treated in depth in the Sharpe-ratio chapter, drawdown episodes in Drawdowns and time under water, the regression columns in Alpha, beta and benchmark-relative performance, and the regime columns in Regime-conditional performance.
Inputs, notation, and assumptions¶
Convention |
This article |
|---|---|
Return basis |
Simple returns for total, per-annum, arithmetic and extreme-return columns; |
Sampling grid |
Native observations for visible return columns; |
Annualisation |
\(\mathrm{af}\) inferred from the sampled |
Mean adjustment |
|
Timing |
Full-sample and descriptive: every column uses the whole history, so none is point in time; cash accrued over \((t-1,t]\) uses the rate known at \(t-1\) on the return grid |
Output units |
Decimal fractions for returns, volatilities and drawdowns; dimensionless ratios, moments and p-values; dates, prices, counts and years where labelled |
qis default |
|
Symbol or input |
Meaning |
Units and convention |
|---|---|---|
\(t_0\), \(t_1\) |
First and last native observation of an asset |
Each asset’s own support |
\(b_0\), \(b_1\) |
First and last complete |
Partial periods at both ends are excluded |
\(Y\), \(Y_{\mathrm{smp}}\) |
Elapsed years from \(t_0\) to \(t_1\), and from \(b_0\) to \(b_1\) |
Calendar days divided by 365.25 |
\(\mathrm{TR}\), \(R_{\mathrm{pa}}\), \(\tilde R_{\mathrm{pa}}\) |
Native total, per-annum and excess per-annum return |
Decimal |
\(R^{\mathrm{smp}}_{\mathrm{pa}}\), \(\tilde R^{\mathrm{smp}}_{\mathrm{pa}}\) |
Per-annum and excess per-annum return from \(b_0\) to \(b_1\) |
Decimal; the ratio numerators |
\(v_k\) |
|
Log returns by default |
\(r_k\), \(\tilde r_k\) |
|
Decimal per period |
\(r^{\mathrm{dd}}_t\) |
Simple returns on the |
Daily by default |
\(x_k\) |
A generic sample: |
Units of the input |
\(T\) |
Number of observations of the sample at hand; |
Count |
\(\mathrm{af}\), \(\mathrm{af}_{\mathrm{reg}}\), \(\mathrm{af}_{\mathrm{c}}\) |
Periods per year of |
12 for |
\(\sigma_v\) |
|
Annualised decimal |
\(T_{-}\), \(\bar v_{-}\) |
Number and mean of the negative \(v_k\) |
Count; decimal per period |
\(\sigma^{-}\) |
|
Annualised decimal |
\(\theta\), \(\delta_{\theta}\) |
Minimum acceptable return; target downside deviation |
Decimal per period; annualised decimal |
\(m_j\) |
\(j\)-th central sample moment with divisor \(T\) |
Units of \(x\) to the power \(j\) |
\(g_1\), \(g_2\); \(G_1\), \(G_2\) |
Uncorrected and bias-corrected skewness and excess kurtosis |
Dimensionless |
\(\mathrm{MDD}\) |
|
Decimal, at most zero |
\(K^2\) |
D’Agostino–Pearson omnibus normality statistic |
\(\chi^2_2\) under normality |
\(\hat q_p\) |
Empirical \(p\)-quantile with linear interpolation |
Units of \(x\) |
\(y_t\), \(d_t\) |
Annual cash rate from |
Decimal per year; date |
\(\omega\), \(p_{\omega}\) |
Benchmark regime (bear, normal, bull) and its share of periods |
Label; fraction |
\(R^2\) |
Coefficient of determination of the benchmark regression |
Fraction |
Inputs are a pandas.DataFrame (or, for compute_ra_perf_table, a pandas.Series) of positive
prices with a sorted DatetimeIndex. Each column is evaluated on its own support: leading
missing values are dropped, interior gaps are forward-filled by the sampling, and no column is
extended beyond its own last observation because another column continues. All statistics are
full-sample and descriptive. A table computed on a whole history uses information that was not
available at earlier dates, so it describes a history and must not be used inside a backtest.
Methodology¶
The PerfParams contract¶
qis.PerfParams is a dataclass with nine fields. The table lists each field with its default in
qis.PerfParams(), the functions that read it, and the columns it governs.
Field |
Default |
Read by |
Governs |
|---|---|---|---|
|
|
Factsheet panels only, not the table functions |
A shortcut that overwrites the fields below |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
No calculation; stored, printed and copied |
Nothing: excess returns are formed on the grid of the column that uses them |
|
|
|
The basis of \(v_k\) and \(x_k\): |
|
|
Regime tables only |
|
|
|
Performance, risk and benchmark tables |
Every excess column, the Sortino and Calmar numerators, and excess regressions |
Definition (the freq shortcut). PerfParams(freq=f) sets freq_vol, freq_reg and
freq_excess_return to f. It sets freq_drawdown to f only when freq_drawdown is empty,
which it is not by default, and it never sets freq_skewness. Two consequences follow.
PerfParams(freq='QE') computes volatility on quarters but skewness on months, and
PerfParams(freq='ME') moves the benchmark regression from the default quarterly grid to the
monthly one.
return_type accepts the five qis.ReturnTypes members, but only LOG and RELATIVE are
meaningful for a price table. It does not affect the arithmetic Sharpe family, which always uses
simple returns, nor WORST, BEST and the drawdowns, which always use levels or simple returns.
Under RELATIVE the column labelled AvgLogReturn holds the mean simple return.
Definition (native endpoints and sampled boundaries). For an asset observed from \(t_0\) to
\(t_1\), the sampled support is the set of complete freq_vol boundaries inside \([t_0,t_1]\): the
first boundary \(b_0\) on or after \(t_0\) and the last boundary \(b_1\) on or before \(t_1\), each
carrying the last available price. The visible return columns TOTAL_RETURN, NAV1,
NUM_YEARS, PA_RETURN, PA_EXCESS_RETURN, AN_LOG_RETURN and AN_LOG_EXCESS_RETURN, and the
date and price columns, use the native endpoints \(t_0\) and \(t_1\). The ratio numerators of
SHARPE_RF0, SHARPE_EXCESS, SHARPE_LOG_AN, SHARPE_LOG_EXCESS and SORTINO_RATIO use the
sampled boundaries \(b_0\) and \(b_1\), the same support as their volatility denominators. The
numerator of CALMAR_RATIO uses the native endpoints, for the same reason: its denominator,
MAX_DD, is measured on the freq_drawdown grid up to the asset’s final observation \(t_1\),
not between complete freq_vol boundaries.
Consequently, PA_RETURN divided by VOL need not reproduce SHARPE_RF0. The two agree only
when \(t_0\) and \(t_1\) fall on the freq_vol grid. In the worked example below the history starts
on 2 January, the first month-end boundary is 31 January, and the two quotients differ by 16%.
Pitfall
compute_ra_perf_table(prices) without perf_params builds
PerfParams(freq=pd.infer_freq(prices.index)). A regular business-day index is inferred as
B, so VOL becomes a daily volatility annualised with \(\sqrt{252}\), NUM_OBS counts days and
the regression grid becomes daily, while skewness stays monthly and drawdowns daily. Remove a
single holiday row and pd.infer_freq returns None, the defaults apply, and VOL is monthly
again. An index with fewer than three dates raises ValueError. compute_risk_table and
compute_performance_table fall back to PerfParams() without inference, and
get_ra_perf_columns and compute_ra_perf_table_with_benchmark inherit the inference. Always
pass an explicit PerfParams.
The catalogue¶
The four tables below list every PerfStat member. The label is PerfStat.X.to_str(), the
string used as the column name. The grid and basis column uses these words: native for the
asset’s own observations, freq_vol, freq_drawdown, freq_skewness and freq_reg for the
PerfParams grids, simple and excess for simple and cash-excess returns, and
return_type for the basis selected by PerfParams.return_type.
Risk-adjusted table: compute_ra_perf_table¶
|
Label |
Formula |
Grid and basis |
Units |
|---|---|---|---|---|
|
|
\(t_0\) |
native |
date |
|
|
\(t_1\) |
native |
date |
|
|
\(P_{t_0}\) |
native |
price |
|
|
\(P_{t_1}\) |
native |
price |
|
|
\(T\), complete boundaries minus one |
|
count |
|
|
\(\mathrm{TR}=P_{t_1}/P_{t_0}-1\) |
native, simple |
decimal |
|
|
\(1+\mathrm{TR}\) |
native, simple |
wealth per unit |
|
|
\(Y=(t_1-t_0)/365.25\) |
native |
years |
|
|
\(R_{\mathrm{pa}}=(1+\mathrm{TR})^{1/Y}-1\) if \(Y>1\), else \(\mathrm{TR}\) |
native, simple |
decimal p.a. |
|
|
\(\tilde R_{\mathrm{pa}}\): \(R_{\mathrm{pa}}\) of \(\prod(1+\tilde r_t)\) |
native, excess |
decimal p.a. |
|
|
\(\log(1+R_{\mathrm{pa}})\) |
native |
decimal p.a. |
|
|
\(\log(1+\tilde R_{\mathrm{pa}})\) |
native, excess |
decimal p.a. |
|
|
\(\bar v\) |
|
decimal per period |
|
|
\(\bar r\) |
|
decimal per period |
|
|
\(\bar{\tilde r}\) |
|
decimal per period |
|
|
\(\mathrm{af}\,\bar r\) |
|
decimal p.a. |
|
|
\(\mathrm{af}\,\bar{\tilde r}\) |
|
decimal p.a. |
|
|
\(R^{\mathrm{smp}}_{\mathrm{pa}}/\sigma_v\) |
|
ratio |
|
|
\(\tilde R^{\mathrm{smp}}_{\mathrm{pa}}/\sigma_v\) |
|
ratio |
|
|
\(\log(1+R^{\mathrm{smp}}_{\mathrm{pa}})/\sigma_v\) |
|
ratio |
|
|
\(\log(1+\tilde R^{\mathrm{smp}}_{\mathrm{pa}})/\sigma_v\) |
|
ratio |
|
|
\(\sqrt{\mathrm{af}}\,\bar r/s(r)\) |
|
ratio |
|
|
\(\sqrt{\mathrm{af}}\,\bar{\tilde r}/s(\tilde r)\) |
|
ratio |
|
|
\(\sigma_v=\sqrt{\mathrm{af}}\,s(v)\) |
|
decimal p.a. |
|
|
\(\sigma^{-}=\sqrt{\mathrm{af}}\,s(v\mid v<0)\); missing if \(T_{-}<2\) |
|
decimal p.a. |
|
|
\(\tilde R^{\mathrm{smp}}_{\mathrm{pa}}/\sigma^{-}\); missing unless \(\sigma^{-}>0\) |
|
ratio |
|
|
\(\tilde R_{\mathrm{pa}}/\lvert\mathrm{MDD}\rvert\); missing if \(\mathrm{MDD}=0\) |
native numerator, |
ratio |
|
|
\(\mathrm{MDD}=\min_t D_t\) |
|
decimal, at most 0 |
|
|
\(D_{t_1}\), at the last observation |
|
decimal, at most 0 |
|
|
\(\mathrm{MDD}/\sigma_v\); missing unless \(\sigma_v>0\) |
|
ratio |
|
|
\(G_1\); missing if \(T\le 2\) |
|
dimensionless |
|
|
\(G_2\) (excess); missing if \(T\le 3\) |
|
dimensionless |
|
|
\(\min_t r^{\mathrm{dd}}_t\) |
|
decimal per period |
|
|
\(\max_t r^{\mathrm{dd}}_t\) |
|
decimal per period |
Descriptive tables: compute_desc_table and compute_desc_freq_table¶
Here \(x_1,\ldots,x_T\) are the observed values of one column of whatever panel is supplied; no
resampling or annualisation happens unless requested. compute_desc_table returns formatted
strings; compute_desc_freq_table returns numbers.
|
Label |
Formula |
Grid and basis |
Units |
|---|---|---|---|---|
|
|
\(\bar x\) |
supplied |
units of \(x\) |
|
|
\(s(x)\) |
supplied |
units of \(x\) |
|
|
\(\sqrt{\mathrm{af}}\,s(x)\), \(\mathrm{af}\) inferred from the index |
supplied |
units of \(x\) p.a. |
|
|
\(\bar x\,\sqrt{T}/s(x)\) |
supplied |
dimensionless |
|
|
\(\hat q_{0.5}\) |
supplied |
units of \(x\) |
|
|
\(\min_k x_k\) |
supplied |
units of \(x\) |
|
|
\(\max_k x_k\) |
supplied |
units of \(x\) |
|
|
\(\hat q_{0.16}\) |
supplied |
units of \(x\) |
|
|
\(\hat q_{0.84}\) |
supplied |
units of \(x\) |
|
|
\(\#\{x_k>0\}/T\) |
supplied |
fraction |
|
|
\(x_T\) |
supplied |
units of \(x\) |
|
|
\((\#\{x_k<x_T\}+\#\{x_k\le x_T\}+1)/(2T)\) |
supplied |
fraction |
|
|
\(P(\chi^2_2>K^2)=e^{-K^2/2}\); needs \(T\ge 20\) |
supplied |
probability |
The descriptive table also reports skewness and kurtosis, as the uncorrected \(g_1\) and \(g_2\),
under the short labels Skew and Kurt taken from PerfStat.SKEWNESS and PerfStat.KURTOSIS.
Benchmark table: compute_ra_perf_table_with_benchmark¶
The regression is \(r_{i,k}=\alpha+\beta\,r_{b,k}+\varepsilon_k\) of asset \(i\) on benchmark \(b\),
fitted by ordinary least squares on their joint freq_reg support.
|
Label |
Formula |
Grid and basis |
Units |
|---|---|---|---|---|
|
|
\(\hat\alpha\) |
|
decimal per period |
|
|
\(\mathrm{af}_{\mathrm{reg}}\,\hat\alpha\) |
|
decimal p.a. |
|
|
\(\hat\beta\) |
|
dimensionless |
|
|
\(R^2\) |
|
fraction |
|
|
Two-sided OLS t-test p-value of \(\hat\alpha\); 1 for the benchmark row |
|
probability |
Regime table: compute_bnb_regimes_pa_perf_table¶
The classifier buckets benchmark returns on its own grid (default QE, simple returns) at the
16% and 84% quantiles into bear, normal and bull periods. \(\bar r_{\mid\omega}\) is the mean
periodic return of the asset in regime \(\omega\).
|
Label |
Formula |
Grid and basis |
Units |
|---|---|---|---|---|
|
|
\(\bar r_{\mid\omega}\) |
classifier grid, simple |
decimal per period |
|
|
\(e^{\mathrm{af}_{\mathrm{c}}\,p_{\omega}\,\bar r_{\mid\omega}}-1\), shifted pro rata to sum to \(R_{\mathrm{pa}}\) |
classifier grid |
decimal p.a. |
|
|
regime p.a. over \(\sigma_v\) under |
classifier grid, |
ratio |
Return, date and count columns¶
The date, price and count columns are read off the data. NUM_OBS counts the returns on the
freq_vol grid, which is the number of complete boundaries minus one; it is not the number of
native observations.
Definition (per-annum and excess per-annum return). With \(Y\) elapsed years,
With a cash series, the per-period cash return is \(r^{f}_t=y_{t-1}\,(d_t-d_{t-1})/365\). Here
\(y_{t-1}\) is the latest rates_data quote dated on or before \(d_{t-1}\), whatever the calendar of
the rate series: the rate known at the start of the period. A daily rate series applied to
month-end returns charges each month the previous month-end quote, and the first return date
accrues nothing. The excess
per-annum return compounds \(\tilde r_t=r_t-r^{f}_t\) and applies the same rule:
\(\tilde R_{\mathrm{pa}}=\big(\prod_t(1+\tilde r_t)\big)^{1/Y}-1\) for \(Y>1\). Without a cash series
every excess column equals its zero-rate counterpart. The log columns are
\(\log(1+R_{\mathrm{pa}})\) and \(\log(1+\tilde R_{\mathrm{pa}})\), which equal the annualised mean
log return by the identity in Notation and conventions. The
derivation of excess returns and NAVs is in
Returns, NAVs, excess returns, fees and leverage.
The arithmetic columns are periodic means of simple returns on the freq_vol grid, and their
AN_ versions multiply by \(\mathrm{af}\). They sit above the compound columns by roughly half the
annualised variance.
The Sharpe columns¶
Six columns report three conventions, each with and without cash. Four of them divide a
compound numerator on the sampled boundaries by the table volatility \(\sigma_v\); the arithmetic
pair divides the mean simple return by its own standard deviation, so numerator and denominator
share one series. PerfParams.sharpe_convention does not change any of the six; it selects the
convention of the regime Sharpe columns. The formulas are in the catalogue; the estimators, their
sampling error and the reconciliation of the three conventions follow
Sharpe (1994) and are treated in the
Sharpe-ratio chapter.
Volatility and downside risk¶
Definition (volatility). VOL is \(\sigma_v=\sqrt{\mathrm{af}}\,s(v)\): the sample standard
deviation of the freq_vol returns in the return_type basis, with ddof=1, annualised with
the factor inferred from the sampled index.
Definition (downside volatility as implemented). Let \(\mathcal{N}=\{k: v_k<0\}\) index the \(T_{-}\) negative returns and \(\bar v_{-}\) their mean. Then
With fewer than two negative returns the sample standard deviation is undefined, and
DOWNSIDE_VOL is missing. This is the standard deviation of the losses about their own mean.
The downside risk of Sortino and van der Meer (1991) and the target downside deviation of
Sortino and Price (1994) measure something else: shortfall below a minimum acceptable return
\(\theta\), averaged over all observations. Its sample analogue, in the form given by Bacon (2008),
is
Proposition (what the implemented downside volatility leaves out). For \(\theta=0\),
Proof. Only negative returns contribute to \(\delta_0\). Split their second moment about zero into dispersion and level: \(\sum_{k\in\mathcal{N}}v_k^2=\sum_{k\in\mathcal{N}}(v_k-\bar v_{-})^2+T_{-}\bar v_{-}^2 =(T_{-}-1)(\sigma^{-})^2/\mathrm{af}+T_{-}\bar v_{-}^2\). Divide by \(T\) and multiply by \(\mathrm{af}\). \(\square\)
The implemented \(\sigma^{-}\) keeps the first term, rescaled, and drops the second: it ignores how large the losses are on average and how often they occur. A strategy that loses exactly 1% in every down month has \(\sigma^{-}=0\). In the worked example the dropped level term is 69% of \(\delta_0^2\) for the equity asset.
Definition (Sortino ratio as implemented). SORTINO_RATIO is
\(\tilde R^{\mathrm{smp}}_{\mathrm{pa}}/\sigma^{-}\): the sampled excess per-annum return over the
implemented downside volatility. Sortino and Price (1994) define the ratio as the excess of the
return over \(\theta\) divided by \(\delta_{\theta}\), so that numerator and denominator refer to the
same target. In qis the numerator is in excess of cash, while the denominator uses a zero
threshold on total returns in the return_type basis, centred on the mean loss.
Two degenerate cases are reported as missing values, because both ratios are undefined rather
than extreme. A history with fewer than two negative freq_vol returns has no \(\sigma^{-}\), so
DOWNSIDE_VOL and SORTINO_RATIO are missing; a positive \(\sigma^{-}\) is required for the ratio.
A NAV that never falls has \(\mathrm{MDD}=0\), so CALMAR_RATIO is missing. Earlier versions of qis
reported a zero downside volatility with an infinite Sortino ratio, and a Calmar ratio of minus
infinity for a positive return, the wrong sign as well as undefined.
Drawdowns and the Calmar ratio¶
The drawdown on the freq_drawdown grid is \(D_t=P_t/\max_{t'\le t}P_{t'}-1\). The grid is the
complete freq_drawdown boundaries followed by the asset’s final observation \(t_1\) when that
falls between boundaries, so a coarse grid keeps a trailing incomplete period. MAX_DD is the
minimum of \(D_t\) over the full history, CURRENT_DD its value at \(t_1\), and MAX_DD_VOL is
\(\mathrm{MDD}/\sigma_v\), missing when \(\sigma_v\) is missing (a single sampled return) or zero.
Episodes, durations and time under water are in
Drawdowns and time under water.
Proposition (sub-sampling cannot deepen the maximum drawdown). Let grid \(G'\) observe a subset of the prices observed on grid \(G\). Then \(\mathrm{MDD}_{G'}\ge\mathrm{MDD}_{G}\).
Proof. \(\mathrm{MDD}_G=\min\{P_t/P_{t'}-1: t'\le t,\ t,t'\in G\}\), because the running peak is the maximum over earlier prices. Restricting the minimum to pairs in \(G'\) can only raise it. \(\square\)
Month-end prices are forward-filled daily prices, so the monthly drawdown is never deeper than
the daily one, and a business-day history re-sampled to calendar days (D) has the same drawdown
as on business days. The final observation that the drawdown grid appends is itself a daily
price, so the proposition still applies, and on a coarse grid both paths end on the same date:
CURRENT_DD then satisfies the same inequality. The proposition matters because of the default
grids.
Pitfall
With PerfParams() the numerator of MAX_DD_VOL is a daily maximum drawdown and
its denominator a monthly volatility. The column mixes a daily path statistic with a monthly
risk scale and, by the proposition, is never shallower than the monthly-grid ratio. In the
worked example the bond asset reports −1.96, against −1.70 with a monthly drawdown. WORST and
BEST also come from the drawdown grid: by default they are the worst and best day, not
month. Pass freq_drawdown equal to freq_vol when a single-grid table is required.
Insight
MAX_DD_VOL is not free of the horizon. For a driftless Brownian motion in log
price, the expected maximum drawdown over \(Y\) years is \(\sqrt{\pi/2}\,\sigma\sqrt{Y}\)
(Magdon-Ismail et al., 2004), so the ratio grows in
magnitude like \(1.25\sqrt{Y}\). Compare it only across histories of equal length.
Definition (Calmar ratio as implemented). CALMAR_RATIO is
\(\tilde R_{\mathrm{pa}}/\lvert\mathrm{MDD}\rvert\): the native excess per-annum return over the
full-history maximum drawdown on the freq_drawdown grid, and missing when \(\mathrm{MDD}=0\).
Numerator and denominator both run to the asset’s final observation. Young (1991) defines the
ratio on a trailing 36-month window: the compound annual return over the window divided by the
maximum drawdown within it, conventionally measured on month-end NAVs. The qis column differs in
three ways. Its window is the full history, which can only deepen the drawdown; its drawdown is
daily by default, which by the proposition above can only deepen it further; and its numerator is
in excess of cash when rates_data is given. A full-history Calmar ratio is therefore smaller in
magnitude than a 36-month one on the same fund, and the two are not interchangeable.
Higher moments and extreme returns¶
For a sample \(x_1,\ldots,x_T\) let \(m_j=T^{-1}\sum_k(x_k-\bar x)^j\). The uncorrected skewness and excess kurtosis are \(g_1=m_3/m_2^{3/2}\) and \(g_2=m_4/m_2^2-3\).
Identity (bias-corrected moments). The adjusted Fisher–Pearson skewness \(G_1\) and the bias-corrected excess kurtosis \(G_2\) compared by Joanes and Gill (1998) are
Proof. \(G_1=k_3/k_2^{3/2}\) and \(G_2=k_4/k_2^2\) in terms of the k-statistics \(k_2=Tm_2/(T-1)\), \(k_3=T^2m_3/\big((T-1)(T-2)\big)\) and \(k_4=T^2\big[(T+1)m_4-3(T-1)m_2^2\big]/\big((T-1)(T-2)(T-3)\big)\). Substituting, \(G_1=g_1\,T^2(T-1)^{3/2}/\big((T-1)(T-2)\,T^{3/2}\big)\), which simplifies to the stated form. For \(G_2\), dividing \(k_4\) by \(k_2^2=T^2m_2^2/(T-1)^2\) gives \((T-1)\big[(T+1)(g_2+3)-3(T-1)\big]/\big((T-2)(T-3)\big)\), and \((T+1)(g_2+3)-3(T-1)=(T+1)g_2+6\). \(\square\)
SKEWNESS and KURTOSIS in the risk table are \(G_1\) and \(G_2\), computed by
scipy.stats.skew and scipy.stats.kurtosis with bias=False on the freq_skewness returns in
the return_type basis. They are missing for \(T\le 2\) and \(T\le 3\) respectively. The descriptive
table (Skew, Kurt) and the rolling skewness of qis.compute_rolling_perf_stat with
RollingPerfStat.SKEW use SciPy’s default bias=True, that is \(g_1\) and \(g_2\). At \(T=143\) the
correction multiplies \(g_1\) by 1.011; on a 36-month rolling window it multiplies it by 1.044, so a
rolling value and a table value of the same window differ by 4% before any sampling error.
Insight
The correction is small next to the sampling error. Under normality the standard errors of \(G_1\) and \(G_2\) are close to \(\sqrt{6/T}\) and \(\sqrt{24/T}\): 0.20 and 0.41 for twelve years of months. The worked example’s skewness of 0.29 and excess kurtosis of −0.29 come from Gaussian paths, and neither is distinguishable from zero.
WORST and BEST are the minimum and maximum simple returns \(r^{\mathrm{dd}}_t\) on the freq_drawdown grid.
When that grid is calendar days and the input is business days, weekend rows carry forward-filled
prices and zero returns, so WORST is at most zero and BEST at least zero.
Descriptive-table columns¶
compute_desc_table works on whatever it is given, typically a panel of returns on one grid. It
drops missing values per column, rejects infinite values, and formats every number as a string.
AVG is the mean, STD the sample standard deviation with ddof=1, and STD_AN replaces STD
when annualize_vol=True, scaling by \(\sqrt{\mathrm{af}}\) with \(\mathrm{af}\) inferred from the
index (252 with a warning on an irregular index). MEDIAN, QUANT_M_1STD and QUANT_P1_STD are
the 50%, 16% and 84% empirical quantiles with NumPy’s linear interpolation; the labels -1std and
+1std recall that these are the one-sigma quantiles of a normal distribution. POSITIVE counts
zeros as non-positive and excludes missing values from the denominator. LAST is the last
observed value and RANK its percentile rank within the column, computed by
scipy.stats.percentileofscore with kind='rank'.
Definition (t-statistic). T_STAT is \(\bar x\,\sqrt{T}/s(x)\), missing when \(T<2\) or
\(s(x)=0\). It is not annualised and does not depend on annualize_vol.
Identity (t-statistic and arithmetic Sharpe). If \(x_k=r_k\) are the simple freq_vol
returns, then T_STAT equals SHARPE_ARITH times \(\sqrt{T/\mathrm{af}}\), which is close to
\(\sqrt{Y_{\mathrm{smp}}}\).
Proof. SHARPE_ARITH is \(\sqrt{\mathrm{af}}\,\bar r/s(r)\); multiply by
\(\sqrt{T/\mathrm{af}}\). On a regular grid \(T/\mathrm{af}\) is the sampled number of years. \(\square\)
A Sharpe ratio of 0.5 therefore needs 16 years of data to reach a t-statistic of 2, before any correction for serial correlation.
Definition (normality test). NORMTEST is the p-value of the omnibus test of
D’Agostino and Pearson (1973), computed by scipy.stats.normaltest. The statistic
\(K^2=Z_1^2+Z_2^2\) adds the squared normalised skewness and kurtosis statistics of
scipy.stats.skewtest and scipy.stats.kurtosistest, and is \(\chi^2_2\) under normality. qis
requires at least 20 observations, the size from which SciPy documents the kurtosis test as valid
(SciPy itself returns a value from 8 observations), and prints the p-value with the four decimals
of the member’s ValueType.FLOAT4 under the label P-val, so a p-value of 0.004 is not shown as
0.00.
Identity (p-value of a two-degree chi-square). \(P(\chi^2_2>K^2)=e^{-K^2/2}\).
Proof. The \(\chi^2_2\) density is \(\tfrac12e^{-z/2}\) on \(z\ge 0\); integrate from \(K^2\) to infinity. \(\square\)
compute_desc_freq_table(df, freq='YE', agg_func=np.sum) first aggregates each column to one
value per period with agg_func, drops periods with any missing value, and reports AVG, STD,
-1std, Median and +1std of the period values as numbers. With simple returns the default sum
is not the compounded period return; pass log returns, whose sum is the period log return, or a
compounding agg_func.
Benchmark and regime columns¶
The benchmark table regresses each asset on the benchmark by ordinary least squares on the
freq_reg grid, with simple returns by default (log returns with is_log_returns=True) and
excess returns for both sides when rates_data is given. ALPHA is the periodic intercept of
Jensen (1968), ALPHA_AN multiplies it linearly by \(\mathrm{af}_{\mathrm{reg}}\), and
ALPHA_PVALUE is the conventional two-sided p-value of the OLS t-test, which assumes serially
uncorrelated, homoskedastic residuals. The benchmark’s own row has its p-value set to 1. Tracking
error, information ratio and robust inference are in
Alpha, beta and benchmark-relative performance.
The regime columns condition on benchmark regimes. Under the default SharpeConvention.PA the
regime Sharpe is the adjusted regime per-annum return divided by \(\sigma_v\); under
ARITHMETIC and LOG it is \(\mathrm{af}_{\mathrm{c}}\,p_{\omega}\) times the conditional mean,
divided by the annualised standard deviation of the same returns, which adds up exactly to the
Sharpe ratio of that convention on the classifier’s grid. No convention deducts cash. The regime
table labels its average columns Bear Average, Normal Average and Bull Average, and every
regime member’s label is a column of that table, so PerfStat.BEAR_AVG selects Bear Average
(its label was Bear Avg before, which selected nothing). The decomposition is in
Regime-conditional performance.
Worked example¶
The example uses the frozen synthetic universe with its reporting quirks disabled, so the two
assets are clean Gaussian paths: SEQ_US, an equity with 17% volatility, and SBD_TSY, a
government bond with 6%. The sample runs from 2 January 2014 to 31 December 2025: 3,130 business
days, 144 month-end boundaries from 31 January 2014, and \(T=143\) monthly returns. Cash is a flat
1% a year quoted from the business day before the first price. Every checked number is
recomputed with NumPy or SciPy from the month-end or daily prices.
Statistic |
|
|
Independent calculation |
|---|---|---|---|
|
17.10% |
5.59% |
\(\sqrt{12}\,s(\ell)\) of 143 month-end log returns |
|
8.85% |
2.97% |
74 and 63 negative months |
Target downside deviation \(\delta_0\) |
11.33% |
3.20% |
Not a qis column |
\(\tilde R^{\mathrm{smp}}_{\mathrm{pa}}\) |
0.50% |
2.81% |
Month-end excess NAV over 11.92 years |
|
0.056 |
0.946 |
Ratio of the two lines above |
|
0.287 |
0.244 |
\(g_1\) = 0.284 and 0.241 |
|
−0.288 |
0.285 |
\(g_2\) = −0.320 and 0.234 |
|
−46.37% |
−10.95% |
Daily running peak |
|
0.0064 |
0.270 |
Native excess p.a. of 0.29% and 2.96% |
|
48.3% |
55.9% |
Share of positive simple returns |
|
0.59 |
2.41 |
|
|
0.2843 |
0.3387 |
\(K^2\) of 2.52 and 2.17 |
The first block recomputes the risk-table columns. It also shows the native-endpoint rule: the
visible PA_RETURN of SEQ_US is 1.30% from 2 January, while the numerator of SHARPE_RF0 is
1.51% from 31 January, so PA_RETURN over VOL gives 0.076 against a reported 0.088.
import numpy as np
import pandas as pd
from scipy import stats
import qis
from qis.datasets import generate_synthetic_universe
universe = generate_synthetic_universe(start='2014-01-02', end='2025-12-31', seed=20260725,
apply_quirks=False)
prices = universe.prices[['SEQ_US', 'SBD_TSY']]
cash = pd.Series(0.01, index=pd.bdate_range('2013-12-31', '2025-12-31'), name='cash')
params = qis.PerfParams(freq='ME', freq_drawdown='D', return_type=qis.ReturnTypes.LOG,
rates_data=cash)
table = qis.compute_ra_perf_table(prices=prices, perf_params=params)
Stat = qis.PerfStat
def column(stat: qis.PerfStat) -> pd.Series:
"""One statistic for both assets, selected by its PerfStat label."""
return table[stat.to_str()]
# Independent inputs: complete month-end boundaries, their returns and the cash accrual.
month_end = prices.resample('ME').last()
log_m = np.log(month_end).diff().dropna()
simple_m = month_end.pct_change().dropna()
T, af = len(log_m), 12.0
years_smp = (month_end.index[-1] - month_end.index[0]).days / 365.25
accrual_m = 0.01 * month_end.index.to_series().diff().dt.days.iloc[1:].to_numpy() / 365.0
pa_smp = (month_end.iloc[-1] / month_end.iloc[0]) ** (1.0 / years_smp) - 1.0
pa_excess_smp = (1.0 + simple_m.sub(accrual_m, axis=0)).prod() ** (1.0 / years_smp) - 1.0
assert T == 143 and (column(Stat.NUM_OBS) == T).all()
# Native endpoints for visible returns, sampled boundaries for ratio numerators.
vol = np.sqrt(af) * log_m.std(ddof=1)
np.testing.assert_allclose(column(Stat.VOL), vol, rtol=1e-12)
np.testing.assert_allclose(column(Stat.SHARPE_RF0) * vol, pa_smp, rtol=1e-10)
np.testing.assert_allclose(pa_smp['SEQ_US'], 0.0151, atol=5e-5)
np.testing.assert_allclose(column(Stat.PA_RETURN)['SEQ_US'], 0.0130, atol=5e-5)
np.testing.assert_allclose(column(Stat.PA_RETURN)['SEQ_US'] / vol['SEQ_US'], 0.076, atol=5e-4)
# Downside volatility: standard deviation of the losses about their own mean.
down_vol = log_m.apply(lambda x: np.sqrt(af) * x[x < 0.0].std(ddof=1))
np.testing.assert_allclose(column(Stat.DOWNSIDE_VOL), down_vol, rtol=1e-12)
np.testing.assert_allclose(column(Stat.SORTINO_RATIO), pa_excess_smp / down_vol, rtol=1e-10)
np.testing.assert_allclose(vol, [0.1710, 0.0559], atol=5e-5)
np.testing.assert_allclose(down_vol, [0.0885, 0.0297], atol=5e-5)
np.testing.assert_allclose(pa_excess_smp, [0.0050, 0.0281], atol=5e-5)
np.testing.assert_allclose(column(Stat.SORTINO_RATIO), [0.056, 0.946], atol=5e-4)
# The target downside deviation and the decomposition proposition.
losses = log_m.where(log_m < 0.0)
n_neg, mean_neg = losses.count(), losses.mean()
target_dd = np.sqrt(af * (np.minimum(log_m, 0.0) ** 2).mean())
level_term = n_neg / T * af * mean_neg ** 2
np.testing.assert_allclose(target_dd ** 2, (n_neg - 1) / T * down_vol ** 2 + level_term,
rtol=1e-12)
assert list(n_neg) == [74, 63]
np.testing.assert_allclose(target_dd, [0.1133, 0.0320], atol=5e-5)
np.testing.assert_allclose(level_term['SEQ_US'] / target_dd['SEQ_US'] ** 2, 0.69, atol=5e-3)
# Skewness and kurtosis: bias-corrected G1 and G2 from central moments.
def central_moment(x: pd.Series, j: int) -> float:
"""Central sample moment with divisor T."""
return float(((x - x.mean()) ** j).mean())
g1 = log_m.apply(lambda x: central_moment(x, 3) / central_moment(x, 2) ** 1.5)
g2 = log_m.apply(lambda x: central_moment(x, 4) / central_moment(x, 2) ** 2 - 3.0)
G1 = g1 * np.sqrt(T * (T - 1)) / (T - 2)
G2 = ((T + 1) * g2 + 6.0) * (T - 1) / ((T - 2) * (T - 3))
np.testing.assert_allclose(column(Stat.SKEWNESS), G1, rtol=1e-10)
np.testing.assert_allclose(column(Stat.KURTOSIS), G2, rtol=1e-10)
np.testing.assert_allclose(G1, stats.skew(log_m, bias=False), rtol=1e-10)
np.testing.assert_allclose(G1, [0.287, 0.244], atol=5e-4)
np.testing.assert_allclose(G2, [-0.288, 0.285], atol=5e-4)
np.testing.assert_allclose(g1, [0.284, 0.241], atol=5e-4)
np.testing.assert_allclose(g2, [-0.320, 0.234], atol=5e-4)
# Drawdown, Calmar and worst return on the daily grid; Calmar has a native numerator.
daily = prices.pct_change().iloc[1:]
years_native = (prices.index[-1] - prices.index[0]).days / 365.25
accrual_d = 0.01 * prices.index.to_series().diff().dt.days.iloc[1:].to_numpy() / 365.0
pa_excess_native = (1.0 + daily.sub(accrual_d, axis=0)).prod() ** (1.0 / years_native) - 1.0
max_dd_daily = (prices / prices.cummax() - 1.0).min()
np.testing.assert_allclose(column(Stat.MAX_DD), max_dd_daily, rtol=1e-12)
np.testing.assert_allclose(column(Stat.PA_EXCESS_RETURN), pa_excess_native, rtol=1e-10)
np.testing.assert_allclose(column(Stat.CALMAR_RATIO), pa_excess_native / -max_dd_daily,
rtol=1e-10)
np.testing.assert_allclose(column(Stat.WORST), daily.min(), rtol=1e-12)
np.testing.assert_allclose(max_dd_daily, [-0.4637, -0.1095], atol=5e-5)
np.testing.assert_allclose(pa_excess_native, [0.0029, 0.0296], atol=5e-5)
np.testing.assert_allclose(column(Stat.CALMAR_RATIO), [0.0064, 0.2703], atol=1e-4)
np.testing.assert_allclose(daily.min()['SEQ_US'], -0.0360, atol=5e-5)
np.testing.assert_allclose(simple_m.min()['SEQ_US'], -0.0905, atol=5e-5)
The worst day of SEQ_US, −3.60%, is what WORST reports; its worst month was −9.05%. The
second block checks the descriptive table on the same month-end returns: the positive share, the
t-statistic and its link to the arithmetic Sharpe ratio, the uncorrected moments, and the
normality test.
monthly = qis.to_returns(prices=prices, freq='ME', drop_first=True)
np.testing.assert_allclose(monthly, simple_m, rtol=1e-12)
desc = qis.compute_desc_table(df=monthly, desc_table_type=qis.DescTableType.WITH_POSITIVE_PROB,
is_add_tstat=True, norm_variable_display_type='{:.6f}')
positive = (simple_m > 0.0).mean()
assert list(desc[Stat.POSITIVE.to_str()]) == ['48.3%', '55.9%']
assert list(desc[Stat.POSITIVE.to_str()]) == [f'{share:.1%}' for share in positive]
t_stat = simple_m.mean() * np.sqrt(T) / simple_m.std(ddof=1)
np.testing.assert_allclose(desc[Stat.T_STAT.to_str()].astype(float), t_stat, atol=1e-6)
np.testing.assert_allclose(t_stat, column(Stat.SHARPE_ARITH) * np.sqrt(T / af), rtol=1e-10)
np.testing.assert_allclose(t_stat, [0.592, 2.415], atol=5e-4)
np.testing.assert_allclose(column(Stat.SHARPE_ARITH), [0.172, 0.700], atol=5e-4)
# The descriptive table reports the uncorrected moments g1 and g2 as 'Skew' and 'Kurt'.
moments = qis.compute_desc_table(df=log_m, desc_table_type=qis.DescTableType.WITH_NORMAL_PVAL,
norm_variable_display_type='{:.6f}')
np.testing.assert_allclose(moments['Skew'].astype(float), g1, atol=1e-6)
np.testing.assert_allclose(moments['Kurt'].astype(float), g2, atol=1e-6)
k_squared, p_value = stats.normaltest(log_m)
z_skew, z_kurt = stats.skewtest(log_m).statistic, stats.kurtosistest(log_m).statistic
np.testing.assert_allclose(k_squared, z_skew ** 2 + z_kurt ** 2, rtol=1e-12)
np.testing.assert_allclose(p_value, np.exp(-k_squared / 2.0), rtol=1e-12)
np.testing.assert_allclose(k_squared, [2.52, 2.17], atol=5e-3)
assert list(moments[Stat.NORMTEST.to_str()]) == [f'{p:.4f}' for p in p_value]
assert list(moments[Stat.NORMTEST.to_str()]) == ['0.2843', '0.3387']
Neither asset rejects normality, as it should not: the paths are Gaussian by construction. The
third block reproduces the three pitfalls of the methodology section. Without perf_params the
business-day index is inferred as B and VOL becomes 16.56% and 5.97%, daily volatilities
annualised with \(\sqrt{252}\), instead of 17.10% and 5.59%; dropping the single row of 4 July 2014
makes the index irregular and restores the monthly numbers. The freq shortcut leaves skewness on
months, and PerfParams.copy keeps it. MAX_DD_VOL divides the daily drawdown by the monthly
volatility. Finally, a month-end NAV that never falls and has no losing month has no drawdown
and no downside volatility, so CALMAR_RATIO, DOWNSIDE_VOL and SORTINO_RATIO are missing.
inferred = qis.compute_ra_perf_table(prices=prices) # perf_params=None: freq is inferred as 'B'
daily_log = np.log(prices).diff().iloc[1:]
np.testing.assert_allclose(inferred[Stat.VOL.to_str()],
np.sqrt(252.0) * daily_log.std(ddof=1), rtol=1e-12)
assert (inferred[Stat.NUM_OBS.to_str()] == 3129).all()
np.testing.assert_allclose(inferred[Stat.VOL.to_str()], [0.1656, 0.0597], atol=5e-5)
irregular = prices.drop(pd.Timestamp('2014-07-04')) # one holiday row removed
assert pd.infer_freq(irregular.index) is None
fallback = qis.compute_ra_perf_table(prices=irregular)
np.testing.assert_allclose(fallback[Stat.VOL.to_str()], vol, rtol=1e-12)
assert qis.PerfParams(freq='QE').freq_skewness == 'ME'
assert qis.PerfParams().freq_reg == 'QE' and qis.PerfParams(freq='ME').freq_reg == 'ME'
assert qis.PerfParams(freq='ME').freq_drawdown == 'D'
max_dd_monthly = (month_end / month_end.cummax() - 1.0).min()
assert (max_dd_monthly >= max_dd_daily).all()
np.testing.assert_allclose(column(Stat.MAX_DD_VOL), max_dd_daily / vol, rtol=1e-12)
np.testing.assert_allclose(max_dd_daily / vol, [-2.71, -1.96], atol=5e-3)
np.testing.assert_allclose(max_dd_monthly / vol, [-2.64, -1.70], atol=5e-3)
assert qis.PerfParams(freq_skewness='QE').copy().freq_skewness == 'QE'
# undefined ratios are missing, not infinite: every month gains between 0.8% and 1.2%
growth = 1.01 + 0.002 * np.sin(np.arange(24))
rising = pd.Series(100.0 * np.concatenate(([1.0], np.cumprod(growth))),
index=month_end.index[:25], name='rising')
rising_row = qis.compute_ra_perf_table(prices=rising, perf_params=params).loc['rising']
assert rising_row[Stat.MAX_DD.to_str()] == 0.0 and rising_row[Stat.PA_EXCESS_RETURN.to_str()] > 0
assert np.isnan(rising_row[[Stat.CALMAR_RATIO.to_str(), Stat.DOWNSIDE_VOL.to_str(),
Stat.SORTINO_RATIO.to_str()]].astype(float)).all()
Implementation in qis¶
Quantity |
Formula |
qis entry point |
|---|---|---|
Grids, return basis and cash |
The contract above |
|
Column names and display formats |
|
|
Return basis of \(v_k\) and \(x_k\) |
\(\ell_t\) or \(r_t\) |
|
Regime Sharpe convention |
PA, arithmetic or log |
|
Risk-adjusted table |
All risk-adjusted columns |
|
Visible return columns |
\(\mathrm{TR}\), \(R_{\mathrm{pa}}\), \(\tilde R_{\mathrm{pa}}\), \(Y\) |
|
Risk columns |
\(\sigma_v\), \(\sigma^{-}\), \(\mathrm{MDD}\), \(G_1\), \(G_2\), \(\min r^{\mathrm{dd}}_t\), arithmetic family |
|
Downside volatility |
\(\sqrt{\mathrm{af}}\,s(v\mid v<0)\) |
internal |
Maximum and current drawdown |
\(\min_t D_t\), last \(D_t\) |
|
Benchmark columns |
\(\hat\alpha\), \(\mathrm{af}_{\mathrm{reg}}\hat\alpha\), \(\hat\beta\), \(R^2\), p-value |
|
Regime columns |
\(\bar r_{\mid\omega}\), regime p.a., regime Sharpe |
|
Formatted preset table |
Columns of a preset, as strings |
|
Descriptive table |
\(\bar x\), \(s(x)\), t-statistic, quantiles, positive share, rank, \(K^2\) p-value |
|
Period aggregates |
Mean, standard deviation and quantiles of period sums |
|
The implementations are in perf_stats.py, config.py, desc_table.py, returns.py and regime_classifier.py.
Descriptive-table modes¶
compute_desc_table always starts from Avg and Std (or Std An), adds T-stat when
is_add_tstat=True, and then applies the mode.
|
Columns added or removed |
|---|---|
|
Removes every column: the ticker index only; the plotting functions draw no table |
|
No further columns |
|
Removes |
|
Adds |
|
Adds |
|
Adds |
|
Adds |
|
Adds |
|
Removes |
|
Adds |
Column presets¶
Reporting functions select columns through preset tuples of PerfStat members. The twelve
exported presets are listed below, in column order. get_ra_perf_columns and
plot_ra_perf_table draw from compute_ra_perf_table and silently omit a requested column that
table does not produce, so a preset with regression or regime columns needs the producer named
in the last column.
Preset |
Columns |
Producer |
|---|---|---|
|
|
Risk-adjusted table; default of |
|
|
Risk-adjusted table |
|
|
Risk-adjusted table |
|
|
Risk-adjusted table |
|
|
Risk-adjusted table |
|
|
Risk-adjusted table |
|
|
Risk-adjusted table |
|
|
Benchmark table |
|
|
Benchmark table |
|
|
Benchmark table; default of |
|
|
Benchmark table |
|
|
Regime table |
Every preset except BENCHMARK_TABLE_COLUMNS contains the mixed-grid MAX_DD_VOL, and none
contains DOWNSIDE_VOL, SORTINO_RATIO, CALMAR_RATIO, CURRENT_DD or the arithmetic Sharpe
pair; pass an explicit tuple of members to report them. The block below checks these two claims
against the exported presets.
presets = [name for name in qis.__all__ if '_COLUMNS' in name]
assert len(presets) == 12
assert qis.RA_TABLE_COLUMNS == qis.STANDARD_TABLE_COLUMNS + (Stat.WORST, Stat.BEST)
assert qis.LN_BENCHMARK_TABLE_COLUMNS == qis.LN_TABLE_COLUMNS + (Stat.ALPHA, Stat.BETA, Stat.R2)
assert [name for name in presets if Stat.MAX_DD_VOL not in getattr(qis, name)] == [
'BENCHMARK_TABLE_COLUMNS']
absent = (Stat.DOWNSIDE_VOL, Stat.SORTINO_RATIO, Stat.CALMAR_RATIO, Stat.CURRENT_DD,
Stat.SHARPE_ARITH, Stat.SHARPE_ARITH_EXCESS)
assert not any(stat in getattr(qis, name) for name in presets for stat in absent)
assert len(qis.PerfStat) == 61
custom = (Stat.PA_EXCESS_RETURN, Stat.VOL, Stat.DOWNSIDE_VOL, Stat.SORTINO_RATIO,
Stat.MAX_DD, Stat.CALMAR_RATIO)
formatted = qis.get_ra_perf_columns(prices=prices, perf_params=params, perf_columns=custom)
assert list(formatted.columns) == [stat.to_str() for stat in custom]
Two naming details matter when code selects columns. PerfStat.X.to_str() returns the display
label, and so does PerfStat.X.name, because the ColVar field name shadows the enumeration’s
member name; the shadowing is kept because qis reads its labels that way, so use
PerfStat.X._name_ or PerfStat['VOL'] for the member name. The wrapped labels
(to_str(short_n=True)) are unique: ALPHA is Alpha and ALPHA_AN is An over Alpha, where
both were Alpha before, and a wide table containing the two could not tell them apart.
Interpretation and limitations¶
Every column is a full-sample, descriptive statistic. None is point in time, and none should enter a backtest decision at an earlier date.
The default table mixes grids.
MAX_DD,CURRENT_DD,WORSTandBESTare daily,VOL, the Sharpe family and the Sortino ratio monthly, andMAX_DD_VOLdivides one by the other. The regression grid is quarterly underPerfParams()and monthly underPerfParams(freq='ME').freq_excess_returnis stored, printed and copied but not read by any calculation. It is kept so that existing code constructingPerfParamswith it keeps working.For a sampled history of one year or less the ratio numerators are total, not annualised, returns, while
VOLis annualised; the resulting Sharpe and Sortino ratios are not comparable with those of longer histories.A rate series quoted from the first price date covers every period, and an earlier start changes nothing. If it starts later, the per-annum excess columns compound and annualise from the first period with a known rate, and qis warns.
Degenerate inputs give missing values, not zeros or infinities:
DOWNSIDE_VOLandSORTINO_RATIOwith fewer than two losing periods,CALMAR_RATIOwithout a drawdown,MAX_DD_VOLwith a missing or zero volatility, and the moments with fewer than three or four observations. Filter or fill them explicitly before ranking assets on these columns.On a coarse drawdown grid such as
freq_drawdown='ME',MAX_DDandCURRENT_DDinclude the final observation of a history that ends mid-month, but troughs inside earlier months are still invisible.Skewness, kurtosis and the normality test assume independent observations. Under serial correlation, as in smoothed private-asset returns, they are less precise than their nominal standard errors suggest; see Serial dependence and autocorrelation.
The bias-corrected moments of the risk table and the uncorrected moments of the descriptive table and rolling skewness are different estimators; compare like with like.
See also¶
References¶
Sortino, F. A., and van der Meer, R. (1991). Downside Risk. The Journal of Portfolio Management, 17(4), 27–31. Downside risk measured against a minimum acceptable return.
Sortino, F. A., and Price, L. N. (1994). Performance Measurement in a Downside Risk Framework. The Journal of Investing, 3(3), 59–64. The Sortino ratio and the target downside deviation contrasted with
DOWNSIDE_VOL.Young, T. W. (1991). Calmar Ratio: A Smoother Tool. Futures, 20(1), 40. The 36-month Calmar convention contrasted with the full-history column.
Joanes, D. N., and Gill, C. A. (1998). Comparing Measures of Sample Skewness and Kurtosis. Journal of the Royal Statistical Society: Series D (The Statistician), 47(1), 183–189. DOI: 10.1111/1467-9884.00122. The \(g_1\), \(G_1\), \(g_2\) and \(G_2\) estimators and their relation.
D’Agostino, R., and Pearson, E. S. (1973). Tests for Departure from Normality. Empirical Results for the Distributions of b2 and √b1. Biometrika, 60(3), 613–622. DOI: 10.1093/biomet/60.3.613. The omnibus normality test behind
NORMTEST.Bacon, C. R. (2008). Practical Portfolio Performance Measurement and Attribution, 2nd edition. Wiley. Practitioner definitions of downside deviation, the Sortino ratio and the Calmar ratio.
Sharpe, W. F. (1994). The Sharpe Ratio. The Journal of Portfolio Management, 21(1), 49–58. Author’s copy. The historical Sharpe ratio behind the arithmetic columns.
Jensen, M. C. (1968). The Performance of Mutual Funds in the Period 1945–1964. The Journal of Finance, 23(2), 389–416. DOI: 10.1111/j.1540-6261.1968.tb00815.x. The regression alpha reported by
ALPHA.Magdon-Ismail, M., Atiya, A. F., Pratap, A., and Abu-Mostafa, Y. S. (2004). On the Maximum Drawdown of a Brownian Motion. Journal of Applied Probability, 41(1), 147–161. DOI: 10.1239/jap/1077134674. The square-root growth of the expected maximum drawdown with the horizon.
Sepp, A. qis: Performance analytics, portfolio backtesting, risk analysis, and factsheet reporting in Python. Software citation metadata.