# 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:

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?

• How would that swap (semiannual payment and annual reset) work? You'd fix a rate annually and then pay it for two consecutive coupons? – Luigi Ballabio Aug 22 '16 at 9:07
• @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. – AZhu Aug 22 '16 at 12:25

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.