Hi forum,
I am trying to calculate sharpe ratio in java, but I am struggling to find a "correct" dataset and result to test
Refering to http://www.hedgeco.net/blogs/2008/07/30/explaining-the-sharpe-ratio-again/
Investment Monthly Returns
Jan Feb Mar Apr May June Jul Aug Sep Oct Nov Dec
1.64 5.85 9.22 3.51 -0.88 1.07 13.03 9.4 10.49 -5.08 n/a n/a
Risk Free Rate 5%
However, I could not get what he got (2.56, instead I got 2.67 rounding error?)
Is this the right way (or commonly accepted way) to compute sharpe ratio?
My code (statistics computed using apache-commons-math)
DescriptiveStatistics stats = new DescriptiveStatistics();
for( double item : returns) {
stats.addValue(item);
}
double mean = stats.getMean();
double std = stats.getStandardDeviation();
double sharpeRatio = (mean - (riskFreeReturn/12) ) / std * Math.sqrt(12);
System.out.println("sharpeRatio="+ sharpeRatio);