#include "cgeneral.h"#include "cdate.h"#include "buscache.h"Defines | |
| #define | JPMCDS_BAD_DAY_FOLLOW ((long)'F') | 
| #define | JPMCDS_BAD_DAY_PREVIOUS ((long)'P') | 
| #define | JPMCDS_BAD_DAY_NONE ((long)'N') | 
| #define | JPMCDS_BAD_DAY_MODIFIED ((long)'M') | 
| #define | JPMCDS_NUM_BAD_DAY_CONVS 4 | 
| #define | JPMCDS_IS_WEEKEND(date, weekends) ((1 << ((date) % 7)) & (weekends)) | 
| Determines whether a day is at a weekend as given by the weekends flag.  | |
| #define | JPMCDS_IS_WEEKDAY(date, weekends) (!(JPMCDS_IS_WEEKEND((date),(weekends)))) | 
Functions | |
| int | JpmcdsDateFromBusDaysOffset (TDate fromDate, long offset, char *holidayFile, TDate *result) | 
| Calculates a business date being at offset business days from the original date.   | |
| int | JpmcdsBusinessDay (TDate date, long method, char *holidayFile, b TDate *outDate) | 
| int | JpmcdsBadDayConvValid (char *routine, long badDayConv) | 
| Validates a bad day convention.  | |
| int | JpmcdsIsBusinessDay (TDate date, char *name, TBoolean *isBusinessDay) | 
| Indicates whether a date is a business day.   | |
| int | JpmcdsDateToBusinessEOM (TDate inDate, char *name, TDate *outDate) | 
| Computes the last business day of the month.   | |
| EXPORT int | JpmcdsHolidayLoadFromDisk (char *name, char *filename) | 
| Loads a holiday cache entry from a disk file, removing old one if it exists.   | |
| int | JpmcdsHolidayListIsBusinessDay (TDate date, THolidayList *hl, TBoolean *isBusinessDay) | 
| Indicates whether a date is a business day.   | |
| int | JpmcdsHolidayListIsHoliday (TDate date, THolidayList *hl, TBoolean *isHoliday) | 
| int | JpmcdsHolidayListBusinessDay (TDate date, long badDayConv, THolidayList *hl, TDate *outDate) | 
| Converts date to a valid business date using the holiday list and bad day convention passed in.   | |
| int | JpmcdsMultiHolidayListBusinessDay (TDate date, long badDayConv, int numHolidayLists, THolidayList *holidayLists[], TDate *outDate) | 
| int | JpmcdsHolidayListBusinessDaysDiff (TDate fromDate, TDate toDate, THolidayList *hl, long *result) | 
| Calculates the number of business days between two dates (FROM & TO).   | |
| int | JpmcdsHolidayListAddBusinessDays (TDate fromDate, long numBusDays, THolidayList *hl, TDate *resultDate) | 
| Adds a number of business days to the original date.   | |
| int | JpmcdsHolidayListDateToBusinessEOM (TDate inDate, THolidayList *hl, TDate *outDate) | 
| Computes the last business day of the month.   | |
| #define JPMCDS_BAD_DAY_FOLLOW ((long)'F') | 
Use following good day
| #define JPMCDS_BAD_DAY_MODIFIED ((long)'M') | 
Try following, then previous if a month boundary is crossed
| #define JPMCDS_BAD_DAY_NONE ((long)'N') | 
Dont check for bad days
| #define JPMCDS_BAD_DAY_PREVIOUS ((long)'P') | 
Use previous good day
| #define JPMCDS_NUM_BAD_DAY_CONVS 4 | 
# bad day conventions (house keeping, do not use)
Using business day conventions (Following, Preceding, and Modified Following) calculates the next bisiness day if the input date is not a business day. Input and Output dates are represented as TDate types.
| date | (I) Input Date | |
| method | (I) See ldate.h | |
| holidayFile | (I) Filename w/ Holidays | |
| outDate | (O) output date | 
Calculates a business date being at offset business days from the original date.
| fromDate | (I) input date | |
| offset | (I) number of business days | |
| holidayFile | (I) holiday file specification | |
| result | (O) resulting business date | 
Computes the last business day of the month.
| inDate | (I) Date to be tested | |
| name | (I) Name of holiday file | |
| outDate | (O) TRUE or FALSE returned | 
| int JpmcdsHolidayListAddBusinessDays | ( | TDate | fromDate, | |
| long | numBusDays, | |||
| THolidayList * | hl, | |||
| TDate * | resultDate | |||
| ) | 
Adds a number of business days to the original date.
Equivalent to JpmcdsDateFromBusDaysOffset, except using a THolidayList structure instead of a holiday file name. Should be used if efficiency is an issue.
| fromDate | (I) Input date | |
| numBusDays | (I) Number of business days | |
| hl | (I) Holiday list structure | |
| resultDate | (O) Resulting business date | 
| int JpmcdsHolidayListBusinessDay | ( | TDate | date, | |
| long | badDayConv, | |||
| THolidayList * | hl, | |||
| TDate * | outDate | |||
| ) | 
Converts date to a valid business date using the holiday list and bad day convention passed in.
Returns SUCCESS if convention OK, FAILURE otherwise.
Equivalent to JpmcdsBusinessDay except using a THolidayList structure instead of a holiday file. Should be used if efficiency is an issue.
| date | (I) Arbitrary date. | |
| badDayConv | (I) Bad day convention for adjusting non-business days. Use one of the following: JPMCDS_BAD_DAY_FOLLOW JPMCDS_BAD_DAY_PREVIOUS JPMCDS_BAD_DAY_MODIFIED JPMCDS_BAD_DAY_NONE | |
| hl | (I) Holiday file list. | |
| outDate | (O) Valid business day. | 
| int JpmcdsHolidayListBusinessDaysDiff | ( | TDate | fromDate, | |
| TDate | toDate, | |||
| THolidayList * | hl, | |||
| long * | result | |||
| ) | 
Calculates the number of business days between two dates (FROM & TO).
Algorithm:
1. if FROM = TO, the result is 0
2. if FROM < TO, the result is the number of business days in the CLOSED interval of [FROM+1,TO]
3. if FROM > TO, the result is negated number of business days in the CLOSED interval of [TO,FROM-1]
Equivalent to JpmcdsBusinessDaysDiff but uses a THolidayList structure instead of a holiday file name. Should be used if efficiency is an issue.
| fromDate | (I) Earlier date | |
| toDate | (I) Later date | |
| hl | (I) Holiday list structure | |
| result | (O) Result value | 
Computes the last business day of the month.
| inDate | (I) Date to be tested | |
| hl | (I) Name of holiday file | |
| outDate | (O) TRUE or FALSE returned | 
| int JpmcdsHolidayListIsBusinessDay | ( | TDate | date, | |
| THolidayList * | hl, | |||
| TBoolean * | isBusinessDay | |||
| ) | 
Indicates whether a date is a business day.
Equivalent to JpmcdsIsBusinessDay but uses THolidayList structure in place of holiday file name.
| date | (I) Input Date | |
| hl | (I) Holiday list structure | |
| isBusinessDay | (O) TRUE if a business day | 
| int JpmcdsHolidayListIsHoliday | ( | TDate | date, | |
| THolidayList * | hl, | |||
| TBoolean * | isHoliday | |||
| ) | 
Equivalent to JpmcdsIsHoliday, but uses a THolidayList structure instead of a holiday file name (and output type is TBoolean rather than long).
Does not take week-ends into account.
| date | (I) Arbitrary date | |
| hl | (I) Holiday list structure | |
| isHoliday | (O) 0 = not a holiday, 1 = is a holiday | 
| EXPORT int JpmcdsHolidayLoadFromDisk | ( | char * | name, | |
| char * | filename | |||
| ) | 
Loads a holiday cache entry from a disk file, removing old one if it exists.
| name | (I) name associated with holidays | |
| filename | (I) filename to load | 
| int JpmcdsIsBusinessDay | ( | TDate | date, | |
| char * | name, | |||
| TBoolean * | isBusinessDay | |||
| ) | 
Indicates whether a date is a business day.
| date | (I) Input Date | |
| name | (I) Filename w/ Holidays | |
| isBusinessDay | (O) | 
| int JpmcdsMultiHolidayListBusinessDay | ( | TDate | date, | |
| long | badDayConv, | |||
| int | numHolidayLists, | |||
| THolidayList * | holidayLists[], | |||
| TDate * | outDate | |||
| ) | 
See JpmcdsHolidayListBusinessDay.
| date | (I) Arbitrary date. | |
| badDayConv | (I) Bad day convention for adjusting non-business days. Use one of the following: JPMCDS_BAD_DAY_FOLLOW JPMCDS_BAD_DAY_PREVIOUS JPMCDS_BAD_DAY_MODIFIED JPMCDS_BAD_DAY_NONE | |
| numHolidayLists | (I) Size of holidayLists[] array. | |
| holidayLists | (I) Holiday lists. | |
| outDate | (O) Valid business day. |