Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

fin-cumulated

Cumulated Time Series from Returns


Description

Computes a cumulated financial 'timeSeries', e.g. prices or indexes, from financial returns.

Usage

cumulated(x, ...)

## Default S3 method:
cumulated(x, method = c("continuous", "discrete", 
    "compound", "simple"), percentage = FALSE, ...)

Arguments

method

a character string naming the method how the returns were computed.

percentage

a logical value. By default FALSE, if TRUE the series will be expressed in percentage changes.

x

an object of class timeSeries.

...

arguments to be passed.

Details

Note, the function cumulated assumes as input discrete returns from a price or index series. Only then the cumulatrd series agrees with the original price or index series. The first values of the cumulated series cannot be computed, it is assumed that the series is indexed to 1.

Value

Returns a 'timeSeries' object of the same class as the input argument x.

Examples

## Use the Microsofts' Close Prices Indexed to 1 - 
   MSFT.CL <- MSFT[, "Close"]
   MSFT.CL <- MSFT.CL/MSFT[[1, "Close"]]
   head(MSFT.CL)

## Compute Discrete Return -    
   MSFT.RET <- returns(MSFT.CL, method = "discrete")
   
## Cumulated Series and Compare - 
   MSFT.CUM <- cumulated(MSFT.RET, method = "discrete") 
   head(cbind(MSFT.CL, MSFT.CUM))

timeSeries

Financial Time Series Objects (Rmetrics)

v3062.100
GPL (>= 2)
Authors
Diethelm Wuertz [aut] (original code), Tobias Setz [cre], Yohan Chalabi [ctb], Martin Maechler [ctb] (<https://orcid.org/0000-0002-8685-9910>)
Initial release
2020-01-24

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.