Learn R Programming

QuantTools (version 0.5.3)

returns: Calculate returns

Description

Calculate returns

Usage

returns(x, type = "r", n = 1)

Arguments

x
numeric vector
type
'r' = x[t] / x[t-n] - 1 , 'l' = ln( x[t] / x[t-n] )
n
lookback

Value

Vector of same length as x with absent returns converted to 0 for relative and 1 for logarithmic.