Skip to content
All library documents

Pricing a Libor-OIS Swap and Calculating Its DV01 in QuantLib

Article Quant Q&A · Author: Gao Haocheng

Summary

A Libor 3-month versus overnight indexed swap uses a 3-month curve to project the Libor leg and an overnight indexed swap curve to project the overnight leg and discount cash flows. The discussion points to QuantLib’s generic swap and floating-for-floating swap classes, with legs built from overnight and interbank rate schedules and indices.

The library objects described do not directly solve for the fair spread. Instead, vary the spread on the overnight leg until the swap’s net present value is zero, using a numerical solver. DV01 likewise requires user-defined repricing after shifting rates; the answer suggests a central difference using valuations under upward and downward bumps. It provides an implementation outline rather than code or a worked example, and does not specify bump size, curve construction details, or conventions, all of which affect results.

Key ideas

  • Use the 3-month curve to forecast the Libor leg and the overnight curve to forecast and discount the overnight leg.
  • QuantLib can represent the swap with generic swap legs or a floating-for-floating swap object.
  • Find the fair spread by solving for the spread that makes net present value zero.
  • Calculate DV01 by repricing under rate bumps, with the suggested central-difference approach.

Tags

Full text
# float float swap in quantlib


# 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 quit confused about this, and I can't find any help in the Internet. Thanks in advance]1

## Answer by David Duarte (score 2)

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

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$$

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.