Record Class OvernightLeg

java.lang.Object
java.lang.Record
com.quantfinlib.rates.OvernightLeg
Record Components:
start - unadjusted effective date
end - unadjusted maturity
spread - spread added to the compounded rate (simple, not compounded)
convention - schedule, day count, calendar and payment lag
overnight - lookback, shift and lockout
fixings - published fixings of the index
All Implemented Interfaces:
FloatLeg

public record OvernightLeg(LocalDate start, LocalDate end, double spread, LegConvention convention, OvernightConvention overnight, FixingHistory fixings) extends Record implements FloatLeg
A compounded-in-arrears overnight floating leg (SOFR, ESTR, SONIA) with payment lag, lookback, observation shift, lockout, stubs and realised fixings for seasoned trades.

The plain idea: each coupon is the daily-compounded overnight rate over its period plus a spread. Days before the valuation date use the published fixings in FixingHistory; later days are forecast as the one-day simple forward of the projection curve, r(f) = (P(f)/P(f+1bd) - 1)/alpha.

Formal statement (ISDA 2021 section 6.9; OvernightConvention gives the lookback L, shift flag and lockout k): with business days o_0 < ... < o_n of the observation window ([s, e], or [s - L, e - L] in business days under a shift), and alpha_i = dayCount.yearFraction(o_i, o_{i+1}),

  R = ( prod_{i<n} (1 + r_i alpha_i) - 1 ) / sum_{i<n} alpha_i

where r_i is the fixing for o_i under a shift, or for o_i - L business days without one (the weights then stay on the accrual days); the last k rates are replaced by r_{n-k-1}. The coupon (R + spread) * tau is paid on the period's payment date.

Worked example: with OvernightConvention.IN_ARREARS, no spread, no payment lag and projection = discount curve, the leg PV telescopes to P(start) - P(end), the value OisSwap uses; the tests pin that to 1e-13 (roundoff over the daily product) and cross-check the conventions against QuantLib output (golden file golden/quantlib-sofr.csv).

  • Constructor Details

  • Method Details

    • periods

      public List<LegConvention.Period> periods()
      Description copied from interface: FloatLeg
      The leg's accrual periods.
      Specified by:
      periods in interface FloatLeg
      Returns:
      the periods, ascending
    • couponRate

      public double couponRate(LegConvention.Period period, DiscountCurve projection)
      Description copied from interface: FloatLeg
      The coupon rate (index rate plus spread) of one period, from published fixings where they exist and the projection curve otherwise.
      Specified by:
      couponRate in interface FloatLeg
      Parameters:
      period - one of FloatLeg.periods()
      projection - projection curve (its valuation date is the valuation date)
      Returns:
      the annualised coupon rate
    • compoundedRate

      public double compoundedRate(LocalDate accrualStart, LocalDate accrualEnd, DiscountCurve projection)
      The compounded overnight rate (no spread) for an accrual period.
      Parameters:
      accrualStart - adjusted accrual start
      accrualEnd - adjusted accrual end
      projection - curve forecasting fixings on or after its valuation date
      Returns:
      the annualised compounded rate
    • 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.
    • start

      public LocalDate start()
      Returns the value of the start record component.
      Returns:
      the value of the start record component
    • end

      public LocalDate end()
      Returns the value of the end record component.
      Returns:
      the value of the end record component
    • spread

      public double spread()
      Returns the value of the spread record component.
      Returns:
      the value of the spread record component
    • convention

      public LegConvention convention()
      Returns the value of the convention record component.
      Returns:
      the value of the convention record component
    • overnight

      public OvernightConvention overnight()
      Returns the value of the overnight record component.
      Returns:
      the value of the overnight record component
    • fixings

      public FixingHistory fixings()
      Returns the value of the fixings record component.
      Returns:
      the value of the fixings record component