tracking_error

AssetList.tracking_error(rolling_window=None, method='rms')

Calculate tracking error time series for the rate of return of assets.

Tracking error is an ex-post measure of how closely the assets follow the benchmark. It is computed from the realized monthly return differences between each asset and the benchmark, and is annualized (multiplied by sqrt(12)). Tracking error values are decimal fractions: 0.05 corresponds to 5% annualized.

Benchmark should be in the first position of the symbols list in AssetList parameters.

Two formulas are available (method parameter):

  • “rms” (default): root-mean-square of the return differences. The differences are not centered around their mean, hence the systematic lag between an asset and the benchmark (tracking difference) is included in the result.

  • “std”: sample standard deviation of the return differences with Bessel’s correction — the classic tracking error definition (Hwang & Satchell, “Tracking Error: Ex-Ante versus Ex-Post Measures”, 2001, eq. 2) measuring the pure volatility of deviations from the benchmark. The first point of the expanding time series is dropped (a single observation has no standard deviation).

Parameters:
rolling_windowint or None, default None

Size of the moving window in months. Must be at least 12 months. If None calculate expanding tracking error.

method{“rms”, “std”}, default “rms”

Tracking error formula: “rms” for the uncentered root-mean-square of return differences, “std” for the centered sample standard deviation.

Returns:
DataFrame

rolling or expanding tracking error time series for each asset.

Examples

>>> import matplotlib.pyplot as plt
>>> x = ok.AssetList(["SP500TR.INDX", "SPY.US", "VOO.US"], last_date="2021-01")
>>> x.tracking_error().plot()
>>> plt.show()
../_images/okama-AssetList-tracking_error-1_00_00.png

To calculate rolling tracking error set rolling_window to a number of months (moving window size):

>>> x.tracking_error(rolling_window=12 * 5, method="std").plot()
>>> plt.show()
../_images/okama-AssetList-tracking_error-1_01_00.png