Learn R Programming

FRAPO (version 0.3-7)

returnseries: Continuous and discrete returns

Description

Either continuous returns or discrete returns are computed for an object. The returns can be expressed as percenatges and the first NA value can be trimmed.

Usage

returnseries(y, method = c("continuous", "discrete"), percentage = TRUE,
             trim = FALSE, compound = FALSE)

Arguments

y
Objects of classes: numeric, matrix, data.frame, ts, mts, timeSeries, zoo and xts are supported.
method
Character, the type of return to be computed.
percentage
Logical, if TRUE (the default) the returns are expressed as percenatges.
trim
Logical, if FALSE (the default) the first value is set to NA such that the length of the return series coincides with the length of the series in levels.
compound
Logical, if FALSE (the default), then simple returns are computed and otherwise compounded returns.

Value

  • An object of the same class as y, containing the truncated series.

concept

  • returns
  • discrete returns
  • continuous returns
  • compound returns

Examples

Run this code
data(StockIndex)
y <- StockIndex[, "SP500"]
ret <- returnseries(y)
head(ret)

Run the code above in your browser using DataLab