Using QuantLib I want to price a Floating rate bond whose coupons are capped at some rate.
I understand I could price the coupon caps separately and then add that to a zero-bond.
However, I've noticed that in
FloatingRateBond QuantLib allows to specify
caps attribute for cap rates of the coupons.
What I don't know is how to set a pricer for such a bond with coupon options and how to pass in the implied volatilites.
The code below clearly throws an error as it complains about pricer not being set.
Can you please tell me how to adjust the code to price the bond with capped coupons?
today = ql.Date(22, 10, 2022) ql.Settings.instance().evaluationDate = today curve = ql.YieldTermStructureHandle(ql.FlatForward(today,0.05,ql.SimpleDayCounter())) schedule = ql.MakeSchedule(ql.Date(31, 12, 2022), ql.Date(31, 12, 2037), frequency = ql.Annual) index = ql.Euribor6M(curve) bond = ql.FloatingRateBond(0, 100, schedule, index, ql.Actual360(), caps = [0.04]*5) bond.setPricingEngine(ql.DiscountingBondEngine(curve)) bond.NPV()