function sortino
sortino(
x: array,
frisk?: number,
mar?: number,
dim?: 0 | 1,
): number

Sortino Ratio.

Calculates the Sortino ratio, a risk-adjusted performance measure that uses downside risk instead of standard deviation. It measures the return of an investment relative to the risk of negative returns.

Examples

Sortino ratio for a single asset

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];
assertEquals(sortino(x), 5.062884553295679);

Sortino ratio with custom MAR

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

assertEquals(sortino([0.1, -0.2, 0.05, -0.1], 0), -0.5303300858899106);

Sortino ratio with no downside

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

assertEquals(sortino([0.01, 0.02, 0.03], 0), Infinity);

Parameters

Asset/portfolio returns

optional
frisk: number

Risk-free rate (defaults to 0)

optional
mar: number

Minimum acceptable return threshold (defaults to 0)

optional
dim: 0 | 1

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

Return Type

number

Sortino Ratio

Throws

If input is a number (not supported)

sortino(
x: matrix,
frisk?: number,
mar?: number,
dim?: 0 | 1,
): array | matrix

Sortino Ratio.

Calculates the Sortino ratio, a risk-adjusted performance measure that uses downside risk instead of standard deviation. It measures the return of an investment relative to the risk of negative returns.

Examples

Sortino ratio for a single asset

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];
assertEquals(sortino(x), 5.062884553295679);

Sortino ratio with custom MAR

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

assertEquals(sortino([0.1, -0.2, 0.05, -0.1], 0), -0.5303300858899106);

Sortino ratio with no downside

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

assertEquals(sortino([0.01, 0.02, 0.03], 0), Infinity);

Parameters

Asset/portfolio returns

optional
frisk: number

Risk-free rate (defaults to 0)

optional
mar: number

Minimum acceptable return threshold (defaults to 0)

optional
dim: 0 | 1

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

Return Type

Sortino Ratio

Throws

If input is a number (not supported)