夏普比率与索提诺比率

Python 中的金融交易

Chelsea Yang

Data Science Instructor

哪种策略更优?

$$

策略 1:
  • 收益:15%
  • 波动率(标准差):30%

$$

策略 2:
  • 收益:10%
  • 波动率(标准差):8%
Python 中的金融交易

风险调整后收益

  • 使不同策略的表现可比
  • 以比率表述获取收益所承担的风险

风险 vs. 回报

Python 中的金融交易

夏普比率

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

$$

  • $R_p $:策略/组合/资产等的收益。
  • $R_r $:无风险利率
  • $\sigma_p $:超额收益($R_p-R_f$)的标准差

$$

  • 夏普比率越大,回报越有吸引力
Python 中的金融交易

现在再来选择

$$

策略 1:
  • 收益:15%
  • 波动率(标准差):30%
  • 夏普比率:15%/30% = 0.5

$$

策略 2:
  • 收益:10%
  • 波动率(标准差):8%
  • 夏普比率:10%/8% = 1.25
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
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
Python 中的金融交易

夏普比率的局限性

  • 同时惩罚"好"与"坏"的波动
  • 上行波动会使比率被低估

夏普比率的局限

Python 中的金融交易

索提诺比率

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

  • $R_p $:策略/组合/资产等的收益
  • $R_r $:无风险利率

  • $\sigma_d $:超额收益($R_p-R_f$)的下行偏离

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
Python 中的金融交易

让我们来练习!

Python 中的金融交易

Preparing Video For Download...