Record Class VanillaSwap
java.lang.Object
java.lang.Record
com.quantfinlib.rates.VanillaSwap
- Record Components:
fixed- the fixed legfloating- the floating leg
A fixed-for-floating swap built from two convention-driven legs: the
replacement for the single-curve, annual,
tau = 1 methods of the
SwapPricer (removed in 4.0). Each leg carries its own frequency, day
count, calendar, roll, stub and payment lag (LegConvention); the
floating leg is a compounded overnight leg (OvernightLeg, with
lookback, observation shift, lockout and realised fixings) or a term-rate
leg (TermRateLeg).
Formal statement, per unit notional, valuation date = the discount curve's, only coupons paid after it counted:
payer PV = PV_float - K * A par rate = PV_float / A (the K that sets payer PV to zero)
with A the FixedLeg.annuity(DiscountCurve). A seasoned trade is valued
the same way: past coupons are dropped, the current coupon combines
published fixings and forecasts.
Worked example: a 5y SOFR OIS, annual both legs, ACT/360, 2-day payment
lag, 2-day lookback: new VanillaSwap(new FixedLeg(s, e, k, conv),
new OvernightLeg(s, e, 0, conv, new OvernightConvention(2, false, 0), fixings));
its par rate on a curve is pinned against QuantLib in the golden test.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptiondoubleannuity(DiscountCurve discount) Fixed-leg annuity per unit notional.final booleanIndicates whether some other object is "equal to" this one.fixed()Returns the value of thefixedrecord component.floating()Returns the value of thefloatingrecord component.doublefloatLegPv(DiscountCurve discount, DiscountCurve projection) Floating-leg PV per unit notional.final inthashCode()Returns a hash code value for this object.doubleparRate(DiscountCurve discount, DiscountCurve projection) Par fixed rate.doublepayerPv(DiscountCurve discount, DiscountCurve projection) PV per unit notional of paying fixed and receiving floating.doublereceiverPv(DiscountCurve discount, DiscountCurve projection) PV per unit notional of receiving fixed and paying floating.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
VanillaSwap
-
-
Method Details
-
annuity
Fixed-leg annuity per unit notional.- Parameters:
discount- discount curve- Returns:
- the annuity
-
floatLegPv
Floating-leg PV per unit notional.- Parameters:
discount- discount curveprojection- projection curve- Returns:
- present value
-
parRate
Par fixed rate.- Parameters:
discount- discount curveprojection- projection curve- Returns:
- the fixed rate that prices the swap at zero
-
payerPv
PV per unit notional of paying fixed and receiving floating.- Parameters:
discount- discount curveprojection- projection curve- Returns:
- present value
-
receiverPv
PV per unit notional of receiving fixed and paying floating.- Parameters:
discount- discount curveprojection- projection curve- Returns:
- present value
-
toString
-
hashCode
-
equals
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. All components in this record class are compared withObjects::equals(Object,Object). -
fixed
-
floating
-