Tracking error and benchmark-relative risk¶
Author: Artur Sepp / First recorded: 2026-08-15
Implemented in qis — Quantitative Investment Strategies. Software citation: CITATION.cff.
Tracking error is the variability of portfolio returns relative to a benchmark. Ex-ante tracking error evaluates current active weights under a covariance estimate; ex-post tracking error measures realised return differences. Both may be annualised percentages, but they describe different objects and need not agree.
Overview¶
Question |
qis entry point |
Required input |
Output |
|---|---|---|---|
What active risk do these weights carry? |
|
Dated covariance matrices and portfolio/benchmark weights |
Risk in the covariance’s square-root units |
How has realised active-return risk evolved? |
|
Portfolio and benchmark NAVs |
Annualised EWMA tracking-error Series |
What were whole-sample tracking error and information ratio? |
|
Periodic return-difference DataFrame |
TE and IR Series |
How do several sets of strategies compare? |
|
Mapping of labels to return-difference DataFrames |
TE and IR DataFrames |
Active-risk analysis follows the benchmark-relative mean/variance setting discussed by Roll (1992). A low tracking error means that relative returns vary little; it does not establish a high absolute return or low total portfolio volatility.
Inputs, notation, and assumptions¶
Convention |
This article |
|---|---|
Return basis |
Simple or log returns via |
Sampling grid |
|
Annualisation |
Ex post: \(\sqrt{\mathrm{af}}\) from explicit pandas |
Mean adjustment |
Whole-sample TE is demeaned; the EWMA TE is a second moment about zero |
Timing |
Ex-ante weights as of each covariance date; ex-post estimates are descriptive |
Output units |
Decimal TE in the units of the covariance or annualised; dimensionless IR |
qis default |
|
Symbol or input |
Meaning |
Units and alignment |
|---|---|---|
\(w_p,w_b\) |
Portfolio and benchmark weights |
Decimal capital fractions; asset labels must match the covariance universe |
\(d=w_p-w_b\) |
Active weights |
May be positive or negative |
\(\Sigma\) |
Asset-return covariance |
Periodic or annualised fractional covariance; state which |
\(x_t=r_{p,t}-r_{b,t}\) |
Realised active return |
Difference of returns using the same convention and grid |
\(s(x)\) |
Sample standard deviation |
|
\(\mathrm{af}\) |
Periods per year |
Native factor for EWMA pandas |
|
EWMA span |
Count of sampled return periods, not calendar days |
Supply positive NAVs over an explicitly aligned sample. Choose simple or log returns with
is_log_returns; the difference of simple returns and the log of a relative NAV are different
quantities.
A covariance used as a risk forecast must be estimated from information available on that
date. RiskModel validates finite, square, symmetric, identically labelled matrices; the caller
remains responsible for the estimate’s economic meaning and suitability as a covariance.
Methodology¶
Ex-ante covariance risk¶
For the active weights and covariance at the same risk date:
RiskModel applies no annualisation. An annualised covariance produces annualised tracking
error; a monthly covariance produces monthly tracking error. The canonical estimator
estimate_rolling_ewma_covar(..., apply_an_factor=True) supplies annualised covariance.
Its matrices are NaN in the row and column of an asset before that asset’s first return.
RiskModel accepts such rows and treats the asset as unavailable on that date: when its active
weight is zero it is ignored, when it is nonzero the tracking error is NaN, and its own
benchmark-beta loading is NaN. Any other non-finite entry is rejected.
Covariance labels define the asset universe. Missing in-universe weights become zero. Material weights outside that universe are rejected in strict mode. Methods accepting dated weight histories use the last observation at or before each covariance date, with zero weights before the first observation. They do not interpolate or supply a backtest execution lag. Single-date methods require an exact covariance-grid date.
Standalone group risk and additive contributions¶
compute_tre_at_date returns a scalar, or standalone sleeve risks when given group_data.
A sleeve’s active weights are set to zero outside the group before evaluating the quadratic form.
The resulting group risks do not add to portfolio tracking error because cross-group covariance
is omitted from each standalone calculation.
For positive total tracking error, the Euler contribution of asset \(i\) is:
compute_marginal_tre_at_date returns these contributions in mcte. They include the
active-weight multiplier; they are not merely the derivative of TE with respect to a weight.
A negative contribution can represent a reduction in total active risk. At zero TE, qis defines
all contributions as zero. For one covariance matrix outside a RiskModel,
compute_benchmark_portfolio_risk_contributions returns the same contributions, with both weight
vectors aligned to the covariance labels; see
Portfolio risk and Euler contributions.
Group rows aggregate asset contributions additively. If the returned table also contains
Total, do not add that row to its constituent groups. Optional systematic and residual
contributions reconcile when the supplied factor covariance decomposition is consistent;
qis does not silently repair inconsistent model views.
Ex-post realised tracking error¶
For a regularly sampled active-return series, the whole-sample estimators are:
TE is in annualised return units; IR is dimensionless. The difference must be formed before estimating its standard deviation. Subtracting the two standalone volatilities does not recover tracking error.
compute_te_ir_errors omits NaNs column by column. A zero-variance difference has TE zero and
IR missing; an insufficient sample can make both missing. An irregular input index may trigger
the annualisation helper’s fallback, so construct the intended regular return grid explicitly.
compute_ewma_realised_tracking_error concatenates the NAVs, removes jointly missing rows,
forward-fills, samples to freq, forms the chosen returns, and passes their difference to qis’s
EWMA volatility estimator. Annualisation uses get_annualization_factor(freq) for an explicit
pandas frequency alias (252 for B, 12 for ME, 4 for QE), so a short sample or newly arriving
dates do not change its risk units. With freq=None, the input grid is retained. None and QIS-only
schedules such as D_8H, the monthly/quarterly Friday schedules and SE retain annualisation
inferred from the surviving return index, including its warning and fallback when inference fails.
The first ewma_span estimates are masked for warm-up. Clip both
ends to the intended common sample before calling it: forward-filling a terminated NAV would
otherwise imply a stale investment value.
The EWMA series describes evolving realised variability. It is not the same estimator as whole-sample sample-standard-deviation TE or covariance-based ex-ante risk.
Worked example¶
Consider two assets with annualised volatilities 20% and 10%, correlation 0.10, and active weights \((0.10,-0.10)\). Their covariance matrix is
Active variance is \(0.00046\), so ex-ante TE is approximately 2.1448%.
Separately, four monthly simple active returns of 1%, −1%, 2%, and 0% have mean 0.5% and sample variance \(1/6000\). Their annualised TE is \(\sqrt{0.002}\), approximately 4.4721%, and IR is \(0.06/\sqrt{0.002}\), approximately 1.3416. These are fixed arithmetic illustrations, not forecasts or a comparison of predicted and realised risk for the same portfolio.
from math import isclose, sqrt
import pandas as pd
import qis
assets = ['Asset A', 'Asset B']
date = pd.Timestamp('2024-12-31')
covariance = pd.DataFrame(
[[0.04, 0.002], [0.002, 0.01]], index=assets, columns=assets
)
risk = qis.RiskModel(covar={date: covariance})
benchmark_weights = pd.Series([0.5, 0.5], index=assets)
portfolio_weights = pd.Series([0.6, 0.4], index=assets)
ex_ante = risk.compute_tre_at_date(
benchmark_weights=benchmark_weights, portfolio_weights=portfolio_weights, date=date
)
contributions = risk.compute_marginal_tre_at_date(
benchmark_weights=benchmark_weights, portfolio_weights=portfolio_weights, date=date
)
assert isclose(ex_ante, sqrt(0.00046), abs_tol=1e-12)
assert isclose(contributions['mcte'].sum(), ex_ante, abs_tol=1e-12)
single_matrix = qis.compute_benchmark_portfolio_risk_contributions(
w_portfolio=portfolio_weights, w_benchmark=benchmark_weights, covar=covariance
)
assert isclose(single_matrix.sum(), ex_ante, abs_tol=1e-12)
return_diffs = pd.DataFrame(
{'Active return': [0.01, -0.01, 0.02, 0.00]},
index=pd.date_range('2024-01-31', periods=4, freq='ME'),
)
te, ir = qis.compute_te_ir_errors(return_diffs=return_diffs)
assert isclose(te.iloc[0], sqrt(0.002), abs_tol=1e-12)
assert isclose(ir.iloc[0], 0.06 / sqrt(0.002), abs_tol=1e-12)
The Euler sum checks attribution arithmetic. It does not test covariance forecasting accuracy.
Large caps against a small-cap benchmark¶
A manager moves the entire equity portfolio into large caps while the mandate benchmark stays in small caps. Large caps have 15% annual volatility, small caps have 18%, and their correlation is 0.90. The manager has reduced absolute volatility by 3 percentage points. The active position, long large caps and short small caps in equal amounts, still has 7.94% annual tracking error. Chapter 11, Eq. 11.17 and Table 11.4.
from math import isclose, sqrt
import pandas as pd
import qis
assets = ['Large caps', 'Small caps']
sigma_large, sigma_small, correlation = 0.15, 0.18, 0.90
cross_cov = correlation * sigma_large * sigma_small
annual_cov = pd.DataFrame([[sigma_large**2, cross_cov], [cross_cov, sigma_small**2]],
index=assets, columns=assets)
as_of = pd.Timestamp('2024-12-31') # illustrative covariance date
model = qis.RiskModel(covar={as_of: annual_cov})
tracking_error = model.compute_tre_at_date(
benchmark_weights=pd.Series([0.0, 1.0], index=assets),
portfolio_weights=pd.Series([1.0, 0.0], index=assets),
date=as_of,
)
spread_vol = sqrt(sigma_large**2 + sigma_small**2 - 2 * correlation * sigma_large * sigma_small)
assert isclose(tracking_error, spread_vol, rel_tol=0.0, abs_tol=1e-12)
assert f'{tracking_error:.2%}' == '7.94%'
This is prospective risk from an annual covariance matrix. The Brinson factsheet example explains one realised active return for a separate three-asset-class portfolio.
Implementation in qis¶
RiskModel owns ex-ante tracking error, benchmark beta, factor exposures, and marginal risk. The adjacent ex-post module owns realised TE and IR. Use these implementations when extending analytics in qis.
Two complete examples use the frozen synthetic universe offline:
Ex-ante example: monthly log-return EWMA covariance, quarterly risk dates, a 36-month span, benchmark beta, and standalone/Euler group risk.
Ex-post example: quarterly rebalanced synthetic portfolios, simple monthly active returns, 36-month EWMA TE, whole-sample TE/IR, and EWMA benchmark beta/alpha.
From the repository, run:
python -m examples.portfolios.ex_anti_tracking_error_and_risk
python -m examples.portfolios.ex_post_tracking_error_and_risk
Both examples keep 2014-01-02–2025-12-31 inputs fixed and disable the fixture’s reporting quirks
to isolate the calculations. The spelling ex_anti in the existing filename is retained for
compatibility. On the maintainer’s Windows host, use the external interpreter and C-local
execution setup in AGENTS.md.
Interpretation and limitations¶
Ex-ante and ex-post TE can differ because their weights, return basis, covariance estimate, sampling period, and estimation method differ. Equal annualisation labels do not make them interchangeable.
A low TE does not imply low absolute portfolio risk or a positive mean active return.
Covariance and weights must be available at the stated risk date. As-of selection does not remove look-ahead already embedded in an input estimate.
Standalone group TE is non-additive. Use
mctefor additive attribution and exclude a precomputedTotalrow when summing groups.Specify the common NAV sample and investigate warm-up or missing values before interpreting the last EWMA point or a whole-sample IR.
The conventional square-root annualisation does not correct for serial dependence or make a short sample precise.
See also¶
Ordinary source links for these APIs are provided in Implementation in qis for readers using a Markdown viewer without Sphinx roles.
References¶
Roll, R. (1992). A Mean/Variance Analysis of Tracking Error. The Journal of Portfolio Management, 18(4), 13–22. DOI: 10.3905/jpm.1992.701922. Author’s copy.
Sepp, A. qis: Performance analytics, portfolio backtesting, risk analysis, and factsheet reporting in Python. Software citation metadata.
Elkamhi, R., and Lee, J. S. H. (2027). Active Risk Management. In Total Portfolio Management, Chapter 11. Springer. DOI: 10.1007/978-3-032-36706-8_11.