Sharpe ratio - A deep dive
Sharpe Ratio¶
Primer¶
Sharpe Ratio is the most common metric used to measure risk in finance.
The formula is
(return on portfolio - risk free rate)/standard deviation of the excess return on the portfolio
There are tons of resources on the internet about sharpe ratio.
This investopedia page is a good introduction.
We assume the risk free rate to be zero, then the formula simply becomes mean returns divided by the standard deviation of returns.
import numpy as np
import pandas as pd
import empyrical as ep
import matplotlib.pyplot as plt
import seaborn as sns
sns.set()
Single stock¶
Let us create a set of 5 stocks with same monthly returns but with different standard deviation for a period of 20 years. Stocks are named a to e with a being the stock with least volatility e with the highest volatility
mu = 0.01 #monthly returns
# Express sigma in relation to mean
multipliers = (0.5,1,2,5,10)
collect = {}
for s,m in zip(list('abcde'), multipliers):
collect[s] = np.random.normal(loc=mu, scale=m*mu, size=240)
df = pd.DataFrame(collect)
axes = df.plot(kind='kde', title='Distribution of returns', subplots=True, figsize=(8,8))
for ax in axes:
ax.axvline(0.01, color='red')
ep.cum_returns(df).plot(title='Cumulative returns')
s = df.describe().round(4)
s = s.append(pd.Series(df.mean()/df.std(), name='sharpe'))
s = s.append(pd.Series((df.mean()/df.std())*np.sqrt(12), name='sharpe_annual'))
s
Although all values are generated from the normal distribution with a fixed mean of 0.01, we could see a stark difference.
The first plot shows the distribution or the spread of returns where a and b are close to the mean of 0.01 (the red line) while e is just nowhere. You can also look at the table where the minimum and maximum returns for a are much closer while for e they are much wider. This implies this is very difficult to infer the mean returns of e as they wildly swing from one extreme to other while on the other hand we could be fairly confident with our estimates for a. From a risk perspective, it is very difficult to differentiate the actual mean value of stock e due to its high volatility. A look at the sharpe ratio for the instruments also follow this pattern.
A look at the cumulative returns suggests that stock e has left everybody behind and despite wild swings, it is way above; it seems that volatility helps in the long run. But this is only a single simulation of how prices would behave for a given risk/return profile.