dcf#

rateslib.calendars.dcf(start, end, convention, termination=NoInput.blank, frequency_months=NoInput.blank, stub=NoInput.blank, roll=NoInput.blank, calendar=NoInput.blank)#

Calculate the day count fraction of a period.

Parameters:
  • start (datetime) – The adjusted start date of the calculation period.

  • end (datetime) – The adjusted end date of the calculation period.

  • convention (str) – The day count convention of the calculation period accrual. See notes.

  • termination (datetime, optional) –

    The adjusted termination date of the leg. Required only if convention is one of the following values:

    • ”30E360ISDA” (since end Feb is adjusted to 30 unless it aligns with termination of a leg)

    • ”ACTACTICMA”, “ACTACTISMA”, “ACTACTBOND”, “ACTACTICMA_STUB365F”, (if the period is a stub the termination of the leg is used to assess front or back stubs and adjust the calculation accordingly)

  • frequency_months (int, optional) – The number of months according to the frequency of the period. Required only with specific values for convention.

  • stub (bool, optional) – Required for “ACTACTICMA”, “ACTACTISMA”, “ACTACTBOND”, “ACTACTICMA_STUB365F”. Non-stub periods will return a fraction equal to the frequency, e.g. 0.25 for quarterly.

  • roll (str, int, optional) – Used by “ACTACTICMA”, “ACTACTISMA”, “ACTACTBOND”, “ACTACTICMA_STUB365F” to project regular periods when calculating stubs.

  • calendar (str, Calendar, optional) – Currently unused.

Return type:

float

Notes

Permitted values for the convention are:

  • “1”: Returns 1 for any period.

  • “1+”: Returns the number of months between dates divided by 12.

  • “Act365F”: Returns actual number of days divided by a fixed 365 denominator.

  • “Act365F+”: Returns the number of years and the actual number of days in the fractional year divided by a fixed 365 denominator.

  • “Act360”: Returns actual number of days divided by a fixed 360 denominator.

  • “30E360”, “EuroBondBasis”: Months are treated as having 30 days and start and end dates are converted under the rule:

    • start day is minimum of (30, start day),

    • end day is minimum of (30, end day).

  • “30360”, “360360”, “BondBasis”: Months are treated as having 30 days and start and end dates are converted under the rule:

    • start day is minimum of (30, start day),

    • end day is minimum of (30, start day) only if start day was adjusted.

  • “30360ISDA”: Months are treated as having 30 days and start and end dates are converted under the rule:

    • start day is converted to 30 if it is a month end.

    • end day is converted to 30 if it is a month end.

    • end day is not converted if it coincides with the leg termination and is in February.

  • “ActAct”, “ActActISDA”: Calendar days between start and end are divided by 365 or 366 dependent upon whether they fall within a leap year or not.

  • “ActActICMA”, “ActActISMA”, “ActActBond”, “ActActICMA_stub365f”: Returns a fraction relevant to the frequency of the schedule if a regular period. If a stub then projects a regular period and returns a fraction of that period.

  • “Bus252”: Business days between start and end divided by 252. If business days, start is included whilst end is excluded.

Further information can be found in the 2006 ISDA definitions and 2006 ISDA 30360 example.

Examples

In [1]: dcf(dt(2000, 1, 1), dt(2000, 4, 3), "Act360")
Out[1]: 0.25833333333333336

In [2]: dcf(dt(2000, 1, 1), dt(2000, 4, 3), "Act365f")
Out[2]: 0.2547945205479452

In [3]: dcf(dt(2000, 1, 1), dt(2000, 4, 3), "ActActICMA", dt(2010, 1, 1), 3, False)
Out[3]: 0.25

In [4]: dcf(dt(2000, 1, 1), dt(2000, 4, 3), "ActActICMA", dt(2010, 1, 1), 3, True)
Out[4]: 0.2554347826086957