API
Functions
DayCounts.yearfrac
— Functionyearfrac(startdate::Date, enddate::Date, dc::DayCount)
Compute the fractional number of years between startdate
and enddate
, according to the DayCount
object dc
.
- If
startdate == enddate
, then the result is zero. - If
startdate > enddate
, then the result is-yearfrac(enddate, startdate, dc)
.
DayCount
types
Actual conventions
DayCounts.Actual365Fixed
— TypeActual365Fixed()
Actual/365 (Fixed) day count convention.
The year fraction is computed as:
Reference
- 2006 ISDA definitions, §4.16 (d)
DayCounts.Actual360
— TypeActual360()
Actual/360 day count convention.
The year fraction is computed as:
Reference
- 2006 ISDA definitions, §4.16 (e)
DayCounts.ActualActualISDA
— TypeActualActualISDA()
Actual/Actual (ISDA) day count convention.
The year fraction is computed as:
For the purposes of above, the start date is included and the end date is excluded.
Reference
- 2006 ISDA definitions, §4.16 (b)
DayCounts.ActualActualICMA
— TypeActualActualICMA(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:
This ensures that:
- all days in a period are of equal length, and
- all periods are of equal length.
Reference
- 2006 ISDA definitions, §4.16 (c).
- ICMA Rule Book, Rule 251.1 (iii).
- EMU and Market Conventions: Recent Developments, ISDA - BS:9951.1, §4. The Actual/Actual Day Count Convention.
DayCounts.ActualActualExcel
— TypeActualActualExcel()
Actual/Actual day count convention, as computed via Microsoft Excel YEARFRAC
with the basis option of 1
.
The year fraction is
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
DayCounts.Thirty360
— TypeThirty360()
30/360 or Bond Basis day count convention.
The year fraction is computed as:
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)
DayCounts.ThirtyE360
— TypeThirtyE360()
30E/360 or Eurobond Basis day count convention.
The year fraction is computed as:
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)
DayCounts.ThirtyE360ISDA
— TypeThirtyE360ISDA(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:
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,
- $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,
Reference
- 2006 ISDA definitions, §4.16 (h)
DayCounts.Thirty360Excel
— TypeThirty360Excel()
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