夏普比率與索提諾比率

Financial Trading in Python

Chelsea Yang

Data Science Instructor

哪個策略表現更好?

$$

策略 1:
  • 報酬:15%
  • 波動度(標準差):30%

$$

策略 2:
  • 報酬:10%
  • 波動度(標準差):8%
Financial Trading in Python

風險調整後報酬

  • 讓不同策略的表現可比較
  • 用一個比率描述為取得報酬所承擔的風險

風險 vs. 報酬

Financial Trading in Python

夏普比率

$$ \text{Sharpe Ratio} = (R_p - R_r)/\sigma_p $$

$$

  • $R_p $:策略、投資組合、資產等的報酬
  • $R_r $:無風險利率
  • $\sigma_p $:超額報酬($R_p-R_f$)的標準差

$$

  • 夏普比率越大,報酬越具吸引力
Financial Trading in Python

再選一次

$$

策略 1:
  • 報酬:15%
  • 波動度(標準差):30%
  • 夏普比率:15%/30% = 0.5

$$

策略 2:
  • 報酬:10%
  • 波動度(標準差):8%
  • 夏普比率:10%/8% = 1.25
Financial Trading in Python

從 bt 回測取得夏普比率

resInfo = bt_result.stats
# Get Sharpe ratios from the backtest stats
print('Sharpe ratio daily: %.2f'% resInfo.loc['daily_sharpe'])
print('Sharpe ratio monthly %.2f'% resInfo.loc['monthly_sharpe'])
print('Sharpe ratio annually %.2f'% resInfo.loc['yearly_sharpe'])
Sharpe ratio daily: 0.49
Sharpe ratio monthly 0.48
Sharpe ratio annually 1.34
Financial Trading in Python

手動計算夏普比率

# Obtain annual return
annual_return = resInfo.loc['yearly_mean']

# Obtain annual volatility volatility = resInfo.loc['yearly_vol']
# Calculate Sharpe ratio manually sharpe_ratio = annual_return / volatility print('Sharpe ratio annually %.2f'% sharpe_ratio)
Sharpe ratio annually 1.34
Financial Trading in Python

夏普比率的限制

  • 同時懲罰「好」與「壞」的波動
  • 上漲波動可能把比率往下拉

夏普比率的限制

Financial Trading in Python

索提諾比率

$$ \text{Sortino Ratio} = (R_p - R_r)/\sigma_d $$

  • $R_p $:策略、投資組合、資產等的報酬
  • $R_r $:無風險利率
  • $\sigma_d $:超額報酬($R_p-R_f$)的下行偏差

下行波動

Financial Trading in Python

從 bt 回測取得索提諾比率

resInfo = bt_result.stats
# Get Sortino ratio from backtest stats
print('Sortino ratio daily: %.2f'% resInfo.loc['daily_sortino'])
print('Sortino ratio monthly %.2f'% resInfo.loc['monthly_sortino'])
print('Sortino ratio annually %.2f'% resInfo.loc['yearly_sortino'])
Sortino ratio daily: 0.70
Sortino ratio monthly 0.86
Sortino ratio annually 2.29
Financial Trading in Python

一起來練習吧!

Financial Trading in Python

Preparing Video For Download...