volAdjust: Scale an xts object of returns to a target volatility.

Description Usage Arguments Value Examples

View source: R/volAdjust.R

Description

This function takes an xts object of returns and scales it to the volatility specified by target.vol. This is useful when you want to put compare the performance of different assets. Putting all assets on the same risk level is important, otherwise comparisons are not meaningful.

Usage

1
volAdjust(a, target.vol = 1)

Arguments

a

an xts object of asset returns

target.vol

a target volatility expressed in annualized terms. So, 10 annualized volatility should be passed as .10/sqrt(12) for monthly data. Default is 1.0. Meaning, the function will not alter the series if no target volatility is specified.

Value

an xts object of returns that has been scaled to have a standard deviation equal to target.vol.

Examples

1
2
3
4
5
6
7
8
library(dMisc)
dts <- seq(Sys.Date()-11, Sys.Date(), 1)
returns <- matrix(rnorm(12),ncol = 1) / 100
ret.xts <- xts(returns, dts)
target.vol = .10/sqrt(12)

ret.va <- volAdjust(ret.xts, target.vol = .10/sqrt(12))
trunc(sd(ret.va),5) == trunc(.10/sqrt(12),5) # TRUE

gtog/dMisc documentation built on May 17, 2019, 8:57 a.m.