Record Class LegConvention

java.lang.Object
java.lang.Record
com.quantfinlib.rates.LegConvention
Record Components:
paymentsPerYear - payments per year, a divisor of 12
dayCount - accrual day count of the leg
calendar - business-day calendar for rolls and the payment lag
roll - roll convention for accrual dates
stub - where an irregular period goes
endOfMonth - end-of-month rule for the unadjusted schedule
paymentLagDays - business days from accrual end to payment, >= 0

public record LegConvention(int paymentsPerYear, DayCount dayCount, BusinessCalendar calendar, BusinessCalendar.Roll roll, BusinessCalendar.StubType stub, boolean endOfMonth, int paymentLagDays) extends Record
The schedule and accrual conventions of one swap leg: how often it pays, how a period's year fraction is measured, which calendar and roll adjust the dates, where a stub goes, and how many business days after the accrual end the payment is made.

The plain idea: two swaps with the same dates and rates can differ in value only through these fields, so they are stated once per leg instead of being assumed (the SwapPricer methods on a YieldCurve, removed in 4.0, assumed an annual fixed leg with tau = 1).

Formally, the unadjusted period ends come from BusinessCalendar.unadjustedSchedule(LocalDate, LocalDate, int, BusinessCalendar.StubType, boolean); accrual dates are those dates rolled with roll (the start included); the payment date of a period ending at e is calendar.addBusinessDays(e, paymentLagDays). A SOFR OIS under the ISDA 2021 / ARRC convention is (1, ACT_360, US calendar, MODIFIED_FOLLOWING, SHORT_FRONT, false, 2).

  • Constructor Details

  • Method Details

    • of

      public static LegConvention of(int paymentsPerYear, DayCount dayCount, BusinessCalendar calendar, BusinessCalendar.Roll roll)
      A convention with a short front stub, no end-of-month rule and no payment lag.
      Parameters:
      paymentsPerYear - payments per year, a divisor of 12
      dayCount - accrual day count
      calendar - business-day calendar
      roll - roll convention
      Returns:
      the convention
    • withPaymentLag

      public LegConvention withPaymentLag(int days)
      The same convention with a different payment lag.
      Parameters:
      days - business days from accrual end to payment
      Returns:
      the new convention
    • withStub

      public LegConvention withStub(BusinessCalendar.StubType stubType)
      The same convention with a different stub type.
      Parameters:
      stubType - where the irregular period goes
      Returns:
      the new convention
    • periods

      public List<LegConvention.Period> periods(LocalDate start, LocalDate end)
      The accrual periods of a leg from start to end (unadjusted dates), ascending, with adjusted accrual dates and payment dates.
      Parameters:
      start - unadjusted effective date
      end - unadjusted maturity date
      Returns:
      the periods, at least one
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • paymentsPerYear

      public int paymentsPerYear()
      Returns the value of the paymentsPerYear record component.
      Returns:
      the value of the paymentsPerYear record component
    • dayCount

      public DayCount dayCount()
      Returns the value of the dayCount record component.
      Returns:
      the value of the dayCount record component
    • calendar

      public BusinessCalendar calendar()
      Returns the value of the calendar record component.
      Returns:
      the value of the calendar record component
    • roll

      public BusinessCalendar.Roll roll()
      Returns the value of the roll record component.
      Returns:
      the value of the roll record component
    • stub

      Returns the value of the stub record component.
      Returns:
      the value of the stub record component
    • endOfMonth

      public boolean endOfMonth()
      Returns the value of the endOfMonth record component.
      Returns:
      the value of the endOfMonth record component
    • paymentLagDays

      public int paymentLagDays()
      Returns the value of the paymentLagDays record component.
      Returns:
      the value of the paymentLagDays record component