Constructing an Inflation Curve from Zero-Coupon Inflation Swaps
Summary
The document presents a QuantLib setup for deriving an inflation term structure from zero-coupon inflation swap quotes. The shown workflow supplies dated market rates, builds a yield curve, creates an inflation index and relinkable term-structure handle, adds a latest CPI fixing, and constructs zero-coupon inflation swap helpers. Those helpers are then passed to a piecewise zero-inflation curve constructor along with conventions such as observation lag, index frequency, interpolation choice, and a base zero rate.
The excerpt ends after the user reports unexpected plotted zero rates, so it does not identify the error or show a corrected curve. It therefore serves mainly as an example of the inputs and conventions involved in curve construction, not as a verified implementation or a complete troubleshooting method. The document gives no market-data source, expected output, or diagnostics to establish which setting is responsible for the unusual results.
Key ideas
- Zero-coupon inflation swap quotes can be converted into curve helpers for bootstrapping an inflation term structure.
- The construction depends on a yield curve, inflation index, CPI fixing, observation lag, and market conventions.
- The example uses a piecewise zero-inflation curve with specified interpolation and base-rate settings.
- The excerpt reports unexpected rates but provides no diagnosis or corrected implementation.
- Curve outputs cannot be validated from the information shown because no expected values or diagnostics are supplied.
Tags
Full text
# How to build an inflation term structure in QuantLib?
# How to build an inflation term structure in QuantLib?
This is what I've got, but I'm getting weird results. Can you spot an error?:
```
zciisData = [(ql.Date(18,4,2020), 1.9948999881744385),
(ql.Date(18,4,2021), 1.9567999839782715),
(ql.Date(18,4,2022), 1.9566999673843384),
(ql.Date(18,4,2023), 1.9639999866485596),
(ql.Date(18,4,2024), 2.017400026321411),
(ql.Date(18,4,2025), 2.0074000358581543),
(ql.Date(18,4,2026), 2.0297999382019043),
(ql.Date(18,4,2027), 2.05430006980896),
(ql.Date(18,4,2028), 2.0873000621795654),
(ql.Date(18,4,2029), 2.1166999340057373),
(ql.Date(18,4,2031), 2.152100086212158),
(ql.Date(18,4,2034), 2.18179988861084),
(ql.Date(18,4,2039), 2.190999984741211),
(ql.Date(18,4,2044), 2.2016000747680664),
(ql.Date(18,4,2049), 2.193000078201294)]
def build_inflation_term_structure(calendar, evaluationDate):
dayCounter = ql.ActualActual()
yTS = build_yield_curve()
lag = 3
fixing_date = calendar.advance(evaluationDate,-lag, ql.Months)
convention = ql.ModifiedFollowing
cpiTS = ql.RelinkableZeroInflationTermStructureHandle()
inflationIndex = ql.USCPI(False, cpiTS)
#last observed CPI level
fixing_rate = 252.0
baseZeroRate = 1.8
inflationIndex.addFixing(fixing_date, fixing_rate)
observationLag = ql.Period(lag, ql.Months)
zeroSwapHelpers = []
for date,rate in zciisData:
nextZeroSwapHelper = ql.ZeroCouponInflationSwapHelper(rate/100,observationLag,date,calendar,
convention,dayCounter,inflationIndex)
zeroSwapHelpers = zeroSwapHelpers + [nextZeroSwapHelper]
# the derived inflation curve
derived_inflation_curve = ql.PiecewiseZeroInflation(evaluationDate, calendar, dayCounter, observationLag,
inflationIndex.frequency(), inflationIndex.interpolated(),
baseZeroRate, yTS, zeroSwapHelpers,
1.0e-12, ql.Linear())
cpiTS.linkTo(derived_inflation_curve)
return inflationIndex, derived_inflation_curve, cpiTS, yTS
```
If I plot the inflationIndex zero rates, I get this: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.