makeReturns: Compute log returns

View source: R/dataHandling.R

makeReturnsR Documentation

Compute log returns

Description

Convenience function to calculate log-returns, also used extensively internally. Accepts xts and matrix-like objects. If you use this with a data.table object, remember to not pass the DT column.

\mbox{log return}_t = (\log(\mbox{PRICE}_{t})-\log(\mbox{PRICE}_{t-1})).

Usage

makeReturns(ts)

Arguments

ts

a possibly multivariate matrix-like object containing prices in levels. If ts is an xts object, we return an xts object. Other types will result in a matrix

Details

Note: the first (row of) observation(s) is set to zero.

Value

Depending on input, either a matrix or an xts object containing the log returns.

Author(s)

Jonathan Cornelissen, Kris Boudt, and Emil Sjoerup


highfrequency documentation built on Oct. 4, 2023, 5:08 p.m.