Generic function for coercing to "volatility"
. There is a default
method and a method for "variance"
.
Usage
as.volatility(x, ...)
# S3 method for default
as.volatility(x, annualized = FALSE, dib = NULL, ...)
# S3 method for variance
as.volatility(x, ...)
Arguments
- x
an object whose class will determine the method to be dispatched. Value is the volatility or variance.
- ...
further arguments to be passed to the next method, such as:
- annualized
for default method, TRUE if volatility value in x is annualized, FALSE if volatility is daily.
- dib
days in one year, day count convention.
Examples
as.volatility(1)
#> Daily Volatility
#> [1] 1
as.volatility(as.variance(.5))
#> Daily Volatility
#> [1] 0.7071068
as.volatility(0.2, TRUE, 252)
#> Annual Volatility (%) 252 days
#> [1] 0.2
as.volatility(as.variance(10:30 / 100, TRUE))
#> Annual Volatility (%) days
#> [1] 31.62278 33.16625 34.64102 36.05551 37.41657 38.72983 40.00000 41.23106
#> [9] 42.42641 43.58899 44.72136 45.82576 46.90416 47.95832 48.98979 50.00000
#> [17] 50.99020 51.96152 52.91503 53.85165 54.77226