Modified Dietz method: Difference between revisions

Content deleted Content added
Tags: Mobile edit Mobile web edit Advanced mobile edit
 
(2 intermediate revisions by 2 users not shown)
Line 1:
{{Short description|Historical performance of an investment portfolio}}
The '''modified Dietz method'''<ref name="Dietz1966">{{cite book
|author=Peter O. Dietz
Line 452 ⟶ 453:
==Java method for modified Dietz return==
<syntaxhighlight lang="java">
private static double modifiedDietz (double emv, double bmv, double cashFlow[], int numCD, int numD[]) {
 
/* emv: Ending Market Value
Line 467 ⟶ 468:
 
if (numCD <= 0) {
throw new ArithmeticException ("numCD <= 0");
}
 
for (int i = 0; i < cashFlow.length; i++) {
if (numD[i] < 0) {
throw new ArithmeticException ("numD[i]<0 , " + "i=" + i);
}
weight[i] = (double) (numCD - numD[i]) / numCD;
Line 478 ⟶ 479:
 
double ttwcf = 0; // total time weighted cash flows
for (int i = 0; i < cashFlow.length; i++) {
ttwcf += weight[i] * cashFlow[i];
}
 
double tncf = 0; // total net cash flows
for (int i = 0; i < cashFlow.length; i++) {
tncf += cashFlow[i];
}