I've ran into a bit of trouble of late trying to calculate the returns of my investment portfolio. Here's one way which has been recommended on the Rstudio blog.
This way uses the Return.portfolio
function from PerformanceAnalytics
and which shows the 'dollar growth' of a portfolio. If anyone has experience with this I'd be keen to hear your thoughts on whether or not this is an accurate method.
library(PerformanceAnalytics)
library(quantmod)
library(dygraphs)
symbols <- c("GOOG", "AMZN", "BA", "FB", "AAPL")
stock.weights <- c(.15, .20, .25, .225, .175)
getSymbols(symbols, src = 'google', from="2017-01-01")
#merge closing together
port.closing <- merge.xts(GOOG[,4], AMZN[,4], BA[,4], FB[,4], AAPL[,4])
#change closings to returns
port.return <- na.omit(Return.calculate(port.closing))
#portfolio returns with wealth.index = TRUE to apply to $1 invested - no rebalance
port.norebal = Return.portfolio(port.return,
weights = stock.weights, wealth.index = TRUE)
#visualise dollar growth
dygraph(port.norebal)
#calculating return on portfolio taking the current date and dividing it by investment date
PortfolioReturn <- as.numeric(tail(port.norebal,1)) / as.numeric(head(port.norebal, 1))
PortfolioReturn
So, I've got the growth of $1 of my portfolio as calculated by the Return.portfolio
function and I calculate the percentage increase between the current date and the investment date. Does this accurately show the capital growth of the portfolio?