Skip to content
All library documents

Setting a Pricer to Calculate a QuantLib Ibor Coupon

Article Quant Q&A · Author: Andre

Summary

The document explains why calling the amount or rate method on a QuantLib IborCoupon can fail with a “pricer not set” error, even when the relevant Euribor fixing has already been supplied. In the implementation described, coupon rate calculation delegates to a pricer before checking whether the index fixing is available. The index also needs a forecasting term structure.

The accepted answer gives a practical workaround: assign the default Black Ibor coupon pricer, and provide the index with a term structure. A flat zero-rate curve can serve as a minimal forecast setup, though using the actual Euribor curve is preferable when available to avoid unintended forecasts for future fixing dates. When building an IborLeg without caps or floors, the library assigns a default pricer to its coupons. This is a software usage explanation, and behavior may depend on the QuantLib version and instrument configuration.

Key ideas

  • QuantLib may require an Ibor coupon pricer even when its fixing is already known.
  • The index also needs a forecasting term structure for rate calculations.
  • Assigning the default Black Ibor coupon pricer is the suggested workaround.
  • Use an actual forecast curve when available, especially to avoid accidental future fixing forecasts.
  • IborLeg can set default pricers for uncapped and unfloored coupons.

Tags

Full text
# Calculating QuantLib IborCoupon with / from given index fixing


# Calculating QuantLib IborCoupon with / from given index fixing












How can I calc with QuantLib the coupon amount of a floating rate IborCoupon on the 3M Euribor Index with a given 3M Euribor Index Fixing?

If I try the following Python code:

```
from QuantLib import *
index = Euribor(Period(3, Months))
start = DateParser_parseISO("2019-02-22")
end = DateParser_parseISO("2019-05-22")
coupon = IborCoupon(end, 1.0, start, end, 2, index)
fixDate = coupon.fixingDate()
index.addFixing(fixDate, 0.04)
print coupon.amount()
```

I get the error `pricer not set`.

I was wondering about the error cause from my understanding no pricer is needed, cause the the relevant Fixing is allready given. The result should be roughly 0.01.

Looking into the (c++) source code of the `amount()` method or more precisly the `rate()` method, I can see that on every call the existence of a pricer is checked.

Therefore I suppose my code is the wrong way to do this.

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

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

The current implementation delegates to a pricer before checking for whether the coupon has already fixed; not only that, but it also requires the index to have a valid forecasting term structure. You're nor wrong, though: I can see how one would expect the call to work. I suggest you open an issue on GitHub (at https://github.com/lballabio/QuantLib/issues) and suggest this as a usability improvement.

In the meantime, you can work around this. The default pricer for IBOR coupons doesn't need additional parameters, so you can set one by adding:

```
coupon.setPricer(BlackIborCouponPricer())
```

after you created the coupon. By the way, if you use `IborLeg` to create a sequence of coupons instead of creating a single one, and if the coupons have no caps or floors (which would require a volatility to be passed), `IborLeg` will set a default pricer to each one so you don't have to.

As for the forecast curve, the simplest way is to create the index as:

```
dummy_curve = FlatForward(0, NullCalendar(), 0.0, Actual365Fixed())
index = Euribor(Period(3, Months), YieldTermStructureHandle(dummy_curve))
```

but if you have an actual Euribor curve, I suggest you use that one instead. This way, you won't run the risk that the index uses the dummy curve for forecasting in case you slip and ask for a future fixing.

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.