function trackerr
trackerr(
x: array,
y: array,
dim?: 0 | 1,
): number

Tracking Error (ex-post).

Ex-post tracking error, which measures the standard deviation of the difference between portfolio returns and benchmark returns.

Examples

Single asset tracking error

import { assertEquals } from "jsr:@std/assert";

const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039];
const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087];
assertEquals(trackerr(x, z), 0.06843618276256436);

Different portfolio tracking error

import { assertEquals } from "jsr:@std/assert";

const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087];

const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058];
assertEquals(trackerr(y, z), 0.058621668348828156);

Tracking error with different assets

import { assertEquals } from "jsr:@std/assert";

assertEquals(trackerr([0.05, 0.03, 0.08], [0.04, 0.025, 0.075]), 0.0028867513459481294);

Parameters

Portfolio/asset returns

Benchmark returns

optional
dim: 0 | 1

Dimension to operate on (0: row-wise, 1: column-wise) (defaults to 0)

Return Type

number

Tracking error value(s)

Throws

If input is a number or insufficient arguments provided

trackerr(
x: matrix,
y: array,
dim?: 0 | 1,
): array | matrix

Tracking Error (ex-post).

Ex-post tracking error, which measures the standard deviation of the difference between portfolio returns and benchmark returns.

Examples

Single asset tracking error

import { assertEquals } from "jsr:@std/assert";

const x = [0.003, 0.026, 0.015, -0.009, 0.014, 0.024, 0.015, 0.066, -0.014, 0.039];
const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087];
assertEquals(trackerr(x, z), 0.06843618276256436);

Different portfolio tracking error

import { assertEquals } from "jsr:@std/assert";

const z = [0.04, -0.022, 0.043, 0.028, -0.078, -0.011, 0.033, -0.049, 0.09, 0.087];

const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058];
assertEquals(trackerr(y, z), 0.058621668348828156);

Tracking error with different assets

import { assertEquals } from "jsr:@std/assert";

assertEquals(trackerr([0.05, 0.03, 0.08], [0.04, 0.025, 0.075]), 0.0028867513459481294);

Parameters

Portfolio/asset returns

Benchmark returns

optional
dim: 0 | 1

Dimension to operate on (0: row-wise, 1: column-wise) (defaults to 0)

Return Type

Tracking error value(s)

Throws

If input is a number or insufficient arguments provided