Python 投资组合分析入门
Charlotte Werger
Data Scientist
年收益率:一个公历年内获得的总收益
年化收益率:从任意期限推算出的年度收益率
平均收益率:较长时期的总收益,平均到较短周期
累计(复利)收益:包含利息、股息与资本利得再投资的复合收益
$$

$$
$$
N 为年数:$rate= (1 +Return)^{1/N} -1$
N 为月数:$rate= (1+Return)^{12/N} -1$
将任意期限转为年化率:
# 查看时间序列的起止
apple_price.head(1)
date
2015-01-06 105.05
Name: AAPL, dtype: float64
apple_price.tail(1)
date
2018-03-29 99.75
Name: AAPL, dtype: float64
# 指定月份数
months = 38
# 计算总收益率
total_return = (apple_price[-1] - apple_price[0]) /
apple_price[0]
print (total_return)
0.5397420653068692
# 按月计算年化收益率
annualized_return=((1 + total_return)**(12/months))-1
print (annualized_return)
0.14602501482708763
# 选取三年区间
apple_price = apple_price.loc['2015-01-01':'2017-12-31']
apple_price.tail(3)
date
2017-12-27 170.60
2017-12-28 171.08
2017-12-29 169.23
Name: AAPL, dtype: float64
# 计算3年期的年化收益率
annualized_return = ((1 + total_return)**(1/3))-1
print (annualized_return)
0.1567672968419047
Python 投资组合分析入门