1. Learn
  2. /
  3. Courses
  4. /
  5. Intro to Computational Finance with R

Exercise

A portfolio of Boeing and Microsoft stock

In this exercise, you will create a set of portfolios that consist of Microsoft and Boeing stock. The goal is to visualize all these portfolios in a plot with on the x-axis the portfolio standard deviation and on the y-axis the expected return on the portfolio.

The code on the right specifies the vector boeing_weights. Every element of the vector boeing_weights represents the proportion of Boeing stocks for that portfolio. The set of weights for Boeing that you will consider ranges from -1, -0.9, ..., up to 2.

Instructions

100 XP
  • The boeing_weights variable is given. Calculate the corresponding value of msft_weights and take into account that the sum of the portfolio weights should be one.
  • Assign to mu_portfolio the expected portfolio returns (\(\mu_p\)) for each set of portfolio weights.
  • Assign to sigma2_portfolio the portfolio variances (\(\sigma_p ^ 2\)) for each set of portfolio weights.
  • Have a look at the code to generate the plot on the right. Add the label "Boeing" and "Microsoft" on the right place in the risk-return plot. Are you not sure what is happening there? Have a look at the documentation of the text() function.