A fund can have zero tracking error and still underperform its benchmark every month.
That sounds contradictory until you separate two questions: how far behind did it finish, and how much did the gap vary along the way? Tracking difference answers the first. Tracking error answers the second.
For an ETF comparison page, portfolio dashboard or investment research tool, showing only one can give users the wrong impression. This guide calculates both from the same six-month example, then looks at the data choices that can change the result.
Tracking error vs tracking difference
| Measure | What it tells you | Calculation used here | How to read it |
|---|---|---|---|
| Tracking difference | The performance gap over a stated period | Compounded fund return minus compounded benchmark return | Negative means the fund lagged, using this sign convention |
| Tracking error | Variability in periodic return differences | Sample standard deviation of fund-minus-benchmark returns, annualised | Lower means more consistent tracking, not necessarily a smaller cumulative shortfall |
These are historical, or ex-post, measures. A risk model's forecast tracking error is a different calculation.
Vanguard's explanation of index tracking makes the same distinction between the size of the performance gap and its variability. Check a provider's methodology before comparing reported figures: observation frequency, measurement window and return basis need to match.
One benchmark, two funds
The following numbers are synthetic monthly total returns. They illustrate the calculation; they are not observations from real funds.
Fund A trails the benchmark by exactly 0.10 percentage points each month. Fund B sometimes leads and sometimes lags.
| Month | Benchmark | Fund A | Fund B |
|---|---|---|---|
| 1 | 2.00% | 1.90% | 2.40% |
| 2 | −1.00% | −1.10% | −1.60% |
| 3 | 3.00% | 2.90% | 3.30% |
| 4 | 0.00% | −0.10% | −0.50% |
| 5 | −2.00% | −2.10% | −1.80% |
| 6 | 1.00% | 0.90% | 0.60% |
Both funds have an average monthly active return of −0.10 percentage points. Their month-to-month behaviour is quite different.
Calculate tracking difference
Compound each return series separately:
Fund return = product(1 + each fund return) − 1 Benchmark return = product(1 + each benchmark return) − 1 Tracking difference = Fund return − Benchmark return For Fund A, the six-month return is 2.3352%. The benchmark returns 2.9485%. Fund A's tracking difference is therefore −0.6133 percentage points, or about −61.33 basis points.
Adding its six monthly gaps gives −0.60 percentage points. That is not the same result. A difference between two compounded returns is generally not the sum of their periodic differences.
Nor is it the relative-wealth calculation (1 + fund return) / (1 + benchmark return) − 1. That ratio can be useful, but it is a different statistic. Label the convention you use.
Calculate tracking error
First calculate the active return for every observation:
active return[t] = fund return[t] − benchmark return[t] annualised tracking error = sample_stdev(active returns) × sqrt(periods per year) Fund A's active returns are constant. Their standard deviation is zero, even though every month contains a shortfall.
Fund B's active returns vary. Using monthly observations and a square-root-of-12 annualisation, its tracking error is 1.5492% a year.
| Result | Fund A | Fund B |
|---|---|---|
| Six-month fund return | 2.3352% | 2.3123% |
| Six-month benchmark return | 2.9485% | 2.9485% |
| Six-month tracking difference | −0.6133 percentage points | −0.6362 percentage points |
| Annualised tracking error | 0.0000% | 1.5492% |
The cumulative shortfalls are similar. The consistency of those shortfalls is not. Neither result, on its own, tells someone which fund to buy.
Six observations are deliberately easy to inspect, but far too few for a stable assessment of a real fund. The annualised figures demonstrate a convention, not a forecast.
Calculate both in Python
This example needs only Python's standard library. Returns are decimals: 0.02 means 2%. Each row must represent the same interval for the fund and benchmark.
from math import isfinite, prod, sqrt from statistics import stdev def tracking_metrics(rows, periods_per_year): # rows: (fund_return, benchmark_return), aligned by interval if len(rows) < 2: raise ValueError("At least two paired return observations are needed") if not isfinite(periods_per_year) or periods_per_year <= 0: raise ValueError("periods_per_year must be positive and finite") if any(not isfinite(r) or r <= -1 for row in rows for r in row): raise ValueError("This example requires finite returns above -100%") fund = [row[0] for row in rows] benchmark = [row[1] for row in rows] active = [f - b for f, b in rows] fund_return = prod(1 + r for r in fund) - 1 benchmark_return = prod(1 + r for r in benchmark) - 1 return { "fund_return": fund_return, "benchmark_return": benchmark_return, "tracking_difference": fund_return - benchmark_return, "tracking_error_annualised": stdev(active) * sqrt(periods_per_year), } benchmark = [0.02, -0.01, 0.03, 0.00, -0.02, 0.01] fund_a = [0.019, -0.011, 0.029, -0.001, -0.021, 0.009] fund_b = [0.024, -0.016, 0.033, -0.005, -0.018, 0.006] for name, fund in [("Fund A", fund_a), ("Fund B", fund_b)]: result = tracking_metrics(list(zip(fund, benchmark)), 12) td = result["tracking_difference"] * 100 te = result["tracking_error_annualised"] * 100 print(f"{name}: TD {td:.4f} pp; annualised TE {te:.4f}%") Output:
Fund A: TD -0.6133 pp; annualised TE 0.0000% Fund B: TD -0.6362 pp; annualised TE 1.5492% Python's statistics.stdev uses the sample standard deviation, with an n − 1 denominator. Do not mix it with a population standard deviation when reconciling results.
The function assumes the caller has already aligned complete intervals. It cannot detect a Friday-to-Monday return paired with a Thursday-to-Friday return. For production input, join on explicit interval boundaries and reject unmatched observations before calling it.
The data decisions that matter more than the code
NAV returns or exchange-price returns?
An ETF's market price can trade above or below its net asset value. A calculation based on market prices therefore includes premium or discount movements that a NAV-based comparison does not. CFA Institute's ETF overview distinguishes these two values.
Use NAV total returns when the question is how the fund's portfolio tracked its index. Use market-price returns when that is the experience you intend to measure, and name that basis in the output. A generic historical close is not automatically a fund NAV.
Price return or total return?
Comparing a fund's price-only return with a dividend-reinvesting benchmark introduces a mismatch. Distributions can look like tracking failures if they are omitted on one side.
Specify whether the benchmark uses price return, gross total return or net total return. Match the fund series as closely as the analytical purpose allows. Verify what an “adjusted” field actually adjusts; the label alone does not establish dividend reinvestment or tax treatment.
Currency, timestamps and missing dates
A USD fund series and a EUR benchmark series do not isolate the same exposure. Different closing times can also make a pair of daily returns move out of step, even when the underlying holdings are similar.
Use a shared reporting currency, consistent valuation times and the same observation calendar. Do not replace a missing return with zero. If a date is absent, investigate it or rebuild both series over matching intervals. Record any exclusions with the result.
Annualisation is a convention
The example uses monthly observations, so the scaling factor is sqrt(12). Daily equity calculations often use sqrt(252), but switching that number does not turn irregular observations into daily data.
Square-root scaling assumes a stable variance and no material serial correlation in active returns. If those assumptions do not fit the series, report the observation-frequency statistic and explain the annualisation method. A low historical number is not a promise of future tracking.
Where SiftingIO fits in the workflow
At SiftingIO, we provide market data for applications that need current and historical prices. Our historical OHLCV documentation is a starting point for building the price-input layer of a comparison tool. Coverage, history and access depend on the endpoint and plan.
Keep that input layer separate from the performance calculation. Price bars alone do not provide every ingredient of a fund comparison. Obtain the appropriate NAV, distribution and benchmark total-return series where the analysis requires them, and verify their usage rights. An ETF used as a benchmark proxy also introduces its own costs and tracking behaviour.
The broader distinction between ETF prices, history and NAV is covered in our US stock and ETF data guide. For the calculation above, the final input should be a small, auditable table of paired returns, regardless of where the raw observations came from.
What to show beside the number
A useful comparison card gives the reader enough context to reproduce it:
Tracking difference: −0.6362 percentage points over six months Tracking error: 1.5492% annualised Basis: synthetic total returns, same currency Frequency: monthly; six paired observations Method: sample standard deviation × sqrt(12) On a real dashboard, add the fund/share class, exact benchmark variant, start and end dates, price or NAV basis, and the number of excluded observations. Keep the signed performance gap beside the variability measure. That prevents a small tracking-error number from concealing a persistent shortfall.
Originally published on SiftingIO.


![[Exercice IA #1] Le ticket de caisse du développeur (Variables et calculs)](https://media2.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.us-east-2.amazonaws.com%2Fuploads%2Farticles%2Fuq2fvh5degyfrcwr54n5.png)