Constucting a Piecewise Interpolated Quantlib Term Structure
Rate Helpers
The quantlib bootstrap process takes a set of yield curve observations to build the interpolated curve from. These observations come in the form of objects called rate helpers.Sample Code
# Deposit Helper (e.g., 3-Month rate)
mm_rate = ql.QuoteHandle(ql.SimpleQuote(0.045))
mm_helper = ql.DepositRateHelper(mm_rate, ql.Period(3, ql.Months),
0, calendar, business_day_convention,
True, day_count)
# Swap Helper (e.g., 1-Year OIS rate)
swap_rate = ql.QuoteHandle(ql.SimpleQuote(0.048))
swap_helper = ql.OISRateHelper(2, ql.Period(1, ql.Years), swap_rate,
ql.OvernightIndex(calendar))
helpers = [mm_helper, swap_helper]
import QuantLib as ql
# Set today's date
today = ql.Date(25, 6, 2026)
ql.Settings.instance().evaluationDate = today
curve = ql.PiecewiseYieldCurve(today, helpers, day_count,
ql.Linear(), ql.IterativeBootstrap())