Back to Community
backtester sharpe calculations

hi guys, please see img below.

this backtest has a yearly return of 27% and 10% volatility, and yet shows a sharpe of 4.4. how is this possible? Furthermore, on the sharpe tab, i calculated an average sharpe of 2.57.

12 responses

and how does over 45% roi and same volatility get a sharpe of 1.43??

I have the same question. My algorithm returns 25% in first year with a volatility of 3%. Why is the Sharpe ratio only 1.68?

I thought sharpe ratio = (return - risk free rate) / volatility. If you assume zero risk free rates then it should be just return / volatility.

It has been frustrating for me since they did not calculate sortino correctly, and then it was beta, and now it's backtest sharpe. I don't know how it is possible to mess up so bad on such simple calculations.

Unless.. they are now charging us for shorting stocks. Even then, if 25% return with 3% vol gives a sharpe of 1.68 that means that they are charging us a whooping 20% for charging stocks. mmm.. doesn't make sense. Maybe they just got the calculations wrong.

Yeah, I think the calculations are wrong. I'm getting some werid results as well.

I am wondering if this little function is the culprit:

def _adjust_returns(returns, adjustment_factor):  
    """  
    Returns a new pd.Series adjusted by adjustment_factor. Optimizes for the  
    case of adjustment_factor being 0  
    Parameters  
    ----------  
    returns : pd.Series  
    adjustment_factor : series / float  
    Returns  
    -------  
    pd.Series  
    """  
    **if isinstance(adjustment_factor, (float, int)) and adjustment_factor == 0:  
        return returns.copy()**  
    return returns - adjustment_factor  

Hi all,

A lot of questions in this thread, sorry if I don't get to all of them.

@toan
Averaging sharpe ratios across different time scales will always give different results. Here's a paper on the relative error when the sharpe ratio is averaged across different time scales as opposed to calculated once as (mean (daily risk-adjusted-return)) / std(daily risk-adjusted-volatility) * sqrt(252)

@Pravin
See the calculation above, this error is due to inconsistent averaging across time scales. Using the daily returns will always give back different values than a single CAGR-based calculation. Neither methodology is "wrong", however.

If there's anything else I can clarify, please feel free to ask.

Best,
Lotanna Ezenwa

Disclaimer

The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by Quantopian. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. No information contained herein should be regarded as a suggestion to engage in or refrain from any investment-related course of action as none of Quantopian nor any of its affiliates is undertaking to provide investment advice, act as an adviser to any plan or entity subject to the Employee Retirement Income Security Act of 1974, as amended, individual retirement account or individual retirement annuity, or give advice in a fiduciary capacity with respect to the materials presented herein. If you are an individual retirement or other investor, contact your financial advisor or other fiduciary unrelated to Quantopian about whether any given investment idea, strategy, product or service described herein may be appropriate for your circumstances. All investments involve risk, including loss of principal. Quantopian makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances.

Lotanna,

you should not be getting 4.4 sharpe with 27% return and 1.43 sharpe with over 45% return when the volatility is the same no matter how you calculate it.

Lotana,

Can you comment this metrics:

My test shows wrong calculation of Sharpe and Sortino Ratios in Bactester.

Pyfolio metrics:

Backtest Months: 26
Backtest
annual_return 0.14
annual_volatility 0.09
sharpe_ratio 1.54
calmar_ratio 1.95

stability 0.93
max_drawdown -0.07
omega_ratio 1.30
sortino_ratio 2.31
skewness -0.07
kurtosis 2.39
information_ratio 0.03
alpha 0.14
beta 0.05

Becktester Metrics:

Total Returns
33.8%
Benchmark Returns
16%
Alpha
0.13
Beta
0.06
Sharpe
0.37
Sortino
0.55

Information Ratio
0.02
Volatility
0.09
Max Drawdown
-7.4%

Hi Lotanna,

When you say:

See the calculation above, this error is due to inconsistent averaging across time scales.

Does it mean there is an error currently in the calculation and is going to be fixed?