Tracking Error

perfana.monte_carlo.risk.tracking_error_m(cov_or_data, weights, bmk_weights, freq)[source]

Calculates the tracking error with respect to the benchmark.

If a covariance matrix is used as the data, the benchmark components must be placed after the portfolio components. If a simulated returns cube is used as the data, the benchmark components must be placed after the portfolio components.

Parameters
  • cov_or_data (ndarray) – Covariance matrix or simulated returns data cube.

  • weights (Union[Iterable[Union[int, float]], ndarray, Series]) – Weights of the portfolio. This must be 1 dimensional and must match the dimension of the data’s last axis.

  • bmk_weights (Union[Iterable[Union[int, float]], ndarray, Series]) – Weights of the benchmark portfolio.

  • freq (Union[str, int]) – Frequency of the data. Can either be a string (‘week’, ‘month’, ‘quarter’, ‘semi-annual’, ‘year’) or an integer specifying the number of units per year. Week: 52, Month: 12, Quarter: 4, Semi-annual: 6, Year: 1.

Returns

Tracking error of the portfolio

Return type

float

Examples

>>> from perfana.datasets import load_cube
>>> from perfana.monte_carlo import portfolio_cov, tracking_error_m
>>> data = load_cube()
>>> weights = [0.25, 0.18, 0.13, 0.11, 0.24, 0.05, 0.04]
>>> bmk_weights = [0.65, 0.35]
>>> freq = 'quarterly'
>>> tracking_error_m(data, weights, bmk_weights, freq)
0.031183281273726802