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!
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.