Course Name: Natural Language Processing in Trading, Section No: 5, Unit No: 1, Unit type: Notebook
in the sharpe ratio formula I can see that the average daily returns are used however in the denominator of the fraction the annualized volatility is used. I think the term of square root of 252 should not be present in the formula the way it has been written.
Hey,
I believe this is the line of code you are referring to:
sharpe_ratio = (excess_daily_returns.mean() / excess_daily_returns.std()) * np.sqrt(trading_days)
To clarify, in this formula, we are not multiplying the square root of trading days directly with the denominator. Instead, we are multiplying it with the result of the mean returns divided by the standard deviation of returns. This effectively annualizes the Sharpe ratio. Here's the breakdown:
- excess_daily_returns.mean() / excess_daily_returns.std() -> This calculates the daily Sharpe ratio.
- * np.sqrt(trading_days) -> This annualizes the daily Sharpe ratio by scaling it according to the number of trading days in a year (earlier defined as 252).
Hope this resolves your query!
Thanks
Rushda
you're right. I didn't realize that the sqrt term is multiplied. Basically, the daily excess return can be multiplied by 252=sqrt(252)*sqrt(252) and the daily vol by sqrt(252) to annualize it. Then the two sqrt(252) terms cancel out and only one sqrt(252) remains that is multiplied by the fraction.
Thank you for your reply,
Spyros