[R-sig-Finance] IMM Dates

Gabor Grothendieck ggrothendieck at gmail.com
Wed May 24 22:17:54 CEST 2006


If x is a "Date" object then the first line in the body
of thirdwed calculates the "Date" class date of the
first of x's month.

Now, suppose n = 1 if d is on Wed, n = 2 if d is on Tue,
..., n = 6 if d is on Thu.   The correspondence between
the usual encoding (0=Sun, ..., 6=Sat) and this encoding
is given in the second line and in the third line we
calculate the date of the third Wed.

Following that we have nexthirdwed which calls
thirdwed adding 30 days to the result if the
result is before x (to get us the third wed in
the following month):

thirdwed <- function(x) {
   d <- x - as.POSIXlt(x)$mday + 1
   n <- (3-as.POSIXlt(d)$wday) %% 7 + 1
   d + 14 + n - 1
}

nextthirdwed <- function(x) {
  y <- thirdwed(x)
  thirdwed(y + 30 * (y < x))
}

nextthirdwed(as.Date(c("2006-04-05", "2006-04-19", "2006-04-30")))


On 5/24/06, david.fiorino at abnamro.com <david.fiorino at abnamro.com> wrote:
>
> Before I reinvent the wheel, does anyone know of functionality that
> calculates the next IMM settlement date given today's date?
>
> Thanks - David
> ---------------------------------------------------------------------------
> This message (including any attachments) is confidential and...{{dropped}}
>
> _______________________________________________
> R-SIG-Finance at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>



More information about the R-SIG-Finance mailing list