# 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()
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.

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.