Skip to content
Prev 14255 / 15274 Next

turning returns back into an index

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.