# float float swap in quantlib

I'm using quantlib to calculate a fair spread of Libor/OIS swap. I have read the reference of ql.Swap and ql.FloatFloatSwap. But the document is too vague. I totally can't understand what parameters should be used.

Now I have a YieldCurve object of 3M Libor and a YieldCurve object of OIS rate. How can I calculate the fair spread of Libor/OIS spread though Quantlib? And Is that possible to calculate DV01 of this swap?

I'm not saying that you don't, but before using software to calculate whatever you need, one should be sure to understand what is being priced and how to price it.

For a Libor 3M vs OIS swap, you need two curves: a 3M curve for the forward estimation of the 3M index and an OIS curve for the forward estimation of the overnight index and to discount the cashflows.

In QuantLib you can use either the ql.Swap or the ql.FloatFloatSwap classes.

For the ql.Swap, the constructor would be:

ql.Swap(firstLeg, secondLeg) and you can build the legs with ql.OvernightLeg and ql.IborLeg

For the ql.FloatFloatSwap the constructor would be:

ql.FloatFloatSwap(swapType, firstLegNotionals, secondLegNotionals, firstLegSchedule, firstLegIndex, firstLegDayCount, secondLegSchedule, secondLegIndex, secondLegDayCount, intermediateCapitalExchange=False, finalCapitalExchange=False, gearing1=[1.0], spread1=[0.0])

Neither of these objects have a method to determine the spread so I believe you will have to implement it yourself with a solver (QuantLib has several solvers). Solve which spread on the overnight index gives you an NPV of 0.

Same goes for the DV01, you will need to implement the logic yourself, with something like :

$$(MtM_{bump.up} - MtM_{bump.down}) / 2$$

• Thanks. How to set spread rate in ql.FloatFloatSwap? Commented Jun 12, 2020 at 13:00
• It's one of the optional parameters. I corrected the answer to include those. You can also check here for the full list: quantlib.org/reference/… Commented Jun 12, 2020 at 13:14