Computing a ball relation in java

I am trying to calculate the sharpe coefficient in java, but I am struggling to find the “correct” dataset and the result for testing

Link to http://www.hedgeco.net/blogs/2008/07/30/explaining-the-sharpe-ratio-again/

Investment monthly income

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

5% risk-free rate

However, I could not get what I got (2.56, instead I got a 2.67 rounding error?)

Is it correct (or a common way) to calculate the sharpe coefficient?

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);
+3
source share
1 answer

, , , .

+3

Source: https://habr.com/ru/post/1755080/


All Articles