mdietz(): 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.
Calculate Modified Dietz Return with multiple cash flows
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);