wilsonfreitas / R-fixedincome

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

create a fixed daycount notation for datetime ranges #12

Open wilsonfreitas opened 9 years ago

wilsonfreitas commented 9 years ago

I need to create a daycount to specify fixed datetime intervals. For example, a spot rate is valid between 2 dates. So it depends on a calendar, but daycount doesn't refer to a calendar. What to do?

Suggestion:

as.daycount('fixed/2015-06-12:2015-07-12')

and use spotrate's calendar.

The problem is how to compute timefactor and dib that usually returns the number after /. One possible solution is: dib and timefactor methods have an optional argument for calendar.

dib(dc, calendar=NULL)
timefactor(dc, term, calendar=NULL)

and daycount could inform it has a datetime interval with a method has_daterange, that method would be used in dib, timefactor simply passes through. So, every time a curve use timefactor it should pass a calendar.