busday.h File Reference

#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.

Detailed Description


Define Documentation

#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)


Function Documentation

int JpmcdsBusinessDay ( TDate  date,
long  method,
char *  holidayFile,
b TDate outDate 
)

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.

Parameters:
date (I) Input Date
method (I) See ldate.h
holidayFile (I) Filename w/ Holidays
outDate (O) output date

int JpmcdsDateFromBusDaysOffset ( TDate  fromDate,
long  offset,
char *  holidayFile,
TDate result 
)

Calculates a business date being at offset business days from the original date.

Parameters:
fromDate (I) input date
offset (I) number of business days
holidayFile (I) holiday file specification
result (O) resulting business date

int JpmcdsDateToBusinessEOM ( TDate  inDate,
char *  name,
TDate outDate 
)

Computes the last business day of the month.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
fromDate (I) Earlier date
toDate (I) Later date
hl (I) Holiday list structure
result (O) Result value

int JpmcdsHolidayListDateToBusinessEOM ( TDate  inDate,
THolidayList *  hl,
TDate outDate 
)

Computes the last business day of the month.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.

Parameters:
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.


Distributed by BN Algorithms Ltd -- consulting in quantitative finance, mathematical algorithms and software implementations. CDS Home Page. For enquires contact webs@bnikolic.co.uk.
This documentation is derived from ISDA CDS Standard Model version 1.7. You can get a copy of the original ISDA code at www.bnikolic.co.uk. This is a derivative work under the terms of the ISDA CDS Standard Model Public License. BN Algorithms Ltd licenses this work to you solely for on-screen viewing on your own computer. Making copies and further distribution of this work is prohibited.
This documentation is provided "as-is", without warranty of any kind, either expressed or implied, including, without limitation, warranties that the documentation is free of defects, merchantable, fit for a particular purpose or non-infringing. the entire risk as to the quality of the documentation is with you. Should this documentation prove defective in any respect, you (not the licensor) assume the cost of any necessary correction. This disclaimer of warranty constitutes an essential part of this license.