Computes the compounding (and discount) factor for spot rates and curves.

compound(x, t, val, ...)

discount(x, t, val, ...)

Arguments

x

can be a Compounding, a SpotRate, a SpotRateCurve, a ForwardRate and a character representing a Compounding.

t

represents the term to compound. Can be a numeric, a Term, a Date or even missing. See Details.

val

is the value of the spot rate to be compounded in the given term. Can be a numeric, a Date or missing. See Details.

...

additional arguments.

Value

A numeric value that represents the compounding factor for the given spot rate.

Details

For Compounding classes the arguments t and val must be provided.

For a SpotRate class, if the t argument is numeric, representing the term to be compounded, the argument val must be a character with the units of the Term class. If otherwise t is a Term object, val is missing.

For SpotRateCurve and ForwardRate classes, that already have terms associated, t and val are missing.

discount() method is the inverse of compound: 1 / compound().

Examples

compound("simple", 2, 0.05)
#> [1] 1.1
compound("discrete", 2, 0.05)
#> [1] 1.1025
compound("continuous", 2, 0.05)
#> [1] 1.105171

spr <- spotrate(0.06, "simple", "actual/365", "actual")
compound(spr, 10, "days")
#> [1] 1.001644
discount(spr, 10, "days")
#> [1] 0.9983589
t <- term(10, "days")
compound(spr, t)
#> [1] 1.001644
discount(spr, t)
#> [1] 0.9983589
d1 <- Sys.Date()
d2 <- Sys.Date() + 10
compound(spr, d1, d2)
#> [1] 1.001644
discount(spr, d1, d2)
#> [1] 0.9983589

terms <- c(1, 11, 26, 27, 28)
rates <- c(0.0719, 0.056, 0.0674, 0.0687, 0.07)
curve <- spotratecurve(rates, terms, "discrete", "actual/365", "actual")
compound(curve)
#> [1] 1.000190 1.001643 1.004657 1.004927 1.005204
discount(curve)
#> [1] 0.9998098 0.9983592 0.9953646 0.9950971 0.9948232