📜  python pandas 累积回报 - Python 代码示例

📅  最后修改于: 2022-03-11 14:46:52.658000             🧑  作者: Mango

代码示例1
#We calculate and plot the cumulative return of a given dataframe called data
r = data.pct_change()  
r_plus_one = r.add(1)
cumulative_return = r_plus_one.cumprod().sub(1)
cumulative_return.mul(100).plot()
plt.ylabel('Percent')
plt.legend(['Cumulative Return'])
plt.show()