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

Evaluate strategy performance by Sharpe ratio

The Sharpe ratio is a risk-adjusted return measure developed by Nobel laureate William F. Sharpe. It is calculated as the average return over the risk-free rate divided by the standard deviation of the excess return.

You will calculate and review the Sharpe ratio of a signal-based strategy. The strategy generates long or short signals using two moving average indicators, and has been backtested using the 3-year historical price data of the Google stock. The backtest statistics has been provided in resInfo.

Bu egzersiz

Financial Trading in Python

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

Egzersiz talimatları

  • Get annual return and volatility from resInfo and save them in yearly_mean and yearly_vol respectively.
  • Calculate the Sharpe ratio manually using yearly_return and yearly_vol.
  • Print the annualized Sharpe ratio directly obtained from resInfo.

Uygulamalı interaktif egzersiz

Bu örnek kodu tamamlayarak bu egzersizi bitirin.

# Get annual return and volatility
yearly_return = ____
print('Annual return: %.2f'% yearly_return)
yearly_vol = ____
print('Annual volatility: %.2f'% yearly_vol)

# Calculate the Sharpe ratio manually
sharpe_ratio = ____ / ____
print('Sharpe ratio calculated: %.2f'% sharpe_ratio)

# Print the Sharpe ratio
print('Sharpe ratio %.2f'% ____)
Kodu Düzenle ve Çalıştır