1. Learn
  2. /
  3. Courses
  4. /
  5. Statistical Simulation in Python

Exercise

Portfolio Simulation - Part I

In the next few exercises, you will calculate the expected returns of a stock portfolio & characterize its uncertainty.

Suppose you have invested $10,000 in your portfolio comprising of multiple stocks. You want to evaluate the portfolio's performance over 10 years. You can tweak your overall expected rate of return and volatility (standard deviation of the rate of return). Assume the rate of return follows a normal distribution.

First, let's write a function that takes the principal (initial investment), number of years, expected rate of return and volatility as inputs and returns the portfolio's total value after 10 years.

Upon completion of this exercise, you will have a function you can call to determine portfolio performance.

Instructions

100 XP
  • In the function definition, accept four arguments: number of years yrs, the expected rate of return avg_return, volatility sd_of_return, and principal (initial investment) principal as inputs.
  • Simulate rates of return for each year as a normal random variable.
  • Initialize end_return to the principal input. In the for loop, end_return is scaled up by the rate each year.
  • Use portfolio_return() to calculate and print result.