第一動差:Mu
你可以使用 numpy 的 mean() 函式來計算個股的歷史平均報酬。
當你計算股票的日均報酬時,其實就是在估計歷史報酬分配的第一動差($\mu$)。
但對長期投資人來說,日報酬的估計有什麼用呢?你可以用下面的公式,根據平均日報酬與一年中的交易日數(一般約為 252 天),來估計股票的平均年化報酬:
$$ \text{Average Annualized Return} = ((1 + \mu)^{252}) - 1 $$
上一個練習中的 StockPrices 物件已儲存為變數。
本練習屬於課程
Python 投資組合風險管理入門
練習說明
- 匯入
numpy並命名為np。 - 計算
'Returns'欄位的平均值以估計第一動差($\mu$),並指定給mean_return_daily。 - 使用該公式推導在一年有 252 個交易日假設下的平均年化報酬。記得在 Python 中,次方運算使用
**運算子。
動手互動練習
試著完成這個範例程式碼,體驗一下這個練習。
# Import numpy as np
import ____ as ____
# Calculate the average daily return of the stock
mean_return_daily = ____(StockPrices['Returns'])
print(mean_return_daily)
# Calculate the implied annualized average return
mean_return_annualized = ((____+____)**____)-____
print(mean_return_annualized)