BaşlayınÜcretsiz Başlayın

Portfolio Sharpe ratio

In this exercise you are now going to calculate the Sharpe ratio of the portfolio. How do you think the portfolio Sharpe ratio will be different to the S&P500 Sharpe ratio? You'll find out in this exercise.

You have the portfolio value over time under pf_AUM and the number of months for that data under months. Last, the risk-free rate is available under rfr, which is still set to zero.

Bu egzersiz

Introduction to Portfolio Analysis in Python

kursunun bir parçasıdır
Kursu Görüntüle

Egzersiz talimatları

  • Calculate the total return from pf_AUM and annualized return for the period defined under months
  • Calculate the annualized volatility, vol_pf, using the standard deviation of the returns. Use 250 trading days
  • Calculate the Sharpe ratio. Don't forget to subtract the risk-free rate rfr from the annualized return.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Calculate total return and annualized return from price data 
total_return = (____[____] - ____[____]) / ____[____]

# Annualize the total return over 4 year 
annualized_return = ((1 + total_return)**(____/months))-1

# Create the returns data 
pf_returns = pf_AUM.pct_change()

# Calculate annualized volatility from the standard deviation
vol_pf = pf_returns.____()*____.____(____)

# Calculate the Sharpe ratio 
sharpe_ratio = ((____ - ____) /____)
print (sharpe_ratio)
Kodu Düzenle ve Çalıştır