0

所以我的问题是Return.cumulative函数的输出数据不同于apply.yearly获得相同的返回数字。

这是重现的代码

require(quantmod)
require(PerformanceAnalytics)

from <- as.Date("2016-01-01")
to <- as.Date("2017-01-01")

getSymbols("GOOGL", from = from, to = to)

dat <- GOOGL[,6]
returns <- na.omit(ROC(dat,n = 1,"discrete"))

# Cumulative return
cumReturn <- Return.cumulative(returns)

# Apply return
sumReturn <- apply.yearly(returns,sum)

# Print
print(cumReturn)
print(sumReturn)

尝试使用该apply.monthly函数获取每月数据时,我也得到了相同的差异。

4

1 回答 1

1

离散回报应以几何方式(乘法)跨时间聚合。对离散回报求和会得出不准确的结果。Return.cumulative默认使用几何聚合。

R> Return.cumulative(returns)
                  GOOGL.Adjusted
Cumulative Return     0.04346625
R> apply.yearly(returns+1, prod)-1
           GOOGL.Adjusted
2016-12-30     0.04346625

有关两种退货类型之间差异和关系的讨论,请参阅A Tale of Two Returns 。

如果returns包含连续复合(log)返回,那么你的apply.yearly调用是正确的,你应该geometric = FALSEReturn.cumulative调用中设置。

R> Return.cumulative(returns, geometric = FALSE)
                  GOOGL.Adjusted
Cumulative Return     0.06251856
R> apply.yearly(returns, sum)
           GOOGL.Adjusted
2016-12-30     0.06251856
于 2017-02-07T00:55:27.143 回答