date_sup.h File Reference

#include "cgeneral.h"
#include "cdate.h"

Functions

int JpmcdsMakeTDateArray (TDate baseDate, TDateInterval *interval, int startIdx, int arrayIncrement, int ndates, TDate *dateArray)
 Make an array of TDates.
int JpmcdsCountDates (TDate fromDate, TDate toDate, TDateInterval *interval, int *numIntervals, int *extraDays)
 Counts # TDateIntervals in a range of dates.
int JpmcdsFreq2TDateInterval (long freq, TDateInterval *interval)
 Converts a frequency (# times/year) to a TDateInterval.
int JpmcdsDateIntervalToFreq (TDateInterval *interval, double *freq)
 Converts a TDateInterval to a frequency.
int JpmcdsDateIntervalToYears (TDateInterval *interval, double *years)
 Converts a TDateInterval to # years.
int JpmcdsDateFromDateAndOffset (TDate oldDate, TDateInterval *interval, int index, TDate *newDate)
 Calculates a date from another date and offset represented by interval and index.

Detailed Description


Function Documentation

int JpmcdsCountDates ( TDate  fromDate,
TDate  toDate,
TDateInterval interval,
int *  numIntervals,
int *  extraDays 
)

Counts # TDateIntervals in a range of dates.

Note that fromDate can be either later than or earlier than toDate.

In order to make this routine speedier we start from a low estimate of result value that is calculated using division (speedy approach). Based on the low estimate we calculate the results.

Note that we allways calculate currDate based on fromDate rather than lastDate. We MUST do it because date + (n*Interval) = ((date + Interval)+Interval) ... )+Interval is not always true

int JpmcdsDateFromDateAndOffset ( TDate  oldDate,
TDateInterval interval,
int  index,
TDate newDate 
)

Calculates a date from another date and offset represented by interval and index.

newDate = oldDate + index*interval

int JpmcdsDateIntervalToFreq ( TDateInterval interval,
double *  freq 
)

Converts a TDateInterval to a frequency.

Parameters:
interval (I)
freq (O) # times per year

int JpmcdsDateIntervalToYears ( TDateInterval interval,
double *  years 
)

Converts a TDateInterval to # years.

Note that if the TDateInterval is a month type (A,S,Q), the routine uses 30/360 to compute the year fraction. If it is a day type (D,W), it uses Act/365F.

int JpmcdsFreq2TDateInterval ( long  freq,
TDateInterval interval 
)

Converts a frequency (# times/year) to a TDateInterval.

Returns SUCCESS/FAILURE.

int JpmcdsMakeTDateArray ( TDate  baseDate,
TDateInterval interval,
int  startIdx,
int  arrayIncrement,
int  ndates,
TDate dateArray 
)

Make an array of TDates.

Returns SUCCESS/FAILURE.


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.