Enum Class DayCount

java.lang.Object
java.lang.Enum<DayCount>
com.quantfinlib.rates.DayCount
All Implemented Interfaces:
Serializable, Comparable<DayCount>, Constable

public enum DayCount extends Enum<DayCount>
Day-count conventions: the year fraction between two dates as real term sheets define it — because finance never agreed on how long a year is, and the disagreement is worth real money.

An interest payment is notional × rate × yearFraction, and the same two calendar dates produce different year fractions under different conventions: 2024-01-15 → 2024-07-15 is 182 days, which is 0.5056 under ACT/360 (money markets: USD deposits, SOFR), 0.4986 under ACT/365 (GBP money markets, many swap fixed legs), and exactly 0.5 under 30/360 (US corporate bonds, which pretend every month has 30 days so coupons come out round). On a $100m swap leg at 5%, picking the wrong convention moves the payment by tens of thousands of dollars — a booking error that surfaces as an unexplained break on settlement day, not a model error.

The rule in practice: the convention is part of the instrument (read the term sheet), never a system-wide default. That is why BondPricer and the curve utilities take a DayCount argument instead of assuming one.

Definitions follow the 2006 ISDA Definitions, section 4.16: THIRTY_360 is 30/360 Bond Basis (4.16(f)), THIRTY_E_360 is 30E/360 Eurobond Basis (4.16(g)), THIRTY_E_360_ISDA is 30E/360 (ISDA) (4.16(h)), ACT_ACT_ISDA is 4.16(b). ACT_ACT_ICMA (ICMA Rule 251, 4.16(c)) depends on the coupon period and frequency as well as the two dates: BondPricer handles it, and actActIcma(LocalDate, LocalDate, LocalDate, LocalDate, int) computes it directly. BUS/252 (Brazil) needs a holiday calendar and is bus252(BusinessCalendar, LocalDate, LocalDate).

  • Nested Class Summary

    Nested classes/interfaces inherited from class Enum

    Enum.EnumDesc<E>
  • Enum Constant Summary

    Enum Constants
    Enum Constant
    Description
    Actual days / 360 — money markets (USD LIBOR/SOFR style).
    Actual days / 365 (fixed) — GBP money markets, many swaps.
    ACT/ACT ICMA — government bonds (US Treasuries, gilts, Bunds).
    ACT/ACT ISDA — government bonds and ISDA swap legs; leap-year exact.
    US (Bond Basis) 30/360 — corporate and agency bonds.
    30E/360 (Eurobond Basis): both day numbers capped at 30, with no condition on the other date.
    30E/360 (ISDA): a date on the last day of its month counts as the 30th, except that the termination date is left alone when it is the last day of February.
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    actActIcma(LocalDate start, LocalDate end, LocalDate periodStart, LocalDate periodEnd, int frequency)
    ACT/ACT ICMA (ICMA Rule 251): days(start, end) / (frequency × days(periodStart, periodEnd)), where [periodStart, periodEnd) is the regular (quasi-)coupon period containing [start, end).
    static double
    bus252(BusinessCalendar calendar, LocalDate start, LocalDate end)
    BUS/252: business days d with start <= d < end on calendar, divided by 252 (Brazilian DI and government bond convention, ANBIMA).
    static DayCount
    Returns the enum constant of this class with the specified name.
    static DayCount[]
    Returns an array containing the constants of this enum class, in the order they are declared.
    abstract double
    Year fraction from start (inclusive) to end (exclusive).
    double
    yearFraction(LocalDate start, LocalDate end, LocalDate terminationDate)
    Year fraction when the convention depends on whether end is the termination (maturity) date.

    Methods inherited from class Object

    getClass, notify, notifyAll, wait, wait, wait
  • Enum Constant Details

    • ACT_360

      public static final DayCount ACT_360
      Actual days / 360 — money markets (USD LIBOR/SOFR style).
    • ACT_365

      public static final DayCount ACT_365
      Actual days / 365 (fixed) — GBP money markets, many swaps.
    • THIRTY_360

      public static final DayCount THIRTY_360
      US (Bond Basis) 30/360 — corporate and agency bonds.
    • THIRTY_E_360

      public static final DayCount THIRTY_E_360
      30E/360 (Eurobond Basis): both day numbers capped at 30, with no condition on the other date.
    • THIRTY_E_360_ISDA

      public static final DayCount THIRTY_E_360_ISDA
      30E/360 (ISDA): a date on the last day of its month counts as the 30th, except that the termination date is left alone when it is the last day of February. The two-date form treats end as not being the termination date; use yearFraction(LocalDate, LocalDate, LocalDate) for the final period.
    • ACT_ACT_ICMA

      public static final DayCount ACT_ACT_ICMA
      ACT/ACT ICMA — government bonds (US Treasuries, gilts, Bunds). Needs the coupon period, so the two-date form throws; use actActIcma(LocalDate, LocalDate, LocalDate, LocalDate, int) or pass this constant to BondPricer.
    • ACT_ACT_ISDA

      public static final DayCount ACT_ACT_ISDA
      ACT/ACT ISDA — government bonds and ISDA swap legs; leap-year exact.
  • Method Details

    • values

      public static DayCount[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static DayCount valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null
    • yearFraction

      public abstract double yearFraction(LocalDate start, LocalDate end)
      Year fraction from start (inclusive) to end (exclusive).
    • yearFraction

      public double yearFraction(LocalDate start, LocalDate end, LocalDate terminationDate)
      Year fraction when the convention depends on whether end is the termination (maturity) date. Only THIRTY_E_360_ISDA uses it.
    • actActIcma

      public static double actActIcma(LocalDate start, LocalDate end, LocalDate periodStart, LocalDate periodEnd, int frequency)
      ACT/ACT ICMA (ICMA Rule 251): days(start, end) / (frequency × days(periodStart, periodEnd)), where [periodStart, periodEnd) is the regular (quasi-)coupon period containing [start, end). A full regular coupon period therefore has fraction exactly 1/frequency.
    • bus252

      public static double bus252(BusinessCalendar calendar, LocalDate start, LocalDate end)
      BUS/252: business days d with start <= d < end on calendar, divided by 252 (Brazilian DI and government bond convention, ANBIMA).