[R-SIG-Finance] turning returns back into an index

blank bruvnor at icloud.com
Sun May 14 15:11:26 CEST 2017


I’ve looked everywhere for a C optimised R library function that will accumulate returns with interim levels but can’t find it. 

so a function that is the inverse of Return.calculate() from PerformanceAnalytics

or, something like this:

rtns <- rnorm(100, sd=0.01)
index <- vector(, length = length(rtns)+1)
index[1] <- 100
for ( i in 1:length(rtns) ) {
  index[i+1] <- index[i] * (1+rtns[i])
}

cheers.



More information about the R-SIG-Finance mailing list