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. 30/360's end-of-month adjustments (the 31st treated as the 30th when the start is on the 30th) are the US Bond Basis variant; other markets use slightly different 30/360 flavors — stated here so nobody "fixes" the adjustment against ISDA 30E/360.

  • 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.
    • 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).