function painratio
painratio(
x: array,
frisk?: number,
t?: number,
mode?: string,
dim?: 0 | 1,
): number

Pain Ratio.

A risk-adjusted measure with free risk and Pain index. Pain Ratio = (Portfolio Return - RiskFree) / Pain Index

It measures how much return is earned for each unit of pain (drawdown) experienced.

Examples

Single array of returns

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

var x = [0.003,0.026,0.015,-0.009,0.014,0.024,0.015,0.066,-0.014,0.039];
assertEquals(painratio(x,0,12), 101.04495520047377);

Multiple arrays

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

var x = [0.003,0.026,0.015,-0.009,0.014,0.024,0.015,0.066,-0.014,0.039];

var y = [-0.005,0.081,0.04,-0.037,-0.061,0.058,-0.049,-0.021,0.062,0.058];
assertEquals(painratio(x,0,12), 101.04495520047377);
assertEquals(painratio(y,0,12), 3.235687223114222);

Parameters

asset/portfolio returns

optional
frisk: number

annual free-risk rate (def: 0)

optional
t: number

frequency of data. 1: yearly, 4: quarterly, 12: monthly, 52: weekly, 252: daily (def: 252)

optional
mode: string

drawdown calculation. 'return','geometric' (def: 'return')

optional
dim: 0 | 1

dimension 0: row, 1: column (def: 0)

Return Type

number

Pain Ratio value(s)

painratio(
x: matrix,
frisk?: number,
t?: number,
mode?: string,
dim?: 0 | 1,
): array | matrix

Pain Ratio.

A risk-adjusted measure with free risk and Pain index. Pain Ratio = (Portfolio Return - RiskFree) / Pain Index

It measures how much return is earned for each unit of pain (drawdown) experienced.

Examples

Single array of returns

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

var x = [0.003,0.026,0.015,-0.009,0.014,0.024,0.015,0.066,-0.014,0.039];
assertEquals(painratio(x,0,12), 101.04495520047377);

Multiple arrays

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

var x = [0.003,0.026,0.015,-0.009,0.014,0.024,0.015,0.066,-0.014,0.039];

var y = [-0.005,0.081,0.04,-0.037,-0.061,0.058,-0.049,-0.021,0.062,0.058];
assertEquals(painratio(x,0,12), 101.04495520047377);
assertEquals(painratio(y,0,12), 3.235687223114222);

Parameters

asset/portfolio returns

optional
frisk: number

annual free-risk rate (def: 0)

optional
t: number

frequency of data. 1: yearly, 4: quarterly, 12: monthly, 52: weekly, 252: daily (def: 252)

optional
mode: string

drawdown calculation. 'return','geometric' (def: 'return')

optional
dim: 0 | 1

dimension 0: row, 1: column (def: 0)

Return Type

Pain Ratio value(s)