API

# API

## Functions

yearfrac(startdate::Date, enddate::Date, dc::DayCount)

Compute the fractional number of years between startdate and enddate, according to the DayCount objectdc.

• If startdate == enddate, then the result is zero.
• If startdate > enddate, then the result is -yearfrac(enddate, startdate, dc).

## DayCount types

### Actual conventions

Actual365Fixed()

Actual/365 (Fixed) day count convention.

The year fraction is computed as:

$\frac{\text{# of days}}{365}$

Reference

• 2006 ISDA definitions, §4.16 (d)
Actual360()

Actual/360 day count convention.

The year fraction is computed as:

$\frac{\text{# of days}}{360}$

Reference

• 2006 ISDA definitions, §4.16 (e)
ActualActualISDA()

Actual/Actual (ISDA) day count convention.

The year fraction is computed as:

$\frac{\text{# of days in standard year}}{365} + \frac{\text{# of days in leap year}}{366}$

For the purposes of above, the start date is included and the end date is excluded.

Reference

• 2006 ISDA definitions, §4.16 (b)
ActualActualICMA(schedule::StepRange{Date,Month})

Actual/Actual (ICMA), Actual/Actual (ISMA) or ISMA-99 day count convention.

Note that this is dependent on the coupon or payment schedule of the underlying security. This is provided via the schedule argument, currently only date ranges with steps of months are supported.

The year fraction is computed as:

$\sum_{\text{schedule period}} \frac{\text{# of days in period}}{\text{length of period} \times \text{periods per year}}$

This ensures that:

• all days in a period are of equal length, and
• all periods are of equal length.

Reference

ActualActualExcel()

Actual/Actual day count convention, as computed via Microsoft Excel YEARFRAC with the basis option of 1.

The year fraction is

$\frac{\text{# of days}}{D}$

where:

• if start date and end date are in the same calendar year, then $D$ is the number of days in that calendar year,
• otherwise if the end date is less than or equal to one year after the start date, then
• $D = 366$ if the interval includes February 29 (including both the start and end dates), or
• $D = 365$ otherwise.
• otherwise it is the average length of the years included in the interval (this does not depend on where the start or end dates fall within those years).

Reference

### 30/360 conventions

Thirty360()

30/360 or Bond Basis day count convention.

The year fraction is computed as:

$\frac{360 \times (y_2 - y_1) + 30 \times (m_2 - m_1) + (d_2 - d_1)}{360}$

where

• $y_1$ and $y_2$ are the years of the start and end date, respectively.
• $m_1$ and $m_2$ are the months of the start and end date, respectively.
• $d_1$ is the day of the month at the start date, unless it is 31, in which case it is
• $d_2$ is the day of the month at the end date, unless it is 31 and $d_1 ≥ 30$, in which case it is 30.

Reference

• 2006 ISDA definitions, §4.16 (f)
ThirtyE360()

30E/360 or Eurobond Basis day count convention.

The year fraction is computed as:

$\frac{360 \times (y_2 - y_1) + 30 \times (m_2 - m_1) + (d_2 - d_1)}{360}$

where

• $y_1$ and $y_2$ are the years of the start and end date, respectively.
• $m_1$ and $m_2$ are the months of the start and end date, respectively.
• $d_1$ is the day of the month at the start date, unless it is 31st day of the month, in which case it is 30.
• $d_2$ is the day of the month at the end date, unless it is 31st day of the month, in which case it is 30.

Reference

• 2006 ISDA definitions, §4.16 (g)
ThirtyE360ISDA(maturity::Date)

30E/360 (ISDA) day count convention. Note that this is dependant of the maturity date of the underlying security, provided as the maturity argument.

The year fraction is computed as:

$\frac{360 \times (y_2 - y_1) + 30 \times (m_2 - m_1) + (d_2 - d_1)}{360}$

where

• $y_1$ and $y_2$ are the years of the start and end date, respectively.
• $m_1$ and $m_2$ are the months of the start and end date, respectively.
• $d_1$ is the day of the month at the start date, unless it is:
• the last day of February, or
• the 31st day of the month,
in which case it is 30.
• $d_2$ is the day of the month at the end date, unless it is:
• the last day of February and not the maturity date, or
• the 31st day of the month,
in which case it is 30.

Reference

• 2006 ISDA definitions, §4.16 (h)
Thirty360Excel()

US (NASD) 30/360 day count convention, as computed via Microsoft Excel YEARFRAC with the basis option of 0.

This differs from Thirty360 when:

• if the start date is the last day of February, then
• $d_1$ is 30, and
• if the end date is also the last day of February $d_2$ is also 30.

Reference