To address this, I came up with a function called "IsHoliday". The way it works is that you submit a date and then it tells you whether that date corresponds to a holiday-shortened session, according to the CME Group's stock index futures holiday calendar. The calendar runs from 2007 through 2011.
Here is the code:
Code: Select all
Inputs: TestDate(numeric);
IsHoliday = False;
// 2011 Holidays
If TestDate = 1110117 Then IsHoliday = True; // Martin Luther King Day - January 17th, 2011
If TestDate = 1110221 Then IsHoliday = True; // President's Day - February 21st, 2011
If TestDate = 1110530 Then IsHoliday = True; // Memorial Day - May 30th, 2011
If TestDate = 1110704 Then IsHoliday = True; // Fourth of July - July 4th, 2011
If TestDate = 1110905 Then IsHoliday = True; // Memorial Day - September 5th, 2011
If TestDate = 1111124 Then IsHoliday = True; // Thanksgiving - November 24th, 2011
If TestDate = 1111125 Then IsHoliday = True; // Day After Thanksgiving - November 25th, 2011
// 2010 Holidays
If TestDate = 1100118 Then IsHoliday = True; // Martin Luther King Day - January 18th, 2010
If TestDate = 1100215 Then IsHoliday = True; // President's Day - February 15th, 2010
If TestDate = 1100531 Then IsHoliday = True; // Memorial Day - May 31st, 2010
If TestDate = 1100705 Then IsHoliday = True; // Fourth of July - July 5th, 2010
If TestDate = 1100906 Then IsHoliday = True; // Labor Day - September 6th, 2010
If TestDate = 1101125 Then IsHoliday = True; // Thanksgiving - November 25th, 2010
If TestDate = 1101126 Then IsHoliday = True; // Day After Thanksgiving - November 26th, 2010
// 2009 Holidays
If TestDate = 1090119 Then IsHoliday = True; // Martin Luther King Day - January 19th, 2009
If TestDate = 1090216 Then IsHoliday = True; // President's Day - February 16th, 2009
If TestDate = 1090525 Then IsHoliday = True; // Memorial Day - May 25th, 2009
If TestDate = 1090703 Then IsHoliday = True; // Day Before Fourth of July - July 3rd, 2009
If TestDate = 1090907 Then IsHoliday = True; // Labor Day - September 7th, 2009
If TestDate = 1091126 Then IsHoliday = True; // Thanksgiving Day - November 26th, 2009
If TestDate = 1091127 Then IsHoliday = True; // Day After Thanksgiving - November 27th, 2009
If TestDate = 1091224 Then IsHoliday = True; // Christmas Eve - December 24th, 2009
// 2008 Holidays
If TestDate = 1080121 Then IsHoliday = True; // Martin Luther King Day - January 21st, 2008
If TestDate = 1080218 Then IsHoliday = True; // President's Day - February 18th, 2008
If TestDate = 1080526 Then IsHoliday = True; // Memorial Day - May 26th, 2008
If TestDate = 1080703 Then IsHoliday = True; // Day Before Fourth of July - July 3rd, 2008
If TestDate = 1080704 Then IsHoliday = True; // Fourth of July - July 4th, 2008
If TestDate = 1080901 Then IsHoliday = True; // Labor Day - September 1st, 2008
If TestDate = 1081127 Then IsHoliday = True; // Thanksgiving Day - November 27th, 2008
If TestDate = 1081128 Then IsHoliday = True; // Day After Thanksgiving Day - November 28th, 2008
If TestDate = 1081224 Then IsHoliday = True; // Christmas Eve - December 24th, 2008
// 2007 Holidays
If TestDate = 1070528 Then IsHoliday = True; // Memorial Day - May 28th, 2007
If TestDate = 1070703 Then IsHoliday = True; // Day Before Fourth of July - July 3rd, 2007
If TestDate = 1070704 Then IsHoliday = True; // Fourth of July - July 4th, 2007
If TestDate = 1070903 Then IsHoliday = True; // Labor Day - September 3rd, 2007
If TestDate = 1071122 Then IsHoliday = True; // Thanksgiving Day - November 22nd, 2007
If TestDate = 1071123 Then IsHoliday = True; // Day After Thanksgiving Day - November 23rd, 2007
If TestDate = 1071224 Then IsHoliday = True; // Christmas Eve - December 24th, 2007
As always, any feedback or comments are appreciated.