Skip to content
All library documents

Building QuantLib Swap Legs with Different Reset and Payment Frequencies

Article Quant Q&A · Author: AZhu

Summary

The document explains how to model a floating-rate swap when the rate reset or calculation frequency differs from the payment frequency, a setup that the standard VanillaSwap interface does not directly support. Its example is a leg that pays semiannually while resetting annually.

The suggested approach is to adapt QuantLib’s floating-leg construction function to accept a separate reset frequency, build the required coupons, and pass the resulting leg to a Swap constructor. For a LIBOR-only implementation, using IborCoupon directly can simplify the modified function; the fixed leg can be constructed with the FixedRateLeg class. This is an implementation outline rather than a complete example: it gives no code, pricing results, or guidance on day-count conventions and schedule details.

Key ideas

  • A standard VanillaSwap assumes the floating leg’s payment and calculation reset frequencies match.
  • Adapt floating-leg construction to accept a separate reset frequency when they differ.
  • For a LIBOR-only leg, constructing IborCoupon objects directly can reduce implementation complexity.
  • Build the fixed leg separately and combine both legs in a Swap object.

Tags

Full text
# Using quantlib to price swaps with different payment and calculation resets for floating leg


# Using quantlib to price swaps with different payment and calculation resets for floating leg












I understand the VanillaSwap object assumes that payment and calculation resets are the same, so is there any way we could use quantlib to price a swap with different reset and calculation frequencies? (say payment is semiannual but resets is annual).

A few candidates I've considered are:





Is there any other simpler way to deal with this given that everything else is similar to a VanillaSwap except using different payment and calculation dates?

## Answer by Luigi Ballabio (score 2, accepted)

https://quant.stackexchange.com/a/29787

There's no code for this at this time. What you can do is clone and modify the `FloatingLeg` function in `ql/cashflows/cashflowvectors.hpp` so that it takes another frequency for the resets and uses it to build the coupons together with the other inputs. If you only need LIBOR coupons, you can remove the template arguments from the modified functions and use `IborCoupon` directly to reduce its complexity. So yes, you'll repeatedly create the coupons, but you'll write the code only once in the function.

Once you write it, you can call your modified function and pass the returned leg to the `Swap` constructor. The fixed leg can be built by the `FixedRateLeg` class, declared in `ql/cashflows/fixedratecoupon.hpp`.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.