Return number of days in coupon period containing the settlement date. <span align="right" style="background-color:99FF99"><strong>Excel: COUPDAYS</strong></span>

View versions (1)

Interface

#include <codecogs/finance/banking/coupondaysinperiod.h>

using namespace Finance::Banking;

Calculate the number of days in the coupon period that contains the settlement date. The number of days returned depends on the year basis specified:

For yb_USA, yb_EU and yb_Act360 the returned value is:

days\ =\ \frac{360}{freq}
(1)

Where freq is the number of times per year the payment is made (1 for yf_Annual, 2 for yf_SemiAnnual or 4 for yf_Quarterly).

For yb_Act365 the returned value is:

days\ =\ \frac{365}{freq}
(2)

(Using integer division)

Finally, for yb_Act, the exact number of days between the two dates (taking into account leap years) is returned.

Example 1

#include <stdio.h>

#include <codecogs/units/date/date.h>
#include <codecogs/units/date/dateymd.h>
#include <codecogs/finance/banking/coupondaysinperiod.h>

int main(void)
{
  int settDate=Units::Date::date(1998, 1, 25);
  int maturityDate=Units::Date::date(1999, 11, 15);
  int days=Finance::Banking::couponDaysInPeriod(settDate,
       maturityDate, 
       Finance::Banking::yf_SemiAnnual,
       Finance::Banking::yb_Act);
  int y, m, d;
  
  Units::Date::dateYMD(settDate, y, m, d);
  printf("settlement=%i/%i/%i\n", y, m, d);
  
  Units::Date::dateYMD(maturityDate, y, m, d);
  printf("maturity=%i/%i/%i\n", y, m, d);
  
  printf("days in period=%i\n", days);

  return 0;
}

Output:

settlement=1998/1/25
maturity=1999/11/15
days in period=181

Parameters

sett
The settlement date, expressed as a serial Julian date.
mat
The maturity date of the settlement, expressed as a serial Julian date.
freq
The frequency with which payments are made:
Blank

\copydoc YearlyFreq

Parameters

basis
The year basis to use for the calculation:
Blank

\copydoc YearBasis.

Returns

The number of days in the coupon period.
GPL Licence — free for non commercial use. See Licence details.