开发者

calculating sharpe ratio in java

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 * Mat开发者_JAVA技巧h.sqrt(12);

    System.out.println("sharpeRatio="+ sharpeRatio);


From the calculations the article links to, you have the right answer and the article displays the wrong results.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜