Term-class | R Documentation |
It is the time interval used in calculations with interest rates. The Term class represents the period used to discount or compound a spot rate.
The Term object is defined by its numeric value and its unit, that can be
"days"
, "months"
or "years"
.
For example:
term(6, "months") #> [1] "6 months"
It represents a period of 6 months. The Term object can also be created from a string representation of a Term.
as.term("6 months") #> [1] "6 months"
Since the Term object inherits from a numeric
, it inherits all numeric
operations.
Numeric values can be summed or subtracted from a Term object numeric part.
term(1, "days") + 1 #> [1] "2 days"
Arithmetic and comparison operations between Term object are not implemented, so these operations raise an error.
try(term(1, "days") + term(2 , "days")) #> Error in term(1, "days") + term(2, "days") : Not implemented
The DateRangeTerm class inherits Term and defines start and end dates and a calendar to count the amount of working days between these two dates. This is a Term between two dates.
term(Sys.Date() - 5, Sys.Date(), "Brazil/ANBIMA") #> [1] "3 days"
In financial markets it is fairly usual to evaluate interest rates between two dates.
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.