annreturn(): number
Computes the annualized return.
Calculates the annualized return of an asset or portfolio over a period. It supports both geometric (compounded) and simple (arithmetic) return modes.
Annualized return for a single asset (geometric)
Annualized return for a single asset (geometric)
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(annreturn(x, 12), 0.2338146820656939);
x: array
Asset/portfolio returns
Frequency of data points in a year (1: yearly, 4: quarterly, 12: monthly, 52: weekly, 252: daily)
annreturn(): array
Computes the annualized return.
Calculates the annualized return of an asset or portfolio over a period. It supports both geometric (compounded) and simple (arithmetic) return modes.
Annualized return for a single asset (geometric)
Annualized return for a single asset (geometric)
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(annreturn(x, 12), 0.2338146820656939);
x: matrix
Asset/portfolio returns
Frequency of data points in a year (1: yearly, 4: quarterly, 12: monthly, 52: weekly, 252: daily)
The computed annualized return