Helpers methods that return parts of a SpotRateCurve object according to a given term.

first(x, t)

last(x, t)

closest(x, t)

Arguments

x

a SpotRateCurve object.

t

a Term object.

first filters the first elements of the SpotRateCurve according to the given term.

last filters the last elements of the SpotRateCurve according to the given term.

closest selects the element of the SpotRateCurve that is the closest to the given term.

Value

A SpotRateCurve object that is a subset of the given curve. The elements returned are select according to the operation executed.

Examples

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")
first(curve, "10 days")
#>       SpotRateCurve
#> 1 day        0.0719
#> discrete actual/365 actual 
#> Reference date: 2023-06-27 
last(curve, "10 days")
#>         SpotRateCurve
#> 26 days        0.0674
#> 27 days        0.0687
#> 28 days        0.0700
#> discrete actual/365 actual 
#> Reference date: 2023-06-27 
closest(curve, "10 days")
#>         SpotRateCurve
#> 11 days         0.056
#> discrete actual/365 actual 
#> Reference date: 2023-06-27