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

Treynor Ratio.

Computes the Treynor ratio, a risk-adjusted performance measure that uses beta (systematic risk) instead of standard deviation. It measures excess return per unit of systematic risk.

Examples

Treynor ratio for a single asset against benchmark

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(treynor(x, z, 0.01/12), -0.09568702060685172);

Treynor ratio for multiple assets against benchmark

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];

const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058];
assertEquals(treynor(x, z, 0.01/12), -0.09568702060685172);
assertEquals(treynor(y, z, 0.01/12), 0.029862503769903546);

Treynor ratio with zero risk-free rate

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(treynor(x, z), -0.10035923840992064);

Parameters

Asset/portfolio returns

Benchmark/market returns

optional
frisk: number

Risk-free rate (defaults to 0)

optional
dim: 0 | 1

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

Return Type

number

The Treynor ratio

Throws

If input is a number or insufficient arguments provided

treynor(
x: matrix,
y: array,
frisk?: number,
dim?: 0 | 1,
): array | matrix

Treynor Ratio.

Computes the Treynor ratio, a risk-adjusted performance measure that uses beta (systematic risk) instead of standard deviation. It measures excess return per unit of systematic risk.

Examples

Treynor ratio for a single asset against benchmark

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(treynor(x, z, 0.01/12), -0.09568702060685172);

Treynor ratio for multiple assets against benchmark

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];

const y = [-0.005, 0.081, 0.04, -0.037, -0.061, 0.058, -0.049, -0.021, 0.062, 0.058];
assertEquals(treynor(x, z, 0.01/12), -0.09568702060685172);
assertEquals(treynor(y, z, 0.01/12), 0.029862503769903546);

Treynor ratio with zero risk-free rate

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(treynor(x, z), -0.10035923840992064);

Parameters

Asset/portfolio returns

Benchmark/market returns

optional
frisk: number

Risk-free rate (defaults to 0)

optional
dim: 0 | 1

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

Return Type

The Treynor ratio

Throws

If input is a number or insufficient arguments provided