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

#include <ored/portfolio/bondtotalreturnswap.hpp>

+ Inheritance diagram for BondTRS:
+ Collaboration diagram for BondTRS:

Public Member Functions

 BondTRS ()
 Default Constructor. More...
 
 BondTRS (Envelope env, const BondData &bondData)
 Constructor for coupon bonds. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &) override
 
virtual void fromXML (XMLNode *node) override
 
virtual XMLNodetoXML (XMLDocument &doc) const override
 
std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
 Add underlying Bond names. More...
 
const BondDatabondData () const
 
const ScheduleDatascheduleData () const
 
const LegDatafundingLegData () const
 
const bool payTotalReturnLeg () const
 
const Real initialPrice () const
 
const bool useDirtyPrices () const
 
const std::string & observationLag () const
 
const std::string & observationConvention () const
 
const std::string & observationCalendar () const
 
const std::string & paymentLag () const
 
const std::string & paymentConvention () const
 
const std::string & paymentCalendar () const
 
const std::vector< std::string > & paymentDates ()
 
- Public Member Functions inherited from Trade
 Trade ()
 Default constructor. More...
 
 Trade (const string &tradeType, const Envelope &env=Envelope(), const TradeActions &ta=TradeActions())
 Base class constructor. More...
 
virtual ~Trade ()
 Default destructor. More...
 
virtual void build (const QuantLib::ext::shared_ptr< EngineFactory > &)=0
 
virtual std::map< std::string, RequiredFixings::FixingDatesfixings (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
const RequiredFixingsrequiredFixings () const
 
virtual std::map< AssetClass, std::set< std::string > > underlyingIndices (const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const
 
void reset ()
 Reset trade, clear all base class data. This does not reset accumulated timings for this trade. More...
 
void resetPricingStats (const std::size_t numberOfPricings=0, const boost::timer::nanosecond_type cumulativePricingTime=0)
 Reset accumulated timings to given values. More...
 
string & id ()
 Set the trade id. More...
 
void setEnvelope (const Envelope &envelope)
 Set the envelope with counterparty and portfolio info. More...
 
void setAdditionalData (const std::map< std::string, boost::any > &additionalData)
 
TradeActionstradeActions ()
 Set the trade actions. More...
 
const string & id () const
 
const string & tradeType () const
 
const Envelopeenvelope () const
 
const set< string > & portfolioIds () const
 
const TradeActionstradeActions () const
 
const QuantLib::ext::shared_ptr< InstrumentWrapper > & instrument () const
 
const std::vector< QuantLib::Leg > & legs () const
 
const std::vector< string > & legCurrencies () const
 
const std::vector< bool > & legPayers () const
 
const string & npvCurrency () const
 
virtual QuantLib::Real notional () const
 Return the current notional in npvCurrency. See individual sub-classes for the precise definition. More...
 
virtual string notionalCurrency () const
 
const Date & maturity () const
 
virtual bool isExpired (const Date &d)
 
const string & issuer () const
 
template<typename T >
additionalDatum (const std::string &tag) const
 returns any additional datum. More...
 
virtual const std::map< std::string, boost::any > & additionalData () const
 returns all additional data returned by the trade once built More...
 
const std::string & sensitivityTemplate () const
 
void validate () const
 Utility to validate that everything that needs to be set in this base class is actually set. More...
 
virtual bool hasCashflows () const
 
boost::timer::nanosecond_type getCumulativePricingTime () const
 Get cumulative timing spent on pricing. More...
 
std::size_t getNumberOfPricings () const
 Get number of pricings. More...
 
- Public Member Functions inherited from XMLSerializable
virtual ~XMLSerializable ()
 
virtual void fromXML (XMLNode *node)=0
 
virtual XMLNodetoXML (XMLDocument &doc) const =0
 
void fromFile (const std::string &filename)
 
void toFile (const std::string &filename) const
 
void fromXMLString (const std::string &xml)
 Parse from XML string. More...
 
std::string toXMLString () const
 Parse from XML string. More...
 

Private Attributes

BondData originalBondData_
 
BondData bondData_
 
ScheduleData scheduleData_
 
LegData fundingLegData_
 
bool payTotalReturnLeg_ = false
 
Real initialPrice_ = Null<Real>()
 
bool useDirtyPrices_ = true
 
bool payBondCashFlowsImmediately_ = false
 
std::string observationLag_
 
std::string observationConvention_
 
std::string observationCalendar_
 
std::string paymentLag_
 
std::string paymentConvention_
 
std::string paymentCalendar_
 
std::vector< std::string > paymentDates_
 
string fxIndex_ = ""
 

Additional Inherited Members

- Protected Member Functions inherited from Trade
Date addPremiums (std::vector< QuantLib::ext::shared_ptr< Instrument > > &instruments, std::vector< Real > &multipliers, const Real tradeMultiplier, const PremiumData &premiumData, const Real premiumMultiplier, const Currency &tradeCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &factory, const string &configuration)
 
void setLegBasedAdditionalData (const Size legNo, Size resultLegId=Null< Size >()) const
 
void setSensitivityTemplate (const EngineBuilder &builder)
 
void setSensitivityTemplate (const std::string &id)
 
- Protected Attributes inherited from Trade
string tradeType_
 
QuantLib::ext::shared_ptr< InstrumentWrapperinstrument_
 
std::vector< QuantLib::Leg > legs_
 
std::vector< string > legCurrencies_
 
std::vector< boollegPayers_
 
string npvCurrency_
 
QuantLib::Real notional_
 
string notionalCurrency_
 
Date maturity_
 
string issuer_
 
string sensitivityTemplate_
 
bool sensitivityTemplateSet_ = false
 
std::size_t savedNumberOfPricings_ = 0
 
boost::timer::nanosecond_type savedCumulativePricingTime_ = 0
 
RequiredFixings requiredFixings_
 
std::map< std::string, boost::any > additionalData_
 

Detailed Description

Definition at line 35 of file bondtotalreturnswap.hpp.

Constructor & Destructor Documentation

◆ BondTRS() [1/2]

BondTRS ( )

Default Constructor.

Definition at line 38 of file bondtotalreturnswap.hpp.

38: Trade("BondTRS") {}
Trade()
Default constructor.
Definition: trade.hpp:59

◆ BondTRS() [2/2]

BondTRS ( Envelope  env,
const BondData bondData 
)

Constructor for coupon bonds.

Definition at line 41 of file bondtotalreturnswap.hpp.

42 : Trade("BondTRS", env), originalBondData_(bondData), bondData_(bondData) {}

Member Function Documentation

◆ build()

void build ( const QuantLib::ext::shared_ptr< EngineFactory > &  )
overridevirtual

Build QuantLib/QuantExt instrument, link pricing engine. If build() is called multiple times, reset() should be called between these calls.

Implements Trade.

Definition at line 50 of file bondtotalreturnswap.cpp.

50 {
51 DLOG("BondTRS::build() called for trade " << id());
52
53 // ISDA taxonomy
54 additionalData_["isdaAssetClass"] = string("Credit");
55 additionalData_["isdaBaseProduct"] = string("Total Return Swap");
56 additionalData_["isdaSubProduct"] = string("");
57 additionalData_["isdaTransaction"] = string("");
58
59 const QuantLib::ext::shared_ptr<Market> market = engineFactory->market();
60 QuantLib::ext::shared_ptr<EngineBuilder> builder_trs = engineFactory->builder("BondTRS");
62 bondData_.populateFromBondReferenceData(engineFactory->referenceData());
63
64 Schedule schedule = makeSchedule(scheduleData_);
66
67 auto configuration = builder_trs->configuration(MarketContext::pricing);
68 auto legBuilder = engineFactory->legBuilder(fundingLegData_.legType());
69
70 // check currency restrictions
71
72 QL_REQUIRE(fundingLegData_.currency() != bondData_.currency() || fxIndex_.empty(),
73 "if funding leg ccy (" << fundingLegData_.currency() << ") = bond ccy (" << bondData_.currency()
74 << "), no fx index must be given");
75 QL_REQUIRE(fundingLegData_.currency() == bondData_.currency() || !fxIndex_.empty(),
76 "if funding leg ccy (" << fundingLegData_.currency() << ") != bond ccy (" << bondData_.currency()
77 << "), a fx index must be given");
78
81
82 // build return leg valuation and payment schedule
83 DLOG("build valuation and payment dates vectors");
84
85 Period observationLag = observationLag_.empty() ? 0 * Days : parsePeriod(observationLag_);
86 Calendar observationCalendar = parseCalendar(observationCalendar_);
87 BusinessDayConvention observationConvention =
88 observationConvention_.empty() ? Unadjusted : parseBusinessDayConvention(observationConvention_);
89
91 Period plPeriod = boost::apply_visitor(PaymentLagPeriod(), paymentLag);
92 Calendar paymentCalendar = parseCalendar(paymentCalendar_);
93 BusinessDayConvention paymentConvention =
94 paymentConvention_.empty() ? Unadjusted : parseBusinessDayConvention(paymentConvention_);
95
96 std::vector<Date> valuationDates, paymentDates;
97
98 for (auto const& d : schedule.dates()) {
99 valuationDates.push_back(observationCalendar.advance(d, -observationLag, observationConvention));
100 if (d != schedule.dates().front())
101 paymentDates.push_back(paymentCalendar.advance(d, plPeriod, paymentConvention));
102 }
103
104 if (!paymentDates_.empty()) {
105 paymentDates.clear();
106 QL_REQUIRE(paymentDates_.size() + 1 == valuationDates.size(),
107 "paymentDates size (" << paymentDates_.size() << ") does no match valuatioDates size ("
108 << valuationDates.size() << ") minus 1");
109 for (auto const& s : paymentDates_)
110 paymentDates.push_back(parseDate(s));
111 }
112
113 DLOG("valuation schedule:");
114 for (auto const& d : valuationDates)
116
117 DLOG("payment schedule:");
118 for (auto const& d : paymentDates)
120
121 // build fx index for composite bond trs
122
123 QuantLib::ext::shared_ptr<FxIndex> fxIndex;
124 if (!fxIndex_.empty()) {
125 fxIndex =
126 buildFxIndex(fxIndex_, fundingLegData_.currency(), bondData_.currency(), engineFactory->market(),
127 engineFactory->configuration(MarketContext::pricing));
128
129 }
130
131 // build bond index (absolute prices, conditional on survival set to false)
132 BondIndexBuilder bondIndexBuilder(bondData_, useDirtyPrices_, false, NullCalendar(), false, engineFactory);
133 auto bondIndex = bondIndexBuilder.bondIndex();
134
135 // compute initial price taking into account the possible scaling with priceQuoteBaseValue and 100.0
136 Real effectiveInitialPrice = bondIndexBuilder.priceAdjustment(initialPrice_);
137 if (effectiveInitialPrice != Null<Real>())
138 effectiveInitialPrice = effectiveInitialPrice / 100.0;
139
140 // add indexing data from the bond trs leg, if this is desired
141
143 DLOG("adding indexing information from trs leg to funding leg");
144
145 std::vector<string> stringValuationDates;
146 for (auto const& d : valuationDates)
147 stringValuationDates.push_back(ore::data::to_string(d));
148 ScheduleData valuationSchedule(ScheduleDates("", "", "", stringValuationDates, ""));
149
150 // add bond indexing
151 Indexing bondIndexing("BOND-" + bondIndex->securityName(), "", bondIndex->dirty(), bondIndex->relative(),
152 bondIndex->conditionalOnSurvival(), bondData_.bondNotional(), effectiveInitialPrice,
153 Null<Real>(), valuationSchedule, 0, "", "U", false);
154 fundingLegData_.indexing().push_back(bondIndexing);
155
156 // add fx indexing, if applicable
157 if (!fxIndex_.empty()) {
158 Indexing fxIndexing(fxIndex_, "", false, false, false, 1.0, Null<Real>(), Null<Real>(), valuationSchedule,
159 0, "", "U", false);
160 fundingLegData_.indexing().push_back(fxIndexing);
161 }
162
163 // set notional node to 1.0
164 fundingLegData_.notionals() = std::vector<Real>(1, 1.0);
165 fundingLegData_.notionalDates() = std::vector<std::string>();
166
167 // reset flag that told us to pull the indexing information from the equity leg
169 }
170
171 // build funding leg (consisting of a coupon leg and (possibly) a notional leg
172
173 Leg fundingLeg = legBuilder->buildLeg(fundingLegData_, engineFactory, requiredFixings_, configuration);
174 Leg fundingNotionalLeg;
177 Natural fundingLegPayLag = 0;
178 fundingNotionalLeg =
183 }
184
186 "funding leg and total return lag are both rec or both pay");
187 DLOG("Before bondTRS");
188 auto bondTRS = QuantLib::ext::make_shared<QuantExt::BondTRS>(
189 bondIndex, bondData_.bondNotional(), effectiveInitialPrice,
190 std::vector<QuantLib::Leg>{fundingLeg, fundingNotionalLeg}, payTotalReturnLeg_, valuationDates, paymentDates,
193 DLOG("After bondTRS");
194 QuantLib::ext::shared_ptr<BondTRSEngineBuilder> trsBondBuilder =
195 QuantLib::ext::dynamic_pointer_cast<BondTRSEngineBuilder>(builder_trs);
196 QL_REQUIRE(trsBondBuilder, "No Builder found for BondTRS: " << id());
197 bondTRS->setPricingEngine(trsBondBuilder->engine(fundingLegData_.currency()));
198 setSensitivityTemplate(*trsBondBuilder);
199 instrument_.reset(new VanillaInstrument(bondTRS));
200 // maturity_ = std::max(valuationDates.back(), paymentDates.back());
201 maturity_ = bondIndex->bond()->maturityDate();
202 notional_ = bondIndex->bond()->notional() * bondData_.bondNotional();
203
204 // cashflows will be generated as additional results in the pricing engine
205
206 legs_ = {};
207 legCurrencies_ = {};
208 legPayers_ = {};
209
210 // add required bond and fx fixings for return calculation
211 addToRequiredFixings(bondTRS->returnLeg(), QuantLib::ext::make_shared<FixingDateGetter>(requiredFixings_));
212 bondIndexBuilder.addRequiredFixings(requiredFixings_, bondTRS->returnLeg());
213
214 // add required fx fixings for bond cashflow conversion (see the engine for details)
215
216 if (!fxIndex_.empty()) {
217 for (auto const& c : bondIndex->bond()->cashflows()) {
218 requiredFixings_.addFixingDate(fxIndex->fixingCalendar().adjust(c->date(), Preceding), fxIndex_, c->date());
219 }
220 }
221
223 auto inflationIndices = extractAllInflationUnderlyingFromBond(bondIndex->bond());
224 for (const auto& cf : bondTRS->returnLeg()) {
225 auto tcf = QuantLib::ext::dynamic_pointer_cast<TRSCashFlow>(cf);
226 if (tcf != nullptr) {
227 for (const auto& [key, index] : inflationIndices) {
228 auto [name, interpolation, couponFrequency, observationLag] = key;
229 std::string oreName = IndexNameTranslator::instance().oreName(name);
231 tcf->fixingStartDate() - observationLag, oreName, false, index->frequency(),
232 index->availabilityLag(), interpolation, couponFrequency, Date::maxDate(), false, false);
233 }
234 }
235 }
236 }
237}
bool payBondCashFlowsImmediately_
boost::shared_ptr< QuantExt::FxIndex > fxIndex_
const std::vector< Date > & valuationDates() const
const std::vector< Leg > & fundingLeg() const
const std::vector< Date > & paymentDates() const
std::vector< Date > paymentDates_
const boost::shared_ptr< QuantExt::FxIndex > & fxIndex() const
const boost::shared_ptr< QuantExt::BondIndex > & bondIndex() const
const string & currency() const
Definition: bond.hpp:94
void populateFromBondReferenceData(const QuantLib::ext::shared_ptr< BondReferenceDatum > &referenceDatum, const std::string &startDate="", const std::string &endDate="")
populate data from reference datum and check data for completeness
Definition: bond.cpp:175
const string & calendar() const
Definition: bond.hpp:89
bool isInflationLinked() const
Definition: bond.hpp:99
Real bondNotional() const
Definition: bond.hpp:95
std::string observationConvention_
const std::string & observationConvention() const
const bool useDirtyPrices() const
const std::string & observationCalendar() const
const std::string & paymentCalendar() const
const std::string & observationLag() const
const std::string & paymentLag() const
const std::string & paymentConvention() const
const string & paymentConvention() const
Definition: legdata.hpp:878
const string & currency() const
Definition: legdata.hpp:873
bool notionalFinalExchange() const
Definition: legdata.hpp:880
bool isPayer() const
Definition: legdata.hpp:872
bool notionalAmortizingExchange() const
Definition: legdata.hpp:881
const std::vector< Indexing > & indexing() const
Definition: legdata.hpp:894
const string & legType() const
Definition: legdata.hpp:890
const std::string & paymentCalendar() const
Definition: legdata.hpp:889
const bool indexingFromAssetLeg() const
Definition: legdata.hpp:895
const vector< string > & notionalDates() const
Definition: legdata.hpp:876
bool notionalInitialExchange() const
Definition: legdata.hpp:879
const vector< double > & notionals() const
Definition: legdata.hpp:875
void addZeroInflationFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const CPI::InterpolationType coupopnInterpolation, const Frequency couponFrequency, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
void addFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
string npvCurrency_
Definition: trade.hpp:201
std::vector< bool > legPayers_
Definition: trade.hpp:200
std::vector< string > legCurrencies_
Definition: trade.hpp:199
std::vector< QuantLib::Leg > legs_
Definition: trade.hpp:198
QuantLib::Real notional_
Definition: trade.hpp:202
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
RequiredFixings requiredFixings_
Definition: trade.hpp:223
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
Definition: trade.hpp:197
string notionalCurrency_
Definition: trade.hpp:203
std::map< std::string, boost::any > additionalData_
Definition: trade.hpp:224
Calendar parseCalendar(const string &s)
Convert text to QuantLib::Calendar.
Definition: parsers.cpp:157
Date parseDate(const string &s)
Convert std::string to QuantLib::Date.
Definition: parsers.cpp:51
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
BusinessDayConvention parseBusinessDayConvention(const string &s)
Convert text to QuantLib::BusinessDayConvention.
Definition: parsers.cpp:173
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Definition: parsers.cpp:171
PaymentLag parsePaymentLag(const string &s)
Convert text to PaymentLag.
Definition: parsers.cpp:628
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
Calendar calendar
Definition: utilities.cpp:441
void addToRequiredFixings(const QuantLib::Leg &leg, const QuantLib::ext::shared_ptr< FixingDateGetter > &fixingDateGetter)
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
boost::variant< QuantLib::Period, QuantLib::Natural > PaymentLag
Definition: types.hpp:32
Leg makeNotionalLeg(const Leg &refLeg, const bool initNomFlow, const bool finalNomFlow, const bool amortNomFlow, const Natural notionalPaymentLag, const BusinessDayConvention paymentConvention, const Calendar paymentCalendar, const bool excludeIndexing)
Definition: legdata.cpp:1566
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
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
string name
+ Here is the call graph for this function:

◆ fromXML()

void fromXML ( XMLNode node)
overridevirtual

Reimplemented from Trade.

Definition at line 239 of file bondtotalreturnswap.cpp.

239 {
240 Trade::fromXML(node);
241 XMLNode* bondTRSNode = XMLUtils::getChildNode(node, "BondTRSData");
242 QL_REQUIRE(bondTRSNode, "No BondTRSData Node");
243 originalBondData_.fromXML(XMLUtils::getChildNode(bondTRSNode, "BondData"));
245
246 XMLNode* bondTRSDataNode = XMLUtils::getChildNode(bondTRSNode, "TotalReturnData");
247 QL_REQUIRE(bondTRSDataNode, "No bondTRSDataNode Node");
248
249 payTotalReturnLeg_ = parseBool(XMLUtils::getChildValue(bondTRSDataNode, "Payer", true));
250
251 scheduleData_.fromXML(XMLUtils::getChildNode(bondTRSDataNode, "ScheduleData"));
252
253 observationLag_ = XMLUtils::getChildValue(bondTRSDataNode, "ObservationLag");
254 observationConvention_ = XMLUtils::getChildValue(bondTRSDataNode, "ObservationConvention");
255 observationCalendar_ = XMLUtils::getChildValue(bondTRSDataNode, "ObservationCalendar");
256
257 paymentLag_ = XMLUtils::getChildValue(bondTRSDataNode, "PaymentLag");
258 paymentConvention_ = XMLUtils::getChildValue(bondTRSDataNode, "PaymentConvention");
259 paymentCalendar_ = XMLUtils::getChildValue(bondTRSDataNode, "PaymentCalendar");
260 paymentDates_ = XMLUtils::getChildrenValues(bondTRSDataNode, "PaymentDates", "PaymentDate");
261
262 initialPrice_ = Null<Real>();
263 if (auto n = XMLUtils::getChildNode(bondTRSDataNode, "InitialPrice"))
264 initialPrice_ = parseReal(XMLUtils::getNodeValue(n));
265 std::string priceType = XMLUtils::getChildValue(bondTRSDataNode, "PriceType", true);
266 if (priceType == "Dirty")
267 useDirtyPrices_ = true;
268 else if (priceType == "Clean")
269 useDirtyPrices_ = false;
270 else {
271 QL_FAIL("PriceType (" << priceType << ") must be Clean or Dirty");
272 }
273
274 XMLNode* fxt = XMLUtils::getChildNode(bondTRSDataNode, "FXTerms");
275 if (fxt)
276 fxIndex_ = XMLUtils::getChildValue(fxt, "FXIndex", true);
277
279 XMLUtils::getChildValueAsBool(bondTRSDataNode, "PayBondCashFlowsImmediately", false, false);
280
281 XMLNode* bondTRSFundingNode = XMLUtils::getChildNode(bondTRSNode, "FundingData");
282 XMLNode* fLegNode = XMLUtils::getChildNode(bondTRSFundingNode, "LegData");
283 fundingLegData_ = LegData();
284 fundingLegData_.fromXML(fLegNode);
285}
virtual void fromXML(XMLNode *node) override
XMLSerializable interface.
Definition: bond.cpp:59
std::string observationCalendar_
virtual void fromXML(XMLNode *node) override
Definition: legdata.cpp:759
virtual void fromXML(XMLNode *node) override
Definition: schedule.cpp:179
bool parseBool(const string &s)
Convert text to bool.
Definition: parsers.cpp:144
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
rapidxml::xml_node< char > XMLNode
Definition: xmlutils.hpp:60
+ Here is the call graph for this function:

◆ toXML()

XMLNode * toXML ( XMLDocument doc) const
overridevirtual

Reimplemented from Trade.

Definition at line 287 of file bondtotalreturnswap.cpp.

287 {
288 XMLNode* node = Trade::toXML(doc);
289 XMLNode* bondTRSNode = doc.allocNode("BondTRSData");
290 XMLUtils::appendNode(node, bondTRSNode);
291 XMLUtils::appendNode(bondTRSNode, originalBondData_.toXML(doc));
292
293 XMLNode* trsDataNode = doc.allocNode("TotalReturnData");
294 XMLUtils::appendNode(bondTRSNode, trsDataNode);
295 XMLUtils::addChild(doc, trsDataNode, "Payer", payTotalReturnLeg_);
296
297 if (initialPrice_ != Null<Real>())
298 XMLUtils::addChild(doc, trsDataNode, "InitialPrice", initialPrice_);
299 XMLUtils::addChild(doc, trsDataNode, "PriceType", useDirtyPrices_ ? "Dirty" : "Clean");
300
301 if (!observationLag_.empty())
302 XMLUtils::addChild(doc, trsDataNode, "ObservationLag", observationLag_);
303 if (!observationConvention_.empty())
304 XMLUtils::addChild(doc, trsDataNode, "ObservationConvention", observationConvention_);
305 if (!observationCalendar_.empty())
306 XMLUtils::addChild(doc, trsDataNode, "ObservationCalendar", observationCalendar_);
307
308 if (!paymentLag_.empty())
309 XMLUtils::addChild(doc, trsDataNode, "PaymentLag", paymentLag_);
310 if (!paymentConvention_.empty())
311 XMLUtils::addChild(doc, trsDataNode, "PaymentConvention", paymentConvention_);
312 if (!paymentCalendar_.empty())
313 XMLUtils::addChild(doc, trsDataNode, "PaymentCalendar", paymentCalendar_);
314 if (!paymentDates_.empty())
315 XMLUtils::addChildren(doc, trsDataNode, "PaymentDates", "PaymentDate", paymentDates_);
316
317 if (!fxIndex_.empty()) {
318 XMLNode* fxNode = doc.allocNode("FXTerms");
319 XMLUtils::addChild(doc, fxNode, "FXIndex", fxIndex_);
320 XMLUtils::appendNode(trsDataNode, fxNode);
321 }
322
323 XMLUtils::appendNode(trsDataNode, scheduleData_.toXML(doc));
324
325 XMLUtils::addChild(doc, trsDataNode, "PayBondCashFlowsImmediately", payBondCashFlowsImmediately_);
326
327 XMLNode* fundingDataNode = doc.allocNode("FundingData");
328 XMLUtils::appendNode(bondTRSNode, fundingDataNode);
329 XMLUtils::appendNode(fundingDataNode, fundingLegData_.toXML(doc));
330 return node;
331}
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: bond.cpp:95
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: legdata.cpp:856
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: schedule.cpp:198
+ Here is the call graph for this function:

◆ underlyingIndices()

std::map< AssetClass, std::set< std::string > > underlyingIndices ( const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceDataManager = nullptr) const
overridevirtual

Add underlying Bond names.

Reimplemented from Trade.

Definition at line 334 of file bondtotalreturnswap.cpp.

334 {
335 std::map<AssetClass, std::set<std::string>> result;
336 result[AssetClass::BOND] = {bondData_.securityId()};
337 return result;
338}
const string & securityId() const
Definition: bond.hpp:84

◆ bondData()

const BondData & bondData ( ) const

Definition at line 53 of file bondtotalreturnswap.hpp.

53{ return bondData_; }

◆ scheduleData()

const ScheduleData & scheduleData ( ) const

Definition at line 55 of file bondtotalreturnswap.hpp.

55{ return scheduleData_; }

◆ fundingLegData()

const LegData & fundingLegData ( ) const

Definition at line 56 of file bondtotalreturnswap.hpp.

56{ return fundingLegData_; }

◆ payTotalReturnLeg()

const bool payTotalReturnLeg ( ) const

Definition at line 57 of file bondtotalreturnswap.hpp.

57{ return payTotalReturnLeg_; }

◆ initialPrice()

const Real initialPrice ( ) const

Definition at line 58 of file bondtotalreturnswap.hpp.

58{ return initialPrice_; }

◆ useDirtyPrices()

const bool useDirtyPrices ( ) const

Definition at line 59 of file bondtotalreturnswap.hpp.

59{ return useDirtyPrices_; }

◆ observationLag()

const std::string & observationLag ( ) const

Definition at line 60 of file bondtotalreturnswap.hpp.

60{ return observationLag_; }

◆ observationConvention()

const std::string & observationConvention ( ) const

Definition at line 61 of file bondtotalreturnswap.hpp.

61{ return observationConvention_; }

◆ observationCalendar()

const std::string & observationCalendar ( ) const

Definition at line 62 of file bondtotalreturnswap.hpp.

62{ return observationCalendar_; }

◆ paymentLag()

const std::string & paymentLag ( ) const

Definition at line 63 of file bondtotalreturnswap.hpp.

63{ return paymentLag_; }

◆ paymentConvention()

const std::string & paymentConvention ( ) const

Definition at line 64 of file bondtotalreturnswap.hpp.

64{ return paymentConvention_; }

◆ paymentCalendar()

const std::string & paymentCalendar ( ) const

Definition at line 65 of file bondtotalreturnswap.hpp.

65{ return paymentCalendar_; }

◆ paymentDates()

const std::vector< std::string > & paymentDates ( )

Definition at line 66 of file bondtotalreturnswap.hpp.

66{ return paymentDates_; }

Member Data Documentation

◆ originalBondData_

BondData originalBondData_
private

Definition at line 70 of file bondtotalreturnswap.hpp.

◆ bondData_

BondData bondData_
private

Definition at line 70 of file bondtotalreturnswap.hpp.

◆ scheduleData_

ScheduleData scheduleData_
private

Definition at line 73 of file bondtotalreturnswap.hpp.

◆ fundingLegData_

LegData fundingLegData_
private

Definition at line 74 of file bondtotalreturnswap.hpp.

◆ payTotalReturnLeg_

bool payTotalReturnLeg_ = false
private

Definition at line 75 of file bondtotalreturnswap.hpp.

◆ initialPrice_

Real initialPrice_ = Null<Real>()
private

Definition at line 76 of file bondtotalreturnswap.hpp.

◆ useDirtyPrices_

bool useDirtyPrices_ = true
private

Definition at line 77 of file bondtotalreturnswap.hpp.

◆ payBondCashFlowsImmediately_

bool payBondCashFlowsImmediately_ = false
private

Definition at line 78 of file bondtotalreturnswap.hpp.

◆ observationLag_

std::string observationLag_
private

Definition at line 79 of file bondtotalreturnswap.hpp.

◆ observationConvention_

std::string observationConvention_
private

Definition at line 80 of file bondtotalreturnswap.hpp.

◆ observationCalendar_

std::string observationCalendar_
private

Definition at line 81 of file bondtotalreturnswap.hpp.

◆ paymentLag_

std::string paymentLag_
private

Definition at line 82 of file bondtotalreturnswap.hpp.

◆ paymentConvention_

std::string paymentConvention_
private

Definition at line 83 of file bondtotalreturnswap.hpp.

◆ paymentCalendar_

std::string paymentCalendar_
private

Definition at line 84 of file bondtotalreturnswap.hpp.

◆ paymentDates_

std::vector<std::string> paymentDates_
private

Definition at line 85 of file bondtotalreturnswap.hpp.

◆ fxIndex_

string fxIndex_ = ""
private

Definition at line 88 of file bondtotalreturnswap.hpp.