MulaiMulai sekarang secara gratis

Sortino ratio

For this exercise, the portfolio returns data are stored in a DataFrame called df, which you'll use to calculate the Sortino ratio. The Sortino ratio is just like the Sharpe ratio, except for that it uses the standard deviation of the negative returns only, and thereby focuses more on the downside of investing.

Let's see how big the Sortino ratio is compared to the earlier calculated Sharpe ratio. The risk-free rate rfrand the target return target are already defined and are both zero.

Latihan ini adalah bagian dari kursus

Introduction to Portfolio Analysis in Python

Lihat Kursus

Petunjuk latihan

  • Select the returns using .loc that are strictly less than the target, and store them in a new DataFrame called downside_returns.
  • Calculate the mean of the expected returns, and the standard deviation of the downside returns.
  • Calculate the Sortino ratio using rfr for the risk-free rate.

Latihan interaktif praktis

Cobalah latihan ini dengan menyelesaikan kode contoh berikut.

# Create a downside return column with the negative returns only
downside_returns = df.loc[df['pf_returns'] ____ target]

# Calculate expected return and std dev of downside
expected_return = df['____'].____()
down_stdev = downside_returns['pf_returns'].____()

# Calculate the sortino ratio
sortino_ratio = (____ - ____)/____

# Print the results
print("Expected return  : ", expected_return*100)
print("Downside risk   : ", down_stdev*100)
print("Sortino ratio : ", sortino_ratio)
Edit dan Jalankan Kode