spotrate() function creates SpotRate objects.

spotrate(x, compounding, daycount, calendar, period = NULL, .copyfrom = NULL)

Arguments

x

a numeric vector representing spot rate values.

compounding

a Compounding object.

daycount

a Daycount object.

calendar

a bizdays calendar.

period

the period of the rates in x, a Term object or a string like "1 month". The rates are converted to the equivalent annual rates, using compounding and daycount. A DateRangeTerm gives the rate for a fixed period between two dates. Defaults to one year, meaning that x is already annual.

.copyfrom

a SpotRate object used as reference to copy attributes.

Value

A SpotRate object. Its rates are always annual.

Examples

spotrate(0.06, "continuous", "actual/365", "actual")
#> [1] "0.06 continuous actual/365 actual"
spotrate(c(0.06, 0.07, 0.08), "continuous", "actual/365", "actual")
#> [1] "0.06 continuous actual/365 actual" "0.07 continuous actual/365 actual"
#> [3] "0.08 continuous actual/365 actual"

# a monthly inflation rate, stored as the equivalent annual rate
infl <- spotrate(0.0045, "discrete", "business/252", "Brazil/ANBIMA",
  period = "1 month"
)
infl
#> [1] "0.05535675 discrete business/252 Brazil/ANBIMA"
compound(infl, term(1, "month"))
#> [1] 1.0045

# a rate for a fixed period: January 2024 has 22 business days
jan <- term(as.Date("2024-01-01"), as.Date("2024-02-01"), "Brazil/ANBIMA")
infl_jan <- spotrate(0.0045, "discrete", "business/252", "Brazil/ANBIMA",
  period = jan
)
compound(infl_jan, as.Date("2024-01-01"), as.Date("2024-02-01"))
#> [1] 1.0045