QuantLib icon indicating copy to clipboard operation
QuantLib copied to clipboard

relax check for duplicate pillar dates in GlobalBootstrap

Open pcaspers opened this issue 3 weeks ago • 3 comments

We do not allow for duplicate dates from bootstrap helpers and additional dates in GlobalBootstrap. I would like to remove this restriction, since it is not necessary and there are use cases to e.g. include two instruments with identical pillar date in a global bootstrap.

I.e., I would just remove duplicate dates from helpers and additional dates when setting up the dates and times for the interpolation, and check that we have enough unique points for the interpolation, i.e. something like this:

    // first populate the dates vector and make sure they are sorted and unique
    dates.clear();
    dates.push_back(firstDate);
    for (Size j = 0; j < numberHelpers_; ++j)
        dates.push_back(ts_->instruments_[firstHelper_ + j]->pillarDate());
    dates.insert(dates.end(), additionalDates.begin(), additionalDates.end());
    std::sort(dates.begin(), dates.end());
    dates.erase(std::unique(dates.begin(), dates.end()), dates.end());

    // check if there are enough interpolation points
    QL_REQUIRE(dates.size() >= Interpolator::requiredPoints,
               "not enough curve points ("
                   << dates.size()
                   << ") for interpolation requiring at least " << Interpolator::requiredPoints);

Any objections to this, @lballabio, @eltoder?

pcaspers avatar Dec 05 '25 11:12 pcaspers

Ok for me, I guess

lballabio avatar Dec 05 '25 11:12 lballabio

Makes sense to me. We discussed making a similar change, but ended up just passing an empty list of helpers into PiecewiseYieldCurve and passing all dates and helpers via additionalDates and additionalHelpers.

Also, the check for Interpolator::requiredPoints is not strictly needed, because ts_->interpolator_.interpolate() call below will do it as well. But I guess we might be able to produce a better/earlier error message here.

eltoder avatar Dec 05 '25 16:12 eltoder

Yes that's what I thought regarding the error message.

Ok I'll make this change then.

Thanks both.

pcaspers avatar Dec 05 '25 16:12 pcaspers