@@ -274,6 +274,7 @@ void IndexCreditDefaultSwapOption::build(const QuantLib::ext::shared_ptr<EngineF
274274 // Set engine on the underlying CDS.
275275 auto ccy = parseCurrency (npvCurrency_);
276276 std::string overrideCurve = iCdsOptionEngineBuilder->engineParameter (" Curve" , {}, false , " Underlying" );
277+
277278 auto creditCurveId = this ->creditCurveId ();
278279 // warn if that is not possible, except for trades on custom baskets
279280 if (swap_.basket ().constituents ().empty () && splitCurveIdWithTenor (creditCurveId).second == 0 * Days) {
@@ -283,26 +284,28 @@ void IndexCreditDefaultSwapOption::build(const QuantLib::ext::shared_ptr<EngineF
283284 swap_.creditCurveId () + " ')" )
284285 .log ();
285286 }
287+
288+ // for cash settlement build the underlying swap with the inccy discount curve
289+ Settlement::Type settleType = parseSettlementType (option_.settlement ());
290+ cds->setPricingEngine (iCdsEngineBuilder->engine (
291+ ccy, creditCurveId, constituentIds, overrideCurve, iCdsOptionEngineBuilder->calibrateUnderlyingCurves (),
292+ constituentNtls, swap_.recoveryRate (), settleType == Settlement::Cash));
293+
286294 // Strike may be in terms of spread or price
287295 auto strikeType = parseCdsOptionStrikeType (effectiveStrikeType_);
288296
289297 // Determine the index term;
290298 effectiveIndexTerm_ = 5 * Years;
291- Date indexStart = swap_.indexStartDateHint () == Date () ? schedule.dates ().front () : swap_.indexStartDateHint ();
292299 if (!indexTerm_.empty ()) {
293300 // if the option has an explicit index term set, we use that
294301 effectiveIndexTerm_ = parsePeriod (indexTerm_);
295302 } else {
296303 // otherwise we derive the index term from the start date (or an externally set hint for that)
297- effectiveIndexTerm_ = QuantExt::implyIndexTerm (indexStart, schedule.dates ().back ());
304+ effectiveIndexTerm_ = QuantExt::implyIndexTerm (swap_.indexStartDateHint () == Date () ? schedule.dates ().front ()
305+ : swap_.indexStartDateHint (),
306+ schedule.dates ().back ());
298307 }
299308
300- // for cash settlement build the underlying swap with the inccy discount curve
301- Settlement::Type settleType = parseSettlementType (option_.settlement ());
302- cds->setPricingEngine (iCdsEngineBuilder->engine (
303- ccy, creditCurveId, constituentIds, overrideCurve, iCdsOptionEngineBuilder->calibrateUnderlyingCurves (),
304- constituentNtls, swap_.recoveryRate (), settleType == Settlement::Cash));
305-
306309 // Build the option
307310 auto option = QuantLib::ext::make_shared<QuantExt::IndexCdsOption>(cds, exercise, effectiveStrike_, strikeType, settleType,
308311 notionals_.tradeDate , notionals_.realisedFep ,
0 commit comments