How does the backtester calculate Sharpe Ratio ?

How becktester calculate Sharpe Ratio ?
Like this

Annualized Excessive Risk Free Return /Annualized StDev( Excessive Risk Free Return)

or different way?

2 responses

What I got from there:

def sharpe_ratio(algorithm_volatility, algorithm_return, treasury_return):
"""
http://en.wikipedia.org/wiki/Sharpe_ratio
Args:
algorithm_volatility (float): Algorithm volatility.
algorithm_return (float): Algorithm return percentage.
treasury_return (float): Treasury return percentage.
Returns:
float. The Sharpe ratio.
"""
if zp_math.tolerant_equals(algorithm_volatility, 0):
return np.nan

return (algorithm_return - treasury_return) / algorithm_volatility


In numerator actually we have Excessive over US.Treasury Return not Excessive over Risk Free Return.
In Denominator I suppose that algorithm_volatility is just StDev(Return)
not StDev (Excessive over Risk Free Return)
Nether numerator Nether Denominator calculated correctly.
This is not Sharpe Ratio.