lballabio / QuantLib

The QuantLib C++ library
http://quantlib.org
Other
5.43k stars 1.8k forks source link

Don't require bond helpers when a `FittedBondDiscountCurve` instance won't use them #2071

Closed lballabio closed 2 weeks ago

lballabio commented 2 months ago

When passed maxEvaluations=0, a fitted bond curve won't calibrate the parameters of its fitting method; it will use the ones passed, which were precomputed in some other way. However, the constructor still requires that the passed vector of bond helpers is not empty, even if they won't be used; see e.g. https://github.com/lballabio/QuantLib/blob/v1.35/test-suite/fittedbonddiscountcurve.cpp#L45-L50 where a fake bond helper needs to be created. The check should be relaxed.

Note that without bond helpers, we can't determine a max date. We could pass it as a kind-of-optional argument (usually not needed, but required when maxEvaluation = 0), or extrapolate by default (by setting maxDate = Date::.maxDate()); the latter is risky though, since the curve might not make sense long term.

We might also decide that passing a mock bond helper is an easier way to set the max date. It might be confusing, though, and at least it should be documented.