Below are functions that (I hope) calculate Sharpe and Sortino ratios.
I have made their interfaces identical.
From here, "Commonly, Sharpe Ratios on a daily, weekly or monthly basis are annualized by multiplying by the square root of the higher frequency time period. This is because the effective return is proportional to time. Assuming a Weiner process governs stock prices, variance is proportional to time. Hence standard deviation is proportional to the square root of time. So you would scale a Sharpe Ratio by multiplying by t/√t = √t, where t is the frequency you are annualizing from."
So why doesn't this logic apply to a Sortino Ratio, i.e. why don't we have an equivalent np.sqrt(N) term in the last line?
Thanks
def annualised_Sharpe(daily_ret, yearly_benchmark_rate=0.05,N=252):
MAR = yearly_benchmark_rate/N
excess_daily_ret = daily_ret - MAR
return np.sqrt(N) * excess_daily_ret.mean() / excess_daily_ret.std()
def annualised_Sortino(daily_ret, yearly_benchmark_rate=0.05, N=252):
MAR = yearly_benchmark_rate/N
excess_daily_ret = daily_ret - MAR
target_downside_deviation = np.sqrt(np.mean(minimum(excess_daily_ret,0.0)**2))
sortino = excess_daily_ret.mean() / target_downside_deviation
# Add Period correction??
#return np.sqrt(N) * sortino
return sortino