Skip to content

Commit c41618f

Browse files
committed
QPR-13744 handle invalid quotes
1 parent 142068a commit c41618f

10 files changed

Lines changed: 35 additions & 27 deletions

QuantExt/qle/termstructures/averageoisratehelper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ AverageOISRateHelper::AverageOISRateHelper(
5959

6060
void AverageOISRateHelper::initializeDates() {
6161

62-
averageOIS_ = MakeAverageOIS(swapTenor_, overnightIndex_, onTenor_, quote().empty() ? 0.0 : quote()->value(),
63-
fixedTenor_, fixedDayCounter_, spotLagTenor_)
62+
averageOIS_ = MakeAverageOIS(swapTenor_, overnightIndex_, onTenor_,
63+
quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), fixedTenor_,
64+
fixedDayCounter_, spotLagTenor_)
6465
.withFixedCalendar(fixedCalendar_)
6566
.withFixedConvention(fixedConvention_)
6667
.withFixedTerminationDateConvention(fixedConvention_)

QuantExt/qle/termstructures/basistwoswaphelper.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ void BasisTwoSwapHelper::initializeDates() {
7575
of the atm swap rate in MakeVanillaSwap operator ...(). If it is
7676
Null, you get an exception because the discountRelinkableHandle_
7777
is initially empty. */
78-
longSwap_ = MakeVanillaSwap(swapTenor_, longIndex_, quote().empty() || !longMinusShort_ ? 0.0 : quote()->value())
78+
longSwap_ = MakeVanillaSwap(swapTenor_, longIndex_,
79+
quote().empty() || !quote().isValid() || !longMinusShort_ ? 0.0 : quote()->value())
7980
.withDiscountingTermStructure(discountRelinkableHandle_)
8081
.withFixedLegDayCount(longFixedDayCount_)
8182
.withFixedLegTenor(Period(longFixedFrequency_))
@@ -84,7 +85,8 @@ void BasisTwoSwapHelper::initializeDates() {
8485
.withFixedLegCalendar(calendar_)
8586
.withFloatingLegCalendar(calendar_);
8687

87-
shortSwap_ = MakeVanillaSwap(swapTenor_, shortIndex_, quote().empty() || longMinusShort_ ? 0.0 : quote()->value())
88+
shortSwap_ = MakeVanillaSwap(swapTenor_, shortIndex_,
89+
quote().empty() || !quote().isValid() || longMinusShort_ ? 0.0 : quote()->value())
8890
.withDiscountingTermStructure(discountRelinkableHandle_)
8991
.withFixedLegDayCount(shortFixedDayCount_)
9092
.withFixedLegTenor(Period(shortFixedFrequency_))

QuantExt/qle/termstructures/brlcdiratehelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ void BRLCdiRateHelper::initializeDates() {
6464

6565
// Create the BRL CDI swap
6666
swap_ = QuantLib::ext::make_shared<BRLCdiSwap>(OvernightIndexedSwap::Payer, 1.0, startDate, endDate,
67-
quote().empty() ? 0.01 : quote()->value(), brlCdiIndex_, 0.0,
68-
telescopicValueDates_);
67+
quote().empty() || !quote().isValid() ? 0.01 : quote()->value(),
68+
brlCdiIndex_, 0.0, telescopicValueDates_);
6969

7070
// Set the pricing engine
7171
swap_->setPricingEngine(QuantLib::ext::make_shared<DiscountingSwapEngine>(discountRelinkableHandle_));

QuantExt/qle/termstructures/crossccybasismtmresetswaphelper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -155,8 +155,9 @@ void CrossCcyBasisMtMResetSwapHelper::initializeDates() {
155155

156156
swap_ = QuantLib::ext::make_shared<CrossCcyBasisMtMResetSwap>(
157157
foreignNominal, foreignCurrency_, foreignLegSchedule, foreignCcyIndex_,
158-
!spreadOnForeignCcy_ || quote().empty() ? 0.0 : quote()->value(), domesticCurrency_, domesticLegSchedule,
159-
domesticCcyIndex_, spreadOnForeignCcy_ || quote().empty() ? 0.0 : quote()->value(), fxIdx, true,
158+
!spreadOnForeignCcy_ || quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), domesticCurrency_,
159+
domesticLegSchedule, domesticCcyIndex_,
160+
spreadOnForeignCcy_ || quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), fxIdx, true,
160161
foreignPaymentLag_, domesticPaymentLag_, foreignIncludeSpread_, foreignLookback_, foreignFixingDays_,
161162
foreignRateCutoff_, foreignIsAveraged_, domesticIncludeSpread_, domesticLookback_, domesticFixingDays_,
162163
domesticRateCutoff_, domesticIsAveraged_, telescopicValueDates_);

QuantExt/qle/termstructures/crossccybasisswaphelper.cpp

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -147,10 +147,11 @@ void CrossCcyBasisSwapHelper::initializeDates() {
147147

148148
/* Arbitrarily set the spread leg as the pay leg */
149149
swap_ = QuantLib::ext::make_shared<CrossCcyBasisSwap>(
150-
spreadLegNominal, spreadLegCurrency_, spreadLegSchedule, spreadIndex_, quote().empty() ? 0.0 : quote()->value(),
151-
spreadGearing_, flatLegNominal, flatLegCurrency_, flatLegSchedule, flatIndex_, spreadOnFlatLeg_, flatGearing_,
152-
paymentLag_, flatPaymentLag_, includeSpread_, lookback_, fixingDays_, rateCutoff_, isAveraged_,
153-
flatIncludeSpread_, flatLookback_, flatFixingDays_, flatRateCutoff_, flatIsAveraged_, telescopicValueDates_);
150+
spreadLegNominal, spreadLegCurrency_, spreadLegSchedule, spreadIndex_,
151+
quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), spreadGearing_, flatLegNominal,
152+
flatLegCurrency_, flatLegSchedule, flatIndex_, spreadOnFlatLeg_, flatGearing_, paymentLag_, flatPaymentLag_,
153+
includeSpread_, lookback_, fixingDays_, rateCutoff_, isAveraged_, flatIncludeSpread_, flatLookback_,
154+
flatFixingDays_, flatRateCutoff_, flatIsAveraged_, telescopicValueDates_);
154155

155156
QuantLib::ext::shared_ptr<PricingEngine> engine;
156157
if (flatIsDomestic_) {

QuantExt/qle/termstructures/crossccyfixfloatmtmresetswaphelper.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -97,10 +97,10 @@ void CrossCcyFixFloatMtMResetSwapHelper::initializeDates() {
9797
}
9898

9999
swap_ = QuantLib::ext::make_shared<CrossCcyFixFloatMtMResetSwap>(
100-
nominal, fixedCurrency_, fixedSchedule, quote().empty() ? 0.0 : quote()->value(), fixedDayCount_,
101-
paymentConvention_, paymentLag, paymentCalendar_, index_->currency(), floatSchedule, index_, floatSpread,
102-
paymentConvention_, paymentLag, paymentCalendar_, fxIdx, resetsOnFloatLeg_, true, includeSpread_, lookback_,
103-
fixingDays_, rateCutoff_, isAveraged_);
100+
nominal, fixedCurrency_, fixedSchedule, quote().empty() || !quote().isValid() ? 0.0 : quote()->value(),
101+
fixedDayCount_, paymentConvention_, paymentLag, paymentCalendar_, index_->currency(), floatSchedule, index_,
102+
floatSpread, paymentConvention_, paymentLag, paymentCalendar_, fxIdx, resetsOnFloatLeg_, true, includeSpread_,
103+
lookback_, fixingDays_, rateCutoff_, isAveraged_);
104104

105105
// Attach engine
106106
QuantLib::ext::shared_ptr<PricingEngine> engine = QuantLib::ext::make_shared<CrossCcySwapEngine>(

QuantExt/qle/termstructures/crossccyfixfloatswaphelper.cpp

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -127,11 +127,12 @@ void CrossCcyFixFloatSwapHelper::initializeDates() {
127127
// Create the swap
128128
Natural paymentLag = 0;
129129
Spread floatSpread = spread_.empty() ? 0.0 : spread_->value();
130-
swap_.reset(new CrossCcyFixFloatSwap(
131-
CrossCcyFixFloatSwap::Payer, fixedNominal, fixedCurrency_, fixedSchedule,
132-
quote().empty() ? 0.0 : quote()->value(), fixedDayCount_, paymentConvention_, paymentLag, paymentCalendar_,
133-
floatNominal, index_->currency(), floatSchedule, index_, floatSpread, paymentConvention_, paymentLag,
134-
paymentCalendar_, telescopicValueDates_, includeSpread_, lookback_, fixingDays_, rateCutoff_, isAveraged_));
130+
swap_.reset(new CrossCcyFixFloatSwap(CrossCcyFixFloatSwap::Payer, fixedNominal, fixedCurrency_, fixedSchedule,
131+
quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), fixedDayCount_,
132+
paymentConvention_, paymentLag, paymentCalendar_, floatNominal,
133+
index_->currency(), floatSchedule, index_, floatSpread, paymentConvention_,
134+
paymentLag, paymentCalendar_, telescopicValueDates_, includeSpread_, lookback_,
135+
fixingDays_, rateCutoff_, isAveraged_));
135136

136137
earliestDate_ = swap_->startDate();
137138
maturityDate_ = swap_->maturityDate();

QuantExt/qle/termstructures/oisratehelper.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ void OISRateHelper::initializeDates() {
5858

5959
Calendar paymentCalendar_ = overnightIndex_->fixingCalendar();
6060

61-
swap_ = MakeOIS(swapTenor_, overnightIndex_, quote().empty() ? 0.0 : quote()->value())
61+
swap_ = MakeOIS(swapTenor_, overnightIndex_, quote().empty() || !quote().isValid() ? 0.0 : quote()->value())
6262
.withSettlementDays(settlementDays_)
6363
.withFixedLegDayCount(fixedDayCounter_)
6464
.withEndOfMonth(endOfMonth_)
@@ -164,7 +164,7 @@ DatedOISRateHelper::DatedOISRateHelper(const Date& startDate, const Date& endDat
164164
registerWith(overnightIndex_);
165165
registerWith(discountHandle_);
166166

167-
swap_ = MakeOIS(Period(), overnightIndex_, quote().empty() ? 0.0 : quote()->value())
167+
swap_ = MakeOIS(Period(), overnightIndex_, quote().empty() || !quote().isValid() ? 0.0 : quote()->value())
168168
.withEffectiveDate(startDate)
169169
.withTerminationDate(endDate)
170170
.withFixedLegDayCount(fixedDayCounter_)

QuantExt/qle/termstructures/subperiodsswaphelper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -59,8 +59,9 @@ void SubPeriodsSwapHelper::initializeDates() {
5959
Date effectiveDate = spotCalendar.advance(valuationDate, spotDays * Days);
6060

6161
swap_ = QuantLib::ext::shared_ptr<SubPeriodsSwap>(new SubPeriodsSwap(
62-
effectiveDate, 1.0, swapTenor_, true, fixedTenor_, quote().empty() ? 0.0 : quote()->value(), fixedCalendar_,
63-
fixedDayCount_, fixedConvention_, floatPayTenor_, iborIndex_, floatDayCount_, DateGeneration::Backward, type_));
62+
effectiveDate, 1.0, swapTenor_, true, fixedTenor_,
63+
quote().empty() || !quote().isValid() ? 0.0 : quote()->value(), fixedCalendar_, fixedDayCount_,
64+
fixedConvention_, floatPayTenor_, iborIndex_, floatDayCount_, DateGeneration::Backward, type_));
6465

6566
QuantLib::ext::shared_ptr<PricingEngine> engine(new DiscountingSwapEngine(discountRelinkableHandle_));
6667
swap_->setPricingEngine(engine);

QuantExt/qle/termstructures/tenorbasisswaphelper.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,8 +138,9 @@ void TenorBasisSwapHelper::initializeDates() {
138138
Date effectiveDate = spotCalendar.advance(valuationDate, spotDays * Days);
139139

140140
swap_ = QuantLib::ext::make_shared<TenorBasisSwap>(
141-
effectiveDate, 1.0, swapTenor_, payIndex_, quote().empty() || spreadOnRec_ ? 0.0 : quote()->value(),
142-
payFrequency_, receiveIndex_, quote().empty() || !spreadOnRec_ ? 0.0 : quote()->value(), recFrequency_,
141+
effectiveDate, 1.0, swapTenor_, payIndex_,
142+
quote().empty() || !quote().isValid() || spreadOnRec_ ? 0.0 : quote()->value(), payFrequency_, receiveIndex_,
143+
quote().empty() || !quote().isValid() || !spreadOnRec_ ? 0.0 : quote()->value(), recFrequency_,
143144
DateGeneration::Backward, includeSpread_, spreadOnRec_, type_, telescopicValueDates_);
144145

145146
auto engine = QuantLib::ext::make_shared<DiscountingSwapEngine>(discountRelinkableHandle_);

0 commit comments

Comments
 (0)