【问题标题】:Does this actually return the total return of a portfolio?这实际上会返回投资组合的总回报吗?
【发布时间】:2018-02-22 18:24:27
【问题描述】:

我最近在计算投资组合的回报时遇到了一些麻烦。这是 Rstudio 博客上推荐的一种方法。

这种方式使用来自PerformanceAnalyticsReturn.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

所以,我的投资组合增长了 1 美元,由 Return.portfolio 函数计算得出,我计算了当前日期和投资日期之间的百分比增长。这是否准确地显示了投资组合的资本增长?

【问题讨论】:

    标签: r finance quantmod stock performanceanalytics


    【解决方案1】:

    不完全是:当您从 2017 年 1 月 3 日开始执行 Return.portfolio 时,它会为您提供一个索引,其中 2017 年 1 月 3 日的值被假定为 1。但它实际上并不包括 1在 2017-01-03 系列中。

    投资组合回报为as.numeric(tail(port.norebal,1))。当您除以as.numeric(head(port.norebal, 1)) 时,您将获得自投资组合第二天以来的回报(而不是自第一天以来)。即,您正在从计算中删除 2017-01-04 的回报。

    另外,不要忘记在您的回报计算中减去 1。你的投资组合回报率为 40%,而不是 140%。

    为了帮助解决这个问题,我计算了你的投资组合的等权版本,将你的 stock.weights 行替换为

    stock.weights <- rep(0.2, 5)
    

    然后我根据第一原理计算了回报:

    end.price = port.closing["2017-09-13"] 
    start.price = port.closing["2017-01-03"] 
    mean(as.numeric(end.price) / as.numeric(start.price) - 1)
    

    这给了我 0.382475,等于 as.numeric(tail(port.norebal,1)) - 1

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2018-02-19
      • 2020-09-27
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 2019-09-30
      • 2021-04-26
      相关资源
      最近更新 更多