Skip to content

Commit 586e786

Browse files
pcaspersjenkins
authored andcommitted
QPR-12488 better handling of edge case
1 parent a00881e commit 586e786

3 files changed

Lines changed: 28 additions & 8 deletions

File tree

OREData/ored/model/inflation/infdkbuilder.cpp

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -333,15 +333,23 @@ void InfDkBuilder::buildCapFloorBasket() const {
333333

334334
Real tteFromBase = infVol_->timeFromBase(expiryDate);
335335

336-
Real marketPrem = dontCalibrate_ || tte <= 0 || tteFromBase <= 0 ? 0.01 : cf->NPV();
336+
Real marketPrem;
337+
if (dontCalibrate_)
338+
marketPrem = 0.1;
339+
else if (tte <= 0 || tteFromBase <= 0)
340+
marketPrem = 0.00;
341+
else
342+
marketPrem = cf->NPV();
343+
337344
QuantLib::ext::shared_ptr<QuantExt::CpiCapFloorHelper> helper =
338345
QuantLib::ext::make_shared<QuantExt::CpiCapFloorHelper>(capfloor, baseCPI, expiryDate, fixCalendar, bdc,
339-
fixCalendar, bdc, strikeValue, hIndex, lag, marketPrem);
346+
fixCalendar, bdc, strikeValue, hIndex, lag,
347+
marketPrem);
340348

341349
// we might produce duplicate expiry times even if the fixing dates are all different
342-
if (tte > 0 && tteFromBase >= 0 && std::find_if(expiryTimes.begin(), expiryTimes.end(), [tte](Real x) {
343-
return QuantLib::close_enough(x, tte);
344-
}) == expiryTimes.end()) {
350+
if (marketPrem > 0.0 && tte > 0 && tteFromBase > 0 &&
351+
std::find_if(expiryTimes.begin(), expiryTimes.end(),
352+
[tte](Real x) { return QuantLib::close_enough(x, tte); }) == expiryTimes.end()) {
345353
optionBasket_.push_back(helper);
346354
helper->performCalculations();
347355
expiryTimes.push_back(tte);

OREData/ored/model/inflation/infjybuilder.cpp

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -344,6 +344,13 @@ Helpers InfJyBuilder::buildCpiCapFloorBasket(const CalibrationBasket& cb,
344344
// Add the helper's time to expiry.
345345
auto fixingDate = helper->instrument()->fixingDate();
346346
auto t = inflationTime(fixingDate, *zts, false);
347+
348+
// if time is not positive deactivate helper
349+
if (t < 0.0 || QuantLib::close_enough(t, 0.0)) {
350+
active[i] = false;
351+
continue;
352+
}
353+
347354
auto p = expiryTimes.insert(t);
348355
QL_REQUIRE(data_->ignoreDuplicateCalibrationExpiryTimes() || p.second,
349356
"InfJyBuilder: a CPI cap floor calibration "
@@ -459,6 +466,13 @@ Helpers InfJyBuilder::buildYoYCapFloorBasket(const CalibrationBasket& cb, vector
459466
// Add the helper's time to expiry.
460467
auto fixingDate = helperInst->lastYoYInflationCoupon()->fixingDate();
461468
auto t = inflationTime(fixingDate, *yoyTs, yoyInflationIndex_->interpolated());
469+
470+
// if time is not positive deactivate helper
471+
if (t < 0.0 || QuantLib::close_enough(t, 0.0)) {
472+
active[i] = false;
473+
continue;
474+
}
475+
462476
auto p = expiryTimes.insert(t);
463477
QL_REQUIRE(data_->ignoreDuplicateCalibrationExpiryTimes() || p.second,
464478
"InfJyBuilder: a YoY cap floor calibration "
@@ -575,7 +589,7 @@ Helpers InfJyBuilder::buildYoYSwapBasket(const CalibrationBasket& cb,
575589
t = inflationTime(denFixingDate, *yoyTs, yoyInflationIndex_->interpolated());
576590
}
577591

578-
if (t <= 0) {
592+
if (t < 0 || close_enough(t, 0.0)) {
579593
DLOG("The year on year swap with maturity tenor, " << yoySwap->tenor() << ", and date, " << maturity <<
580594
", has a non-positive parameter time, " << t << ", so skipping this as a calibration instrument.");
581595
continue;

QuantExt/qle/models/cpicapfloorhelper.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,8 +39,6 @@ CpiCapFloorHelper::CpiCapFloorHelper(Option::Type type, Real baseCPI, const Date
3939
errorType == BlackCalibrationHelper::RelativePriceError,
4040
"CpiCapFloorHelper supports only PriceError and "
4141
"RelativePriceError error types");
42-
QL_REQUIRE(marketPremium > 0.0 && !close_enough(marketPremium, 0.0),
43-
"can not calibrate to market premium " << marketPremium);
4442
marketValue_ = marketPremium;
4543
}
4644

0 commit comments

Comments
 (0)