function mdietz
mdietz(
ev: number,
bv: number,
cf: number | array,
cfd: number | array,
): number

Modified Dietz Return.

Compute the Modified Dietz Return. It takes into account the timing of the cash flows, weighting them by the time they were held in the portfolio.

Examples

Calculate Modified Dietz Return with multiple cash flows

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

var bv = 100000; // beginning value
var ev = 110000; // ending value
var cf1 = 10000; //cash flow 1 (inflow)
var cf2 = 5000;  //cash flow 2 (inflow)
var cf3 = -2000; //cash flow 3 (outflow)
var cf = [cf1,cf2,cf3]; //cash flow array
var cfd = [0.25,0.5,0.75]; //cash flow dates array as fraction of the total period

assertEquals(mdietz(ev,bv,cf,cfd), -0.0273972602739726);

Parameters

ev: number

ending value

bv: number

beginning value

cf: number | array

cash flow array

cfd: number | array

cash flow dates array as fraction of the total period

Return Type

number

Modified Dietz Return

Usage

import mdietz from "quants/mdietz.ts";