ComeçarComece de graça

Calculation of portfolio returns

For your first exercise on calculating portfolio returns, you will verify that a portfolio return can be computed as the weighted average of the portfolio component returns. In other words, this means that a portfolio return is calculated by taking the sum of simple returns multiplied by the portfolio weights. Remember that simple returns are calculated as the final value minus the initial value, divided by the initial value.

Assume that you invested in three assets. Their initial values are 1000 USD, 5000 USD, 2000 USD, respectively. Over time, the values change to 1100 USD, 4500 USD, and 3000 USD.

Este exercício faz parte do curso

Introduction to Portfolio Analysis in R

Ver curso

Instruções do exercício

  • Create a vector of the initial asset values in_values.
  • Create a vector of the final values, fin_values.
  • Create a vector of the initial weights, weights.
  • Use the simple return definition to compute the vector of returns on the three component assets. Assign return values to returns.
  • Assign the portfolio returns to preturns.

Exercício interativo prático

Experimente este exercício completando este código de exemplo.

# Vector of initial value of the assets
in_values <- 
  
# Vector of final values of the assets
fin_values <-

# Weights as the proportion of total value invested in each asset
weights <-

# Vector of simple returns of the assets 
returns <- (___ - ___)/___
  
# Compute portfolio return using the portfolio return formula
preturns <- sum(___*___)
  
Editar e executar o código