Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions OREData/ored/portfolio/legdata.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1231,7 +1231,7 @@ Leg makeZCFixedLeg(const LegData& data, const QuantLib::Date& openEndDateReplace
void applyStubInterpolation(Leg::iterator c, const std::string& shortIndexStr, const std::string& longIndexStr,
const std::string& roundingTypeStr, const std::string& roundingPrecisionStr,
const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
const bool useOriginalIndexCurve, const Size accrualDays) {
const bool useOriginalIndexCurve, const Size accrualDays, const Size fixingDays) {
if (shortIndexStr.empty() && longIndexStr.empty()) {
return;
}
Expand All @@ -1253,6 +1253,7 @@ void applyStubInterpolation(Leg::iterator c, const std::string& shortIndexStr, c
iborCpn = QuantLib::ext::dynamic_pointer_cast<IborCoupon>(*c);
}
QL_REQUIRE(iborCpn, "applyStubInterpolation(): unable to unpack coupon to ibor coupon");
Size fDays = fixingDays == Null<Size>() ? iborCpn->fixingDays() : fixingDays;
// ... replace it with an interpolated Ibor Coupon ...
QuantLib::ext::shared_ptr<IborIndex> idx1, idx2;
if (!shortIndexStr.empty())
Expand All @@ -1269,7 +1270,7 @@ void applyStubInterpolation(Leg::iterator c, const std::string& shortIndexStr, c
// actually no interpolation, only one index is given effectively, so we can use an Ibor Coupon
tmp = QuantLib::ext::make_shared<IborCoupon>(
iborCpn->date(), iborCpn->nominal(), iborCpn->accrualStartDate(), iborCpn->accrualEndDate(),
iborCpn->fixingDays(),
fDays,
useOriginalIndexCurve ? idx1->clone(iborCpn->iborIndex()->forwardingTermStructure()) : idx1,
iborCpn->gearing(), iborCpn->spread(), iborCpn->referencePeriodStart(), iborCpn->referencePeriodEnd(),
iborCpn->dayCounter(), iborCpn->isInArrears(), iborCpn->exCouponDate());
Expand All @@ -1287,7 +1288,7 @@ void applyStubInterpolation(Leg::iterator c, const std::string& shortIndexStr, c
useOriginalIndexCurve ? iborCpn->iborIndex()->forwardingTermStructure() : Handle<YieldTermStructure>());
tmp = QuantLib::ext::make_shared<InterpolatedIborCoupon>(
iborCpn->date(), iborCpn->nominal(), iborCpn->accrualStartDate(), iborCpn->accrualEndDate(),
iborCpn->fixingDays(), interpolatedIndex, iborCpn->gearing(), iborCpn->spread(),
fDays, interpolatedIndex, iborCpn->gearing(), iborCpn->spread(),
iborCpn->referencePeriodStart(), iborCpn->referencePeriodEnd(), iborCpn->dayCounter(),
iborCpn->isInArrears(), iborCpn->exCouponDate(), iborCpn->iborIndex());
DLOG("created InterpolatedIborIndex for accrual period "
Expand Down Expand Up @@ -1465,7 +1466,7 @@ Leg makeIborLeg(const LegData& data, const QuantLib::ext::shared_ptr<IborIndex>&
// front / back stub interpolation
applyStubInterpolation(leg.begin(), floatData->frontStubShortIndex(), floatData->frontStubLongIndex(),
floatData->frontStubRoundingType(), floatData->frontStubRoundingPrecision(), engineFactory,
floatData->stubUseOriginalCurve());
floatData->stubUseOriginalCurve(), Null<Size>(), fixingDays);
if (leg.size() == 1
&& !floatData->frontStubShortIndex().empty() && !floatData->frontStubLongIndex().empty()
&& !floatData->backStubShortIndex().empty() && !floatData->backStubLongIndex().empty()) {
Expand All @@ -1474,7 +1475,7 @@ Leg makeIborLeg(const LegData& data, const QuantLib::ext::shared_ptr<IborIndex>&
} else {
applyStubInterpolation(leg.end() - 1, floatData->backStubShortIndex(), floatData->backStubLongIndex(),
floatData->backStubRoundingType(), floatData->backStubRoundingPrecision(), engineFactory,
floatData->stubUseOriginalCurve());
floatData->stubUseOriginalCurve(), Null<Size>(), fixingDays);
}
return leg;
}
Expand Down Expand Up @@ -1588,7 +1589,7 @@ Leg makeIborLeg(const LegData& data, const QuantLib::ext::shared_ptr<IborIndex>&
// front / back stub interpolation
applyStubInterpolation(tmpLeg.begin(), floatData->frontStubShortIndex(), floatData->frontStubLongIndex(),
floatData->frontStubRoundingType(), floatData->frontStubRoundingPrecision(), engineFactory,
floatData->stubUseOriginalCurve());
floatData->stubUseOriginalCurve(), Null<Size>(), fixingDays);
if (tmpLeg.size() == 1
&& !floatData->frontStubShortIndex().empty() && !floatData->frontStubLongIndex().empty()
&& !floatData->backStubShortIndex().empty() && !floatData->backStubLongIndex().empty()) {
Expand All @@ -1597,7 +1598,7 @@ Leg makeIborLeg(const LegData& data, const QuantLib::ext::shared_ptr<IborIndex>&
} else {
applyStubInterpolation(tmpLeg.end() - 1, floatData->backStubShortIndex(), floatData->backStubLongIndex(),
floatData->backStubRoundingType(), floatData->backStubRoundingPrecision(), engineFactory,
floatData->stubUseOriginalCurve());
floatData->stubUseOriginalCurve(), Null<Size>(), fixingDays);
}

// return the leg
Expand Down
3 changes: 2 additions & 1 deletion OREData/ored/portfolio/legdata.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -1259,7 +1259,8 @@ Leg buildNotionalLeg(const LegData& data, const Leg& leg, RequiredFixings& requi
void applyStubInterpolation(Leg::iterator c, const std::string& shortIndexStr, const std::string& longIndexStr,
const std::string& roundingTypeStr, const std::string& roundingPrecisionStr,
const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory,
const bool useOriginalIndexCurve, const Size accrualDays = Null<Size>());
const bool useOriginalIndexCurve, const Size accrualDays = Null<Size>(),
const Size fixingDays = Null<Size>());

} // namespace data
} // namespace ore