Get startedGet started for free

Compute portfolio shares and portfolio returns

At the end of September 2004, suppose you have $10,000 to invest in Amazon and Costco over the next month.

Compute your portfolio shares if you invest $8,000 in Amazon and $2,000 in Costco. Moreover, compute the simple monthly return on the portfolio and assume that no dividends were paid.

This exercise is part of the course

Intro to Computational Finance with R

View Course

Exercise instructions

  • Compute the portfolio share of your Amazon stocks and assign it to xA.
  • Compute the portfolio share of your Costco stocks and assign it to xC.
  • Compute the simple monthly return on the portfolio and print the result to the console.

Hands-on interactive exercise

Have a go at this exercise by completing this sample code.

# The simple returns on Amazon (RA) and Costco (RC) are still in your workspace

# Portfolio shares
xA <- 
xC <- 

# Simple monthly return
Edit and Run Code