Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
FloatingLegBuilder Class Reference

#include <ored/portfolio/legbuilders.hpp>

+ Inheritance diagram for FloatingLegBuilder:
+ Collaboration diagram for FloatingLegBuilder:

Public Member Functions

 FloatingLegBuilder ()
 
Leg buildLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const override
 
- Public Member Functions inherited from LegBuilder
 LegBuilder (const string &legType)
 
virtual ~LegBuilder ()
 
virtual Leg buildLeg (const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &, RequiredFixings &requiredFixings, const string &configuration, const QuantLib::Date &openEndDateReplacement=Null< Date >(), const bool useXbsCurves=false) const =0
 
const string & legType () const
 

Detailed Description

Definition at line 52 of file legbuilders.hpp.

Constructor & Destructor Documentation

◆ FloatingLegBuilder()

Definition at line 54 of file legbuilders.hpp.

54: LegBuilder("Floating") {}
LegBuilder(const string &legType)

Member Function Documentation

◆ buildLeg()

Leg buildLeg ( const LegData data,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
RequiredFixings requiredFixings,
const string &  configuration,
const QuantLib::Date &  openEndDateReplacement = Null<Date>(),
const bool  useXbsCurves = false 
) const
overridevirtual

Implements LegBuilder.

Definition at line 79 of file legbuilders.cpp.

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);
106 addToRequiredFixings(result, QuantLib::ext::make_shared<FixingDateGetter>(requiredFixings));
107
108 // handle fx resetting Ibor leg
109
110 if (data.legType() == "Floating" && !data.isNotResetXCCY()) {
111 QL_REQUIRE(!data.fxIndex().empty(), "FloatingRateLegBuilder: need fx index for fx resetting leg");
112 auto fxIndex = buildFxIndex(data.fxIndex(), data.currency(), data.foreignCurrency(), engineFactory->market(),
113 configuration, true);
114
115 // If the domestic notional value is not specified, i.e. there are no notionals specified in the leg
116 // data, then all coupons including the first will be FX linked. If the first coupon's FX fixing date
117 // is in the past, a FX fixing will be used to determine the first domestic notional. If the first
118 // coupon's FX fixing date is in the future, the first coupon's domestic notional will be determined
119 // by the FX forward rate on that future fixing date.
120
121 Size j = 0;
122 if (data.notionals().size() == 0) {
123 DLOG("Building FX Resettable with unspecified domestic notional");
124 } else {
125 // First coupon a plain floating rate coupon i.e. it is not FX linked because the initial notional is
126 // known. But, we need to add it to additionalLegs_ so that we don't miss the first coupon's ibor fixing
127 LOG("Building FX Resettable with first domestic notional specified explicitly");
128 j = 1;
129 }
130
131 // Make the necessary FX linked floating rate coupons
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 // set the same pricer
141 fxLinkedCoupon->setPricer(coupon->pricer());
142 result[j] = fxLinkedCoupon;
143
144 // Add the FX fixing to the required fixings
145 requiredFixings.addFixingDate(fixingDate, data.fxIndex(), fxLinkedCoupon->date());
146 }
147 }
148
149 return result;
150}
@ data
Definition: log.hpp:77
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
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)
Definition: legdata.cpp:1336
void applyIndexing(Leg &leg, const LegData &data, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, RequiredFixings &requiredFixings, const QuantLib::Date &openEndDateReplacement, const bool useXbsCurves)
Definition: legdata.cpp:2633
Leg makeBMALeg(const LegData &data, const QuantLib::ext::shared_ptr< QuantExt::BMAIndexWrapper > &indexWrapper, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::Date &openEndDateReplacement)
Definition: legdata.cpp:1493
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)
Definition: legdata.cpp:1102
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)
Definition: marketdata.cpp:137
+ Here is the call graph for this function: