Search code examples
rquantmodperformanceanalytics

Return data from Return.cumulative vs apply.yearly returns differs?


So my problem is the outptut data from the Return.cumulative function differs from the apply.yearly to get the same return figures.

Here's the code to reproduce

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)

I also get the same differences when trying to get monthly data using the apply.monthly function.


Solution

  • Discrete returns should be aggregated across time geometrically (multiplicative). Summing discrete returns gives inaccurate results. Return.cumulative uses geometric aggregation by default.

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

    See A Tale of Two Returns for a discussion of the differences and relationships between the two return types.

    If returns contained continuously compounded (log) returns, then your apply.yearly call would be correct, and you should set geometric = FALSE in the Return.cumulative call.

    R> Return.cumulative(returns, geometric = FALSE)
                      GOOGL.Adjusted
    Cumulative Return     0.06251856
    R> apply.yearly(returns, sum)
               GOOGL.Adjusted
    2016-12-30     0.06251856