Skip to content

IMM Dates

2 messages · david.fiorino at abnamro.com, Gabor Grothendieck

#
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}}
#
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: