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.
This is a part of the course
“Introduction to Portfolio Risk Management in Python”
Exercise instructions
- Set
numstocks
equal to9
, which is the number of stocks in your portfolio. - Use
np.repeat()
to setportfolio_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.
Hands-on interactive exercise
Have a go at this exercise by completing this sample code.
# How many stocks are in your portfolio?
numstocks = ____
# Create an array of equal weights across all assets
portfolio_weights_ew = ____
# Calculate the equally-weighted portfolio returns
StockReturns['Portfolio_EW'] = StockReturns.iloc[____, ____].mul(portfolio_weights_ew, axis=1).sum(axis=1)
cumulative_returns_plot(['Portfolio', 'Portfolio_EW'])
This exercise is part of the course
Introduction to Portfolio Risk Management in Python
Evaluate portfolio risk and returns, construct market-cap weighted equity portfolios and learn how to forecast and hedge market risk via scenario generation.
Level up your understanding of investing by constructing portfolios of assets to enhance your risk-adjusted returns.
Exercise 1: Portfolio composition and backtestingExercise 2: Calculating portfolio returnsExercise 3: Equal weighted portfoliosExercise 4: Market-cap weighted portfoliosExercise 5: Correlation and co-varianceExercise 6: The correlation matrixExercise 7: The co-variance matrixExercise 8: Portfolio standard deviationExercise 9: Markowitz portfoliosExercise 10: The efficient frontierExercise 11: Sharpe ratiosExercise 12: The MSR portfolioExercise 13: The GMV portfolioWhat is DataCamp?
Learn the data skills you need online at your own pace—from non-coding essentials to data science and machine learning.