wilsonfreitas / R-fixedincome

Fixed income tools for R
http://wilsonfreitas.github.io/R-fixedincome/
Other
51 stars 25 forks source link

Context wrapper for calculations with term objects #27

Open wilsonfreitas opened 2 years ago

wilsonfreitas commented 2 years ago

I have a problem with term objects.

I can't do comparison between term objects because I don't know how to count them (I don't have a daycount).

I can't say that 252 days == 1 year is true, for example, if the daycout is business/252 this is true, otherwise this is not.

The same happens with arithmetic operations, 1 month + 12 days, without a daycount this operation can't be done.

With a context wrapper, that defines the daycount, these expression should be evaluated properly.

t1 <- term(252, "days")
t2 <- term(1, "year")
with_daycount("business/252", t1 == t2)
with_daycount("actual/360", t1 == t2)

These operations are evaluated with the given daycount.