Tracking Error
Tracking Error is a financial metric that quantifies the volatility or dispersion of the difference between the returns of an investment portfolio or asset and the returns of a benchmark index. It measures how closely the portfolio tracks its benchmark and provides insights into the consistency of the portfolio’s performance relative to the benchmark. A higher Tracking Error indicates greater divergence from the benchmark, while a lower Tracking Error suggests that the portfolio closely follows the benchmark.
The formula is as follows:
\[\text{Tracking Error} (\text{TE}) = \text{Standard Deviation of} (\text{Portfolio Returns} - \text{Benchmark Returns})\]By default one Tracking Error is reported per period, computed from the daily returns within that period, so it is a daily figure: multiply by SQRT(252) to compare it with the annualized tracking error funds report. With rolling, the returns of period itself are used instead.
See definition: https://en.wikipedia.org/wiki/Tracking_error
Also known as: active risk, benchmark deviation.
Tracking Error in Python or via the MCP
Install the Finance Toolkit with:
pip install financetoolkit -U
Then call get_tracking_error as shown below.
from financetoolkit import Toolkit
toolkit = Toolkit(
["VOO", "RSP", "QQQ"],
api_key="FINANCIAL_MODELING_PREP_KEY",
start_date="2021-01-01",
end_date="2025-12-31",
)
toolkit.performance.get_tracking_error()
Or, after setting up the Finance Toolkit MCP, ask:
How large was the daily tracking error of VOO, RSP and QQQ against the S&P 500 in each year from 2021 to 2025?
Which returns:
| Date | VOO | RSP | QQQ |
|---|---|---|---|
| 2021 | 0.0002 | 0.0038 | 0.0059 |
| 2022 | 0.0003 | 0.0034 | 0.0067 |
| 2023 | 0.0002 | 0.0038 | 0.005 |
| 2024 | 0.0003 | 0.0046 | 0.0047 |
| 2025 | 0.001 | 0.0051 | 0.0041 |
Parameters
get_tracking_error accepts the following parameters.
| Parameter | Type | Description | Example |
|---|---|---|---|
period | str | The period to use for the calculation. Defaults to “quarterly” if the Toolkit is initialised with quarterly=True, otherwise “yearly”. | "quarterly" |
rolling | int | The rolling window size to use for the calculation. If set, Tracking Error is calculated over a rolling window of this many periods across the full return history instead of per period. Defaults to None. | 4 |
rounding | int | None | The number of decimals to round the results to. Defaults to None, which uses the rounding of the Toolkit (4 unless set otherwise). | 2 |
growth | bool | Whether to calculate the growth of the ratios. Defaults to False. | True |
lag | int | list[int] | The lag to use for the growth calculation. Defaults to 1. | 4 |
standardize | bool | Whether to standardize (Z-Score) the result. When combined with growth=True, standardizes the growth values instead of the raw values. Defaults to False. | True |