81 {
82 auto floatData = QuantLib::ext::dynamic_pointer_cast<FloatingLegData>(
data.concreteLegData());
83 QL_REQUIRE(floatData, "Wrong LegType, expected Floating");
84 string indexName = floatData->index();
85 auto index = *engineFactory->market()->iborIndex(indexName, configuration);
86
87 auto ois = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(index);
88 Leg result;
89 if (ois != nullptr) {
90 QuantLib::ext::shared_ptr<OvernightIndex> idx = ois;
91 if (!floatData->historicalFixings().empty())
92 idx = QuantLib::ext::make_shared<OvernightIndexWithFixingOverride>(ois, floatData->historicalFixings());
93 result =
makeOISLeg(data, idx, engineFactory,
true, openEndDateReplacement);
94 } else {
95 auto bma = QuantLib::ext::dynamic_pointer_cast<QuantExt::BMAIndexWrapper>(index);
96 if (bma != nullptr)
97 result =
makeBMALeg(data, bma, engineFactory, openEndDateReplacement);
98 else {
99 QuantLib::ext::shared_ptr<IborIndex> idx = index;
100 if (!floatData->historicalFixings().empty())
101 idx = QuantLib::ext::make_shared<IborIndexWithFixingOverride>(index, floatData->historicalFixings());
102 result =
makeIborLeg(data, idx, engineFactory,
true, openEndDateReplacement);
103 }
104 }
105 applyIndexing(result, data, engineFactory, requiredFixings, openEndDateReplacement, useXbsCurves);
107
108
109
110 if (
data.legType() ==
"Floating" && !
data.isNotResetXCCY()) {
111 QL_REQUIRE(!
data.fxIndex().empty(),
"FloatingRateLegBuilder: need fx index for fx resetting leg");
113 configuration, true);
114
115
116
117
118
119
120
121 Size j = 0;
122 if (
data.notionals().size() == 0) {
123 DLOG(
"Building FX Resettable with unspecified domestic notional");
124 } else {
125
126
127 LOG(
"Building FX Resettable with first domestic notional specified explicitly");
128 j = 1;
129 }
130
131
132 for (; j < result.size(); ++j) {
133 QuantLib::ext::shared_ptr<FloatingRateCoupon> coupon =
134 QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(result[j]);
135 Date
fixingDate = fxIndex->fixingCalendar().advance(coupon->accrualStartDate(),
136 -static_cast<Integer>(fxIndex->fixingDays()), Days);
137 QuantLib::ext::shared_ptr<FloatingRateFXLinkedNotionalCoupon> fxLinkedCoupon =
138 QuantLib::ext::make_shared<FloatingRateFXLinkedNotionalCoupon>(fixingDate,
data.foreignAmount(),
139 fxIndex, coupon);
140
141 fxLinkedCoupon->setPricer(coupon->pricer());
142 result[j] = fxLinkedCoupon;
143
144
145 requiredFixings.addFixingDate(fixingDate,
data.fxIndex(), fxLinkedCoupon->date());
146 }
147 }
148
149 return result;
150}
#define LOG(text)
Logging Macro (Level = Notice)
#define DLOG(text)
Logging Macro (Level = Debug)
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
Leg makeOISLeg(const LegData &data, const QuantLib::ext::shared_ptr< OvernightIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
void applyIndexing(Leg &leg, const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const QuantLib::Date &openEndDateReplacement, const bool useXbsCurves)
Leg makeBMALeg(const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::BMAIndexWrapper > &indexWrapper, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
Leg makeIborLeg(const LegData &data, const QuantLib::ext::shared_ptr< IborIndex > &index, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const bool attachPricer, const QuantLib::Date &openEndDateReplacement)
QuantLib::ext::shared_ptr< QuantExt::FxIndex > buildFxIndex(const string &fxIndex, const string &domestic, const string &foreign, const QuantLib::ext::shared_ptr< Market > &market, const string &configuration, bool useXbsCurves)