3
$\begingroup$

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:

  1. NonstandardSwap: however I think this does not allow different payment and reset schedules too.

  2. Swap: it takes 2 legs but Leg itself is virtual, however there are many other ways implementing this, one way is to use the IborCoupon however that seems to require repeatedly creating every single coupon in order to constructing Leg.

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?

$\endgroup$
2
  • $\begingroup$ How would that swap (semiannual payment and annual reset) work? You'd fix a rate annually and then pay it for two consecutive coupons? $\endgroup$ Commented Aug 22, 2016 at 9:07
  • $\begingroup$ @LuigiBallabio Sure, you can always fix the rate once and pay it in several installments, I guess somewhat like a fixed rate loan. I want to make my calculations generic enough so that it doesn't matter whether the payment is more or less frequent than the resets though. $\endgroup$
    – AZhu
    Commented Aug 22, 2016 at 12:25

1 Answer 1

2
$\begingroup$

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.

$\endgroup$
1
  • $\begingroup$ That is pretty much what I thought of doing, the way I think this could work is I create a VanillaSwap first and take the fixed leg from there, then create the IborCoupons myself (some logic here to determine which coupon falls into which payment period) and then use Swap to finally tie the 2 legs together. $\endgroup$
    – AZhu
    Commented Aug 23, 2016 at 14:17

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.