Skip to content

Commit a0b454b

Browse files
pcaspersjenkins
authored andcommitted
QPR-11773 update
1 parent 393b121 commit a0b454b

1 file changed

Lines changed: 46 additions & 47 deletions

File tree

QuantExt/qle/pricingengines/mcmultilegbaseengine.cpp

Lines changed: 46 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -477,8 +477,8 @@ McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo(boos
477477
fxLinkedFixedFxRate](const Size n, const std::vector<std::vector<const RandomVariable*>>& states) {
478478
RandomVariable effectiveRate = lgmVectorised_[indexCcyIdx].averagedBmaRate(
479479
boost::dynamic_pointer_cast<BMAIndex>(bma->index()), bma->fixingDates(), bma->accrualStartDate(),
480-
bma->accrualEndDate(), bma->spread(), bma->gearing(), Null<Real>(), Null<Real>(), false, simTime,
481-
*states.at(0).at(0));
480+
bma->accrualEndDate(), bma->includeSpread(), bma->spread(), bma->gearing(), Null<Real>(),
481+
Null<Real>(), false, simTime, *states.at(0).at(0));
482482
RandomVariable fxFixing(n, 1.0);
483483
if (isFxLinked) {
484484
if (fxLinkedFixedFxRate != Null<Real>()) {
@@ -510,32 +510,31 @@ McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo(boos
510510
info.modelIndices.push_back(fxLinkedModelIndices);
511511
}
512512

513-
info.amountCalculator =
514-
[this, indexCcyIdx, cfbma, simTime, isFxLinked, fxLinkedSourceCcyIdx, fxLinkedTargetCcyIdx,
515-
fxLinkedFixedFxRate](const Size n, const std::vector<std::vector<const RandomVariable*>>& states) {
516-
RandomVariable effectiveRate = lgmVectorised_[indexCcyIdx].averagedBmaRate(
517-
boost::dynamic_pointer_cast<BMAIndex>(cfbma->underlying()->index()),
518-
cfbma->underlying()->fixingDates(), cfbma->underlying()->accrualStartDate(),
519-
cfbma->underlying()->accrualEndDate(), cfbma->underlying()->spread(),
520-
cfbma->underlying()->gearing(), cfbma->cap(), cfbma->floor(), cfbma->nakedOption(), simTime,
521-
*states.at(0).at(0));
522-
RandomVariable fxFixing(n, 1.0);
523-
if (isFxLinked) {
524-
if (fxLinkedFixedFxRate != Null<Real>()) {
525-
fxFixing = RandomVariable(n, fxLinkedFixedFxRate);
526-
} else {
527-
RandomVariable fxSource(n, 1.0), fxTarget(n, 1.0);
528-
Size fxIdx = 0;
529-
if (fxLinkedSourceCcyIdx > 0)
530-
RandomVariable fxSource = exp(*states.at(1).at(fxIdx++));
531-
if (fxLinkedTargetCcyIdx > 0)
532-
RandomVariable fxTarget = exp(*states.at(1).at(fxIdx));
533-
fxFixing = fxSource / fxTarget;
534-
}
513+
info.amountCalculator = [this, indexCcyIdx, cfbma, simTime, isFxLinked, fxLinkedSourceCcyIdx,
514+
fxLinkedTargetCcyIdx, fxLinkedFixedFxRate](
515+
const Size n, const std::vector<std::vector<const RandomVariable*>>& states) {
516+
RandomVariable effectiveRate = lgmVectorised_[indexCcyIdx].averagedBmaRate(
517+
boost::dynamic_pointer_cast<BMAIndex>(cfbma->underlying()->index()), cfbma->underlying()->fixingDates(),
518+
cfbma->underlying()->accrualStartDate(), cfbma->underlying()->accrualEndDate(),
519+
cfbma->underlying()->spread(), cfbma->underlying()->gearing(), cfbma->cap(), cfbma->floor(),
520+
cfbma->nakedOption(), simTime, *states.at(0).at(0));
521+
RandomVariable fxFixing(n, 1.0);
522+
if (isFxLinked) {
523+
if (fxLinkedFixedFxRate != Null<Real>()) {
524+
fxFixing = RandomVariable(n, fxLinkedFixedFxRate);
525+
} else {
526+
RandomVariable fxSource(n, 1.0), fxTarget(n, 1.0);
527+
Size fxIdx = 0;
528+
if (fxLinkedSourceCcyIdx > 0)
529+
RandomVariable fxSource = exp(*states.at(1).at(fxIdx++));
530+
if (fxLinkedTargetCcyIdx > 0)
531+
RandomVariable fxTarget = exp(*states.at(1).at(fxIdx));
532+
fxFixing = fxSource / fxTarget;
535533
}
536-
return RandomVariable(n, cfbma->underlying()->nominal() * cfbma->underlying()->accrualPeriod()) *
537-
effectiveRate * fxFixing;
538-
};
534+
}
535+
return RandomVariable(n, cfbma->underlying()->nominal() * cfbma->underlying()->accrualPeriod()) *
536+
effectiveRate * fxFixing;
537+
};
539538

540539
return info;
541540
}
@@ -551,27 +550,27 @@ McMultiLegBaseEngine::CashflowInfo McMultiLegBaseEngine::createCashflowInfo(boos
551550
info.modelIndices.push_back(fxLinkedModelIndices);
552551
}
553552

554-
info.amountCalculator =
555-
[this, indexCcyIdx, sub, simTime, isFxLinked, fxLinkedSourceCcyIdx, fxLinkedTargetCcyIdx,
556-
fxLinkedFixedFxRate](const Size n, const std::vector<std::vector<const RandomVariable*>>& states) {
557-
RandomVariable effectiveRate = lgmVectorised_[indexCcyIdx].subPeriodsRate(
558-
sub->index(), sub->fixingDates(), Null<Real>(), Null<Real>(), false, simTime, *states.at(0).at(0));
559-
RandomVariable fxFixing(n, 1.0);
560-
if (isFxLinked) {
561-
if (fxLinkedFixedFxRate != Null<Real>()) {
562-
fxFixing = RandomVariable(n, fxLinkedFixedFxRate);
563-
} else {
564-
RandomVariable fxSource(n, 1.0), fxTarget(n, 1.0);
565-
Size fxIdx = 0;
566-
if (fxLinkedSourceCcyIdx > 0)
567-
RandomVariable fxSource = exp(*states.at(1).at(fxIdx++));
568-
if (fxLinkedTargetCcyIdx > 0)
569-
RandomVariable fxTarget = exp(*states.at(1).at(fxIdx));
570-
fxFixing = fxSource / fxTarget;
571-
}
553+
info.amountCalculator = [this, indexCcyIdx, sub, simTime, isFxLinked, fxLinkedSourceCcyIdx,
554+
fxLinkedTargetCcyIdx, fxLinkedFixedFxRate](
555+
const Size n, const std::vector<std::vector<const RandomVariable*>>& states) {
556+
RandomVariable effectiveRate = lgmVectorised_[indexCcyIdx].subPeriodsRate(sub->index(), sub->fixingDates(),
557+
simTime, *states.at(0).at(0));
558+
RandomVariable fxFixing(n, 1.0);
559+
if (isFxLinked) {
560+
if (fxLinkedFixedFxRate != Null<Real>()) {
561+
fxFixing = RandomVariable(n, fxLinkedFixedFxRate);
562+
} else {
563+
RandomVariable fxSource(n, 1.0), fxTarget(n, 1.0);
564+
Size fxIdx = 0;
565+
if (fxLinkedSourceCcyIdx > 0)
566+
RandomVariable fxSource = exp(*states.at(1).at(fxIdx++));
567+
if (fxLinkedTargetCcyIdx > 0)
568+
RandomVariable fxTarget = exp(*states.at(1).at(fxIdx));
569+
fxFixing = fxSource / fxTarget;
572570
}
573-
return RandomVariable(n, sub->nominal() * sub->accrualPeriod()) * effectiveRate * fxFixing;
574-
};
571+
}
572+
return RandomVariable(n, sub->nominal() * sub->accrualPeriod()) * effectiveRate * fxFixing;
573+
};
575574

576575
return info;
577576
}

0 commit comments

Comments
 (0)