나는 나의 투자 포트폴리오의 수익을 늦게 계산하려고하는 약간의 문제에 봉착했다. Rstudio 블로그에서 권장되는 한 가지 방법이 있습니다.이것은 실제로 포트폴리오의 총 수익을 반환합니까?
이 방법은 PerformanceAnalytics
의 Return.portfolio
함수를 사용하며 포트폴리오의 '달러 증가'를 보여줍니다. 누구든지이 경험이 있으면 정확한 방법인지 여부에 대한 생각을 듣고 싶습니다.
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
그래서, Return.portfolio
기능에 의해 계산 된 내 포트폴리오의 $ 1 성장있어 내가 현재 날짜와 투자 날짜 사이의 증가율을 계산합니다. 이것은 정확하게 포트폴리오의 자본 증가를 보여줍니까?