Introduction to Portfolio Analysis in Python
Charlotte Werger
Data Scientist
$ $
Portfolio 1
$ $
Portfolio 2
$$
$ Sharpe \; ratio = \frac{R_p - R_f} {\sigma_p} $
Where: $ R_p$ is the portfolio return, $R_f$ is the risk free rate and ${\sigma_p} $ is the portfolio standard deviation
Remember the formula for the portfolio ${\sigma_p} $?
$$
# Calculate the annualized standard deviation
annualized_vol = apple_returns.std()*np.sqrt(250)
print (annualized_vol)
0.2286248397870068
# Define the risk free rate
risk_free = 0.01
# Calcuate the sharpe ratio
sharpe_ratio = (annualized_return - risk_free) / annualized_vol
print (sharpe_ratio)
0.6419569149994251
$ $
Portfolio 1
$ $
Portfolio 2
Introduction to Portfolio Analysis in Python