Exercise

# Calculating portfolio returns

In order to build and backtest a portfolio, you have to be comfortable working with the returns of multiple assets in a single object.

In this exercise, you will be using a `pandas`

`DataFrame`

object, already stored as the variable `StockReturns`

, to hold the returns of multiple assets and to calculate the returns of a model portfolio.

The model portfolio is constructed with pre-defined weights for some of the largest companies in the world just before January 2017:

Company Name | Ticker | Portfolio Weight |
---|---|---|

Apple | AAPL | 12% |

Microsoft | MSFT | 15% |

Exxon Mobil | XOM | 8% |

Johnson & Johnson | JNJ | 5% |

JP Morgan | JPM | 9% |

Amazon | AMZN | 10% |

General Electric | GE | 11% |

FB | 14% | |

AT&T | T | 16% |

*Note that the portfolio weights should sum to 100% in most cases*

Instructions

**100 XP**

- Finish defining the numpy array of model
`portfolio_weights`

with the values according to the table above. - Use the
`.mul()`

method to multiply the`portfolio_weights`

across the rows of`StockReturns`

to get weighted stock returns. - Then use the
`.sum()`

method across the rows on the`WeightedReturns`

object to calculate the portfolio returns. - Finally, review the plot of cumulative returns over time.