Skip to content

Commit 60696f5

Browse files
pcaspersjenkins
authored andcommitted
QPR-11772 fixes
1 parent 268fe54 commit 60696f5

5 files changed

Lines changed: 26 additions & 23 deletions

File tree

OREData/ored/portfolio/capfloor.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -86,8 +86,6 @@ void CapFloor::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
8686
QL_REQUIRE(floatData->caps().empty() && floatData->floors().empty(),
8787
"CapFloor build error, Floating leg section must not have caps and floors");
8888

89-
bool isBmaIndex = boost::dynamic_pointer_cast<QuantExt::BMAIndexWrapper>(index) != nullptr;
90-
9189
if (!floatData->hasSubPeriods()) {
9290
// For the cases where we support caps and floors in the regular way, we build a floating leg with
9391
// the nakedOption flag set to true, this avoids maintaining all features in legs with associated
@@ -448,7 +446,7 @@ void CapFloor::build(const boost::shared_ptr<EngineFactory>& engineFactory) {
448446
// axdd required fixings
449447
auto fdg = boost::make_shared<FixingDateGetter>(requiredFixings_);
450448
for (auto const& l : legs_)
451-
xaddToRequiredFixings(l, fdg);
449+
addToRequiredFixings(l, fdg);
452450

453451
Date startDate = Date::maxDate();
454452
for (auto const& l : legs_) {

OREData/ored/portfolio/legbuilders.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -65,7 +65,7 @@ Leg FloatingLegBuilder::buildLeg(const LegData& data, const boost::shared_ptr<En
6565
} else {
6666
auto bma = boost::dynamic_pointer_cast<QuantExt::BMAIndexWrapper>(index);
6767
if (bma != nullptr)
68-
result = makeBMALeg(data, bma, openEndDateReplacement);
68+
result = makeBMALeg(data, bma, engineFactory, openEndDateReplacement);
6969
else {
7070
boost::shared_ptr<IborIndex> idx = index;
7171
if (!floatData->historicalFixings().empty())

OREData/ored/portfolio/legdata.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
*/
1818

1919
#include <ored/portfolio/bond.hpp>
20+
#include <ored/portfolio/builders/capflooredaveragebmacouponleg.hpp>
2021
#include <ored/portfolio/builders/capflooredaverageonindexedcouponleg.hpp>
2122
#include <ored/portfolio/builders/capflooredcpileg.hpp>
2223
#include <ored/portfolio/builders/capfloorediborleg.hpp>
@@ -40,6 +41,7 @@
4041
#include <qle/cashflows/averageonindexedcoupon.hpp>
4142
#include <qle/cashflows/averageonindexedcouponpricer.hpp>
4243
#include <qle/cashflows/brlcdicouponpricer.hpp>
44+
#include <qle/cashflows/cappedflooredaveragebmacoupon.hpp>
4345
#include <qle/cashflows/cmbcoupon.hpp>
4446
#include <qle/cashflows/couponpricer.hpp>
4547
#include <qle/cashflows/cpicoupon.hpp>
@@ -1484,7 +1486,7 @@ Leg makeOISLeg(const LegData& data, const boost::shared_ptr<OvernightIndex>& ind
14841486
}
14851487

14861488
Leg makeBMALeg(const LegData& data, const boost::shared_ptr<QuantExt::BMAIndexWrapper>& indexWrapper,
1487-
const QuantLib::Date& openEndDateReplacement) {
1489+
const boost::shared_ptr<EngineFactory>& engineFactory, const QuantLib::Date& openEndDateReplacement) {
14881490
boost::shared_ptr<FloatingLegData> floatData = boost::dynamic_pointer_cast<FloatingLegData>(data.concreteLegData());
14891491
QL_REQUIRE(floatData, "Wrong LegType, expected Floating, got " << data.legType());
14901492
boost::shared_ptr<BMAIndex> index = indexWrapper->bma();
@@ -1511,28 +1513,28 @@ Leg makeBMALeg(const LegData& data, const boost::shared_ptr<QuantExt::BMAIndexWr
15111513

15121514
applyAmortization(notionals, data, schedule, false);
15131515

1514-
AverageBMALeg leg = AverageBMALeg(schedule, index)
1515-
.withNotionals(notionals)
1516-
.withSpreads(spreads)
1517-
.withPaymentDayCounter(dc)
1518-
.withPaymentCalendar(paymentCalendar)
1519-
.withPaymentAdjustment(bdc)
1520-
.withGearings(gearings);
1516+
Leg leg = AverageBMALeg(schedule, index)
1517+
.withNotionals(notionals)
1518+
.withSpreads(spreads)
1519+
.withPaymentDayCounter(dc)
1520+
.withPaymentCalendar(paymentCalendar)
1521+
.withPaymentAdjustment(bdc)
1522+
.withGearings(gearings);
15211523

15221524
// try to set the rate computation period based on the schedule tenor
15231525

15241526
Period rateComputationPeriod = 0 * Days;
1525-
if (!tmp.rules().empty() && !tmp.rules().front().tenor().empty())
1526-
rateComputationPeriod = parsePeriod(tmp.rules().front().tenor());
1527-
else if (!tmp.dates().empty() && !tmp.dates().front().tenor().empty())
1528-
rateComputationPeriod = parsePeriod(tmp.dates().front().tenor());
1527+
if (!data.schedule().rules().empty() && !data.schedule().rules().front().tenor().empty())
1528+
rateComputationPeriod = parsePeriod(data.schedule().rules().front().tenor());
1529+
else if (!data.schedule().dates().empty() && !data.schedule().dates().front().tenor().empty())
1530+
rateComputationPeriod = parsePeriod(data.schedule().dates().front().tenor());
15291531

15301532
// handle caps / floors
15311533

15321534
if (floatData->caps().size() > 0 || floatData->floors().size() > 0) {
15331535

15341536
boost::shared_ptr<QuantExt::CapFlooredAverageBMACouponPricer> cfCouponPricer;
1535-
auto builder = boost::dynamic_pointer_cast<CapFlooredAverageONIndexedCouponLegEngineBuilder>(
1537+
auto builder = boost::dynamic_pointer_cast<CapFlooredAverageBMACouponLegEngineBuilder>(
15361538
engineFactory->builder("CapFlooredAverageBMACouponLeg"));
15371539
QL_REQUIRE(builder, "No builder found for CapFlooredAverageBMACouponLeg");
15381540
cfCouponPricer = boost::dynamic_pointer_cast<CapFlooredAverageBMACouponPricer>(
@@ -1541,11 +1543,12 @@ Leg makeBMALeg(const LegData& data, const boost::shared_ptr<QuantExt::BMAIndexWr
15411543

15421544
for (Size i = 0; i < leg.size(); ++i) {
15431545
auto bmaCpn = boost::dynamic_pointer_cast<AverageBMACoupon>(leg[i]);
1544-
QL_REQUIREQ(bmaCpn, "makeBMALeg(): internal error, exepcted AverageBMACoupon. Contact dev.");
1545-
if (caps[i] != Null<Real> || floors[i] != Null<Real>()) {
1546-
leg[i] = boost::make_shared<CappedFlooredAVerageBMACoupon>(
1547-
leg[i], caps[i], floors[i], floatData->nakedOption[i], floatData->includeSpread());
1548-
leg[i]->setPricer(cfCouponPricer);
1546+
QL_REQUIRE(bmaCpn, "makeBMALeg(): internal error, exepcted AverageBMACoupon. Contact dev.");
1547+
if (caps[i] != Null<Real>() || floors[i] != Null<Real>()) {
1548+
auto cpn = boost::make_shared<CappedFlooredAverageBMACoupon>(
1549+
bmaCpn, caps[i], floors[i], floatData->nakedOption(), floatData->includeSpread());
1550+
cpn->setPricer(cfCouponPricer);
1551+
leg[i] = cpn;
15491552
}
15501553
}
15511554
}

OREData/ored/portfolio/legdata.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -961,6 +961,7 @@ Leg makeOISLeg(const LegData& data, const boost::shared_ptr<OvernightIndex>& ind
961961
const boost::shared_ptr<EngineFactory>& engineFactory, const bool attachPricer = true,
962962
const QuantLib::Date& openEndDateReplacement = Null<Date>());
963963
Leg makeBMALeg(const LegData& data, const boost::shared_ptr<QuantExt::BMAIndexWrapper>& indexWrapper,
964+
const boost::shared_ptr<EngineFactory>& engineFactory,
964965
const QuantLib::Date& openEndDateReplacement = Null<Date>());
965966
Leg makeSimpleLeg(const LegData& data);
966967
Leg makeNotionalLeg(const Leg& refLeg, const bool initNomFlow, const bool finalNomFlow, const bool amortNomFlow,

QuantExt/qle/termstructures/proxyoptionletvolatility.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,13 @@
1717
*/
1818

1919
#include <qle/cashflows/overnightindexedcoupon.hpp>
20+
#include <qle/indexes/bmaindexwrapper.hpp>
2021
#include <qle/termstructures/atmadjustedsmilesection.hpp>
2122
#include <qle/termstructures/proxyoptionletvolatility.hpp>
2223
#include <qle/utilities/cashflows.hpp>
2324
#include <qle/utilities/time.hpp>
2425

25-
#include <ql/cashflows/avaeragebmacoupon.hpp>
26+
#include <ql/cashflows/averagebmacoupon.hpp>
2627
#include <ql/indexes/iborindex.hpp>
2728
#include <ql/termstructures/volatility/smilesection.hpp>
2829

0 commit comments

Comments
 (0)