Skip to content
All library documents

QuantLib Extrapolation Beyond the Last Curve Data Point

Article Quant Q&A · Author: YangH

Summary

The document explains what enabling extrapolation does for QuantLib curves. A curve is built from supplied data points, and a request for a value beyond the final point can otherwise raise an error. Enabling extrapolation permits the library to return values outside the supplied range according to the curve's extrapolation behavior.

Using a survival-probability curve as its example, the answer describes extending beyond the final supplied year by continuing with the constant hazard rate implied by the last interval. It notes that the setting also applies to interest-rate curves and volatility surfaces. This can make downstream calculations more convenient, but the resulting values lie beyond the input data and depend on an extrapolation assumption. The example explains the setting's purpose, but does not compare alternative extrapolation rules or assess their suitability for a particular pricing task.

Key ideas

  • Enabling extrapolation allows curve queries beyond the last supplied data point.
  • Without extrapolation, an out-of-range query may produce an error.
  • The survival-curve example continues using the constant hazard rate from its final interval.
  • The setting also applies to interest-rate curves and volatility surfaces.
  • Extrapolated values depend on an assumption beyond the available data.

Tags

Full text
# Quantlib-Python: Can anyone help me understand how enableExtrapolation works?


# Quantlib-Python: Can anyone help me understand how enableExtrapolation works?












I found 'enableExtrapolation' in many curve-building examples but can only guess. Can anyone help me to understand it? It will be perfect if there are examples to show how it works. Thank you very much!

## Answer by Dimitri Vulis (score 1, accepted)

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

For example, let us build a survival probabilities curve providing the survival probabilities for the first 5 years.

```
today = ql.Date().todaysDate()
dates = [today + ql.Period(n , ql.Years) for n in range(5)]
survival_probabilities = [1.0, 0.99, 0.98, 0.97, 0.95]
spcrv = ql.SurvivalProbabilityCurve(dates, survival_probabilities, ql.Actual360(), ql.TARGET())
spcrv.enableExtrapolation()
```

Suppose you need the survival probability in 7 years, beyond the last data point that you have provided. What do you prefer the library to do?

Sometimes, you want to throw, but most of the time it is more convenient to silently use the same constant hazard rate that you provided between 4 and 5 years to interpolate beyond 5 years.

The same setting works for interest rate curves (do you want to get an error when you ask for a discount factor beyond the date of your last helper? usually not), volatility surfaces, etc.

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.