1. Learn
  2. /
  3. Courses
  4. /
  5. Introduction to Portfolio Risk Management in Python

Exercise

Equal weighted portfolios

When comparing different portfolios, you often want to consider performance versus a naive equally-weighted portfolio. If the portfolio doesn't outperform a simple equally weighted portfolio, you might want to consider another strategy, or simply opt for the naive approach if all else fails. You can expect equally-weighted portfolios to tend to outperform the market when the largest companies are doing poorly. This is because even tiny companies would have the same weight in your equally-weighted portfolio as Apple or Amazon, for example.

To make it easier for you to visualize the cumulative returns of portfolios, we defined the function cumulative_returns_plot() in your workspace.

Instructions

100 XP
  • Set numstocks equal to 9, which is the number of stocks in your portfolio.
  • Use np.repeat() to set portfolio_weights_ew equal to an array with an equal weights for each of the 9 stocks.
  • Use the .iloc accessor to select all rows and the first 9 columns when calculating the portfolio return.
  • Finally, review the plot of cumulative returns over time.