function irr
irr(
cf: array,
cfd?: array,
cd?: number,
guess?: number,
): number

Internal rate of return on an investment based on a series of periodic cash flows.

Calculates the internal rate of return on an investment based on a series of regularly/irregularly periodic cash flows.

Examples

Simple IRR with regular cash flows

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

assertEquals(irr([250000, 25000, -10000, -285000]), 0.024712563094781776);

Simple IRR with time periods

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

assertEquals(irr([74.2, 37.1, -104.4], [0, 1, 2], 2), -0.07410820570460687);

Modified IRR with irregular time periods

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

assertEquals(irr([250000, 25000, -10000, -285000], [0, 45, 69, 90], 90), 0.07692283872311291);

Modified IRR with different calendar days

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

assertEquals(irr([74.2, 37.1, -104.4], [0, 14, 31], 31), -0.07271456460699813);

Parameters

Cash flows associated with the investment. Must contain at least one negative and one positive cash flow

optional
cfd: array

Number of calendar days from the beginning of the period that cash flow occurs (defaults to sequential periods)

optional
cd: number

Total number of calendar days in the measurement period (defaults to 1)

optional
guess: number

Initial estimate for what the internal rate of return will be (defaults to 0.1)

Return Type

number

Internal rate of return

Throws

If insufficient arguments or convergence fails