ComenzarEmpieza gratis

Portfolio Simulation - Part II

Now we will use the simulation function you built to evaluate 10-year returns.

Your stock-heavy portfolio has an initial investment of $10,000, an expected return of 7% and a volatility of 30%. You want to get a 95% confidence interval of what your investment will be worth in 10 years. We will simulate multiple samples of 10-year returns and calculate the confidence intervals on the distribution of returns.

By the end of this exercise, you will have run a complete portfolio simulation.

The function portfolio_return() from the previous exercise is already initialized in the environment.

Este ejercicio forma parte del curso

Statistical Simulation in Python

Ver curso

Instrucciones del ejercicio

  • Initialize sims to 1,000.
  • Enter the appropriate values for the portfolio_return() function parameters.
  • Calculate the 95% confidence interval lower (lower_ci) and upper limits (upper_ci).

Ejercicio interactivo práctico

Prueba este ejercicio completando el código de muestra.

# Run 1,000 iterations and store the results
sims, rets = 1000, []

for i in range(sims):
    rets.append(portfolio_return(yrs = 10, avg_return = 0.07, 
                                 volatility = 0.3, principal = 10000))

# Calculate the 95% CI
lower_ci = ____
upper_ci = ____
print("95% CI of Returns: Lower = {}, Upper = {}".format(lower_ci, upper_ci))
Editar y ejecutar código