Skip to content
All library documents

Supplying a Forward Curve to a QuantLib Ibor Index

Article Quant Q&A · Author: Hasek

Summary

This troubleshooting example prices an interest rate cap with the Hull–White one-factor model in QuantLib. The reported null term structure message arises because the custom Ibor index needs a yield term structure to calculate forward rates, but the index was created without one. The proposed fix is to pass the existing yield-term-structure handle into the IborIndex constructor.

The example connects index construction to derivative pricing: the cap engine and model have a curve, but that does not automatically give the index the curve it needs for its own forward-rate calculations. The accepted answer offers a specific configuration change rather than a broader diagnosis. It does not discuss alternative index setups, calendar or day-count choices, or how to validate the resulting price, so those aspects would need separate checking in a production valuation workflow.

Key ideas

  • An Ibor index needs a forwarding term structure to calculate its forward rates.
  • Providing a curve to the Hull–White model and pricing engine does not automatically attach it to the index.
  • Pass the yield-term-structure handle when constructing the custom index.
  • The answer addresses this setup error but does not validate the rest of the cap configuration.

Tags

Full text
# QuantLib: null term structure set to this instance of index


# QuantLib: null term structure set to this instance of index












I'm playing around with QuantLib and trying to price an interest rate cap using HW 1F model.

```
import QuantLib as ql

sigma = 0.35
a = 0.1

today = ql.Date(18, ql.May, 2023)
ql.Settings.instance().setEvaluationDate(today)
day_count = ql.ActualActual(ql.ActualActual.ISDA)

forward_rate = 0.075
forward_curve = ql.FlatForward(today, ql.QuoteHandle(ql.SimpleQuote(forward_rate)), day_count)
initialTermStructure = ql.YieldTermStructureHandle(forward_curve)

calendar = ql.NullCalendar()
convention = ql.ModifiedFollowing

index = ql.IborIndex('custom index', ql.Period('3m'), 0, ql.USDCurrency(), 
                    calendar, convention, True, day_count)

start_date = ql.Date(18, ql.May, 2023)
end_date = ql.Date(18, ql.May, 2024)
period = ql.Period(3, ql.Months)

schedule = ql.Schedule(start_date, end_date, period, calendar, convention, convention, ql.DateGeneration.Forward, False)

nominal = 1000000
strike = 0.07

index_leg = ql.IborLeg([nominal], schedule, index)

cap = ql.Cap(index_leg, [strike])
model = ql.HullWhite(initialTermStructure, a, sigma)
engine = ql.AnalyticCapFloorEngine(model, initialTermStructure)
cap.setPricingEngine(engine)
cap.NPV()
```

It seems like I'm doing something the wrong way

> null term structure set to this instance of custom index3M Actual/Actual (ISDA)

How can I troubleshoot this error?

## Answer by user35980 (score 2, accepted)

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

The index requires a fwd curve to calculate the ibor fwds. `index = ql.IborIndex('custom index', ql.Period('3m'), 0, ql.USDCurrency(),calendar, convention, True, day_count,initialTermStructure)` will work.

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.