turning returns back into an index

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

turning returns back into an index

blank
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.

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.
Reply | Threaded
Open this post in threaded view
|

Re: turning returns back into an index

Pierre Lapointe
cumprod(1+return_vector) to get an index starting from 1.
cumprod(1+return_vector)*100 to get an index starting at 100

On Sun, May 14, 2017 at 9:11 AM, blank <[hidden email]> wrote:

> 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.
>
> _______________________________________________
> [hidden email] mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions
> should go.

        [[alternative HTML version deleted]]

_______________________________________________
[hidden email] mailing list
https://stat.ethz.ch/mailman/listinfo/r-sig-finance
-- Subscriber-posting only. If you want to post, subscribe first.
-- Also note that this is not the r-help list where general R questions should go.