Ralph Vince - Portfolio Mathematics

(Brent) #1

390 THE HANDBOOK OF PORTFOLIO MATHEMATICS


Calculating inβin subsequent equations by (12.03a) will give you risk
of drawdown, as opposed to mere risk of ruin.
The main difference in the mechanics of (12.03a) over (12.03) is that at
any time in the running product of HPRs, if the running product is greater
than 1.0, then the value 1.0 is replaced for the running product at that point.
Herein is some very bare-bones Java code for calculating equation
(12.05) for one or more scenario spectrums, for determining either risk
of ruin [RR(b)] or risk of drawdown [RD(b)]:


import java.awt.;
import java.io.
;
import java.util.*;


public class MaxTWR4VAR{
String lines [];
String msnames [];
double f [];
double b;
boolean usedrawdowninsteadofruin;
double plays[][];
double hprs [][];
double hpr [];//the composite (arithmetic average per
time period) of the hprs
int N; //the number of plays.Capital used to correspond
to variables in the book
long NL;// N as a long to avoid many casts
public MaxTWR4VAR(String[] args){
try{
b=Double.parseDouble(args[1]);
}catch(NumberFormatException e){
System.out.println(”Command Line format:
MaxTWR4VAR inputfile riskofdrawdown(0.0..1.0)
calculateRD(true/false)”);
return;
}
if(args.length>2){
usedrawdowninsteadofruin=Boolean.valueOf (args[2])
.booleanValue();
}
getinputdata(args[0]);
createHPRs();
control();
}

Free download pdf