Portfolio cumulative returns
In the previous exercise, you've calculated the mean performance over a period of time. This gives you one performance number for that entire period. But what if you would want to plot the development of the performance over time? For that, you will need the cumulative performance, not the mean performance. Just like with interest in your bank account, the cumulative performance gives you the compounded return at each date in your dataset. It tells you; "up until today, this is what the total return has been since the start of my data."
Remember because of the compounding effect, you need to use cumprod()
for this calculation. NumPy
has already been imported as np
and available are the daily returns data from the previous exercise under returns
. Let's give it a try!
This exercise is part of the course
Introduction to Portfolio Analysis in Python
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# Create portfolio returns column
returns['Portfolio']= ____.____(____)