MSR 投資組合
最大夏普比率(maximum Sharpe ratio),或稱 MSR 投資組合,位於有效前緣的頂端,可以透過尋找夏普比率最高的投資組合來構建。
不過,MSR 投資組合往往相當不穩定。即使該投資組合過去的夏普比率很高,也不代表未來仍能維持良好的夏普比率。
本練習屬於課程
Python 投資組合風險管理入門
練習說明
- 將
RandomPortfolios依夏普值的「最高」排序,採用遞減序。 - 將
MSR_weights_array與StockReturns的各列相乘,得到加權後的股票報酬。 - 最後,檢視隨時間推移的累積報酬圖。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Sort the portfolios by Sharpe ratio
sorted_portfolios = RandomPortfolios.____(by=['Sharpe'], ascending=____)
# Extract the corresponding weights
MSR_weights = sorted_portfolios.iloc[0, 0:numstocks]
# Cast the MSR weights as a numpy array
MSR_weights_array = np.array(MSR_weights)
# Calculate the MSR portfolio returns
StockReturns['Portfolio_MSR'] = StockReturns.iloc[:, 0:numstocks].mul(____, axis=1).sum(axis=1)
# Plot the cumulative returns
cumulative_returns_plot(['Portfolio_EW', 'Portfolio_MCap', 'Portfolio_MSR'])