Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
swaption.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19#include <ql/cashflows/coupon.hpp>
20#include <ql/cashflows/simplecashflow.hpp>
21#include <ql/exercise.hpp>
22#include <ql/instruments/compositeinstrument.hpp>
23#include <ql/instruments/swaption.hpp>
24#include <ql/time/daycounters/actualactual.hpp>
25
28#include <qle/pricingengines/blackmultilegoptionengine.hpp>
30
38
39#include <boost/algorithm/string/case_conv.hpp>
40#include <boost/timer/timer.hpp>
41
42#include <algorithm>
43
44using boost::timer::cpu_timer;
45using boost::timer::default_places;
46using namespace QuantLib;
47using std::lower_bound;
48using std::sort;
49
50namespace ore {
51namespace data {
52
53namespace {
54QuantLib::Settlement::Method defaultSettlementMethod(const QuantLib::Settlement::Type t) {
55 if (t == QuantLib::Settlement::Physical)
56 return QuantLib::Settlement::PhysicalOTC;
57 else
58 return QuantLib::Settlement::ParYieldCurve; // ql < 1.14 behaviour
59}
60} // namespace
61
62void Swaption::build(const QuantLib::ext::shared_ptr<EngineFactory>& engineFactory) {
63
64 DLOG("Swaption::build() for " << id());
65
66 // 1 ISDA taxonomy
67
68 additionalData_["isdaAssetClass"] = string("Interest Rate");
69 additionalData_["isdaBaseProduct"] = string("Option");
70 additionalData_["isdaSubProduct"] = string("Swaption");
71 additionalData_["isdaTransaction"] = string("");
72
73 // 4 fill currencies and set notional to null (will be retrieved via notional())
74
75 npvCurrency_ = notionalCurrency_ = "USD"; // only if no legs are given, not relevant in this case
76
77 if (!legData_.empty()) {
78 npvCurrency_ = notionalCurrency_ = legData_[0].currency();
79 }
80
81 // 2 build underlying swap and copy its required fixings
82
83 underlying_ = QuantLib::ext::make_shared<ore::data::Swap>(Envelope(), legData_);
84 underlying_->build(engineFactory);
85 requiredFixings_.addData(underlying_->requiredFixings());
86
87 // 3 build the exercise and parse some fields
88
89 DLOG("Swaption::build() for " << id() << ": build exercise");
90
91 exerciseBuilder_ = QuantLib::ext::make_shared<ExerciseBuilder>(optionData_, underlying_->legs());
92
95 settlementMethod_ = optionData_.settlementMethod() == "" ? defaultSettlementMethod(settlementType_)
98
99 notional_ = Null<Real>();
100
101 Date today = Settings::instance().evaluationDate();
102
103 // 5 if the swaption is exercised (as per option data / exercise data), build the cashflows that remain to be paid
104
105 if (exerciseBuilder_->isExercised()) {
106 Date exerciseDate = exerciseBuilder_->exerciseDate();
107 maturity_ = std::max(today, exerciseDate); // will be updated below
108
109 if (optionData_.settlement() == "Physical") {
110
111 // 5.1 if physical exercise, inlcude the "exercise-into" cashflows of the underlying
112
113 for (Size i = 0; i < underlying_->legs().size(); ++i) {
114 legs_.push_back(Leg());
115 legCurrencies_.push_back(underlying_->legCurrencies()[i]);
116 legPayers_.push_back(underlying_->legPayers()[i]);
117 for (auto const& c : underlying_->legs()[i]) {
118 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(c)) {
119 if (exerciseDate <= cpn->accrualStartDate()) {
120 legs_.back().push_back(c);
121 maturity_ = std::max(maturity_, c->date());
122 if (notional_ == Null<Real>())
123 notional_ = cpn->nominal();
124 }
125 } else if (exerciseDate <= c->date()) {
126 legs_.back().push_back(c);
127 maturity_ = std::max(maturity_, c->date());
128 }
129 }
130 }
131
132 } else {
133
134 // 5.2 if cash exercise, include the cashSettlement payment
135
136 if (exerciseBuilder_->cashSettlement()) {
137 legs_.push_back(Leg());
138 legs_.back().push_back(exerciseBuilder_->cashSettlement());
139 legCurrencies_.push_back(npvCurrency_);
140 legPayers_.push_back(false);
141 maturity_ = std::max(maturity_, exerciseBuilder_->cashSettlement()->date());
142 }
143 }
144
145 // 5.3 include the exercise fee payment
146
147 if (exerciseBuilder_->feeSettlement()) {
148 legs_.push_back(Leg());
149 legs_.back().push_back(exerciseBuilder_->feeSettlement());
150 legCurrencies_.push_back(npvCurrency_);
151 legPayers_.push_back(true);
152 maturity_ = std::max(maturity_, exerciseBuilder_->feeSettlement()->date());
153 }
154
155 // 5.4 add unconditional premiums, build instrument (as swap) and exit
156
157 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
158 std::vector<Real> additionalMultipliers;
159 Date lastPremiumDate = addPremiums(additionalInstruments, additionalMultipliers, Position::Long ? 1.0 : -1.0,
160 optionData_.premiumData(), positionType_ == Position::Long ? -1.0 : 1.0,
161 parseCurrency(npvCurrency_), engineFactory,
162 engineFactory->configuration(MarketContext::pricing));
163 auto builder = QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(engineFactory->builder("Swap"));
164 QL_REQUIRE(builder, "could not get swap builder to build exercised swaption instrument.");
165 auto swap = QuantLib::ext::make_shared<QuantLib::Swap>(legs_, legPayers_);
166 swap->setPricingEngine(builder->engine(parseCurrency(npvCurrency_),
167 envelope().additionalField("discount_curve", false),
168 envelope().additionalField("security_spread", false)));
169 setSensitivityTemplate(*builder);
170 instrument_ = QuantLib::ext::make_shared<VanillaInstrument>(swap, positionType_ == Position::Long ? 1.0 : -1.0,
171 additionalInstruments, additionalMultipliers);
172 maturity_ = std::max(maturity_, lastPremiumDate);
173 DLOG("Building exercised swaption done.");
174 return;
175 }
176
177 // 6 if we do not have an active exercise as of today, or no underlying legs we only build unconditional premiums
178
179 if (exerciseBuilder_->exercise() == nullptr || exerciseBuilder_->exercise()->dates().empty() ||
180 exerciseBuilder_->exercise()->dates().back() <= today || legData_.empty()) {
181 legs_ = {{QuantLib::ext::make_shared<QuantLib::SimpleCashFlow>(0.0, today)}};
182 legCurrencies_.push_back(npvCurrency_);
183 legPayers_.push_back(false);
184 maturity_ = today;
185 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
186 std::vector<Real> additionalMultipliers;
187 Date lastPremiumDate = addPremiums(additionalInstruments, additionalMultipliers, Position::Long ? 1.0 : -1.0,
188 optionData_.premiumData(), positionType_ == Position::Long ? -1.0 : 1.0,
189 parseCurrency(npvCurrency_), engineFactory,
190 engineFactory->configuration(MarketContext::pricing));
191 auto builder = QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(engineFactory->builder("Swap"));
192 QL_REQUIRE(builder, "could not get swap builder to build expired swaption instrument.");
193 auto swap = QuantLib::ext::make_shared<QuantLib::Swap>(legs_, legPayers_);
194 swap->setPricingEngine(builder->engine(parseCurrency(npvCurrency_),
195 envelope().additionalField("discount_curve", false),
196 envelope().additionalField("security_spread", false)));
197 instrument_ = QuantLib::ext::make_shared<VanillaInstrument>(swap, positionType_ == Position::Long ? 1.0 : -1.0,
198 additionalInstruments, additionalMultipliers);
199 setSensitivityTemplate(*builder);
200 maturity_ = std::max(maturity_, lastPremiumDate);
201 DLOG("Building (non-exercised) swaption without alive exercise dates done.");
202 return;
203 }
204
205 // 7 fill legs, only include coupons after first exercise
206
207 legCurrencies_ = underlying_->legCurrencies();
208 legPayers_ = underlying_->legPayers();
209 legs_.clear();
210 Date firstExerciseDate = exerciseBuilder_->exercise()->dates().front();
211 for (auto const& l : underlying_->legs()) {
212 legs_.push_back(Leg());
213 for (auto const& c : l) {
214 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(c)) {
215 if (firstExerciseDate <= cpn->accrualStartDate()) {
216 legs_.back().push_back(c);
217 }
218 } else if (firstExerciseDate <= c->date()) {
219 legs_.back().push_back(c);
220 }
221 }
222 }
223
224 // 8 build swaption
225
226 if (settlementType_ == Settlement::Physical)
227 maturity_ = underlying_->maturity();
228 else
229 maturity_ = exerciseBuilder_->noticeDates().back();
230
231 if (exerciseType_ != Exercise::European && settlementType_ == Settlement::Cash &&
232 settlementMethod_ == Settlement::ParYieldCurve)
233 WLOG("Cash-settled Bermudan/American Swaption (id = "
234 << id() << ") with ParYieldCurve settlement method not supported by Lgm engine. "
235 << "Approximate pricing using CollateralizedCashPrice pricing methodology");
236
237 std::vector<QuantLib::Currency> ccys;
238 for (auto const& c : underlying_->legCurrencies())
239 ccys.push_back(parseCurrency(c));
240 auto swaption =
241 QuantLib::ext::make_shared<QuantExt::MultiLegOption>(underlying_->legs(), underlying_->legPayers(), ccys,
243
244 std::string builderType;
245 std::vector<std::string> builderPrecheckMessages;
246 // for European swaptions that are not handled by the black pricer, we fall back to the numeric Bermudan pricer
247 if (exerciseType_ == Exercise::European &&
248 QuantExt::BlackMultiLegOptionEngineBase::instrumentIsHandled(*swaption, builderPrecheckMessages)) {
249 builderType = "EuropeanSwaption";
250 } else {
251 QL_REQUIRE(
252 QuantExt::NumericLgmMultiLegOptionEngineBase::instrumentIsHandled(*swaption, builderPrecheckMessages),
253 "Swaption::build(): instrument is not handled by the available engines: " +
254 boost::join(builderPrecheckMessages, ", "));
255 if (exerciseType_ == Exercise::European || exerciseType_ == Exercise::Bermudan)
256 builderType = "BermudanSwaption";
257 else if (exerciseType_ == Exercise::American)
258 builderType = "AmericanSwaption";
259 }
260
261 DLOG("Getting builder for '" << builderType << "', got " << builderPrecheckMessages.size()
262 << " builder precheck messages:");
263 for (auto const& m : builderPrecheckMessages) {
264 DLOG(m);
265 }
266
267 auto swaptionBuilder = QuantLib::ext::dynamic_pointer_cast<SwaptionEngineBuilder>(engineFactory->builder(builderType));
268 QL_REQUIRE(swaptionBuilder, "Swaption::build(): internal error: could not cast to SwaptionEngineBuilder");
269
270 auto swapBuilder = QuantLib::ext::dynamic_pointer_cast<SwapEngineBuilderBase>(engineFactory->builder("Swap"));
271 QL_REQUIRE(swapBuilder, "Swaption::build(): internal error: could not cast to SwapEngineBuilder");
272
273 // 9.1 determine index (if several, pick first) got get the engine
274
275 QuantLib::ext::shared_ptr<InterestRateIndex> index;
276
277 for (auto const& l : underlying_->legs()) {
278 for (auto const& c : l) {
279 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c)) {
280 if (index == nullptr) {
281 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<IborIndex>(cpn->index())) {
282 DLOG("found ibor / ois index '" << tmp->name() << "'");
283 index = tmp;
284 } else if (auto tmp = QuantLib::ext::dynamic_pointer_cast<SwapIndex>(cpn->index())) {
285 DLOG("found cms index " << tmp->name() << ", use key '" << tmp->iborIndex()->name()
286 << "' to look up vol");
287 index = tmp->iborIndex();
288 } else if (auto tmp = QuantLib::ext::dynamic_pointer_cast<BMAIndex>(cpn->index())) {
289 DLOG("found bma/sifma index '" << tmp->name() << "'");
290 index = tmp;
291 }
292 }
293 }
294 }
295 }
296
297 if (index == nullptr) {
298 DLOG("no ibor, ois, bma/sifma, cms index found, use ccy key to look up vol");
299 }
300
301 // 9.2 determine strikes for calibration basket (simple approach, a la summit)
302
303 std::vector<Real> strikes(exerciseBuilder_->noticeDates().size(), Null<Real>());
304 for (Size i = 0; i < exerciseBuilder_->noticeDates().size(); ++i) {
305 Real firstFixedRate = Null<Real>(), lastFixedRate = Null<Real>();
306 Real firstFloatSpread = Null<Real>(), lastFloatSpread = Null<Real>();
307 for (auto const& l : underlying_->legs()) {
308 for (auto const& c : l) {
309 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<FixedRateCoupon>(c)) {
310 if (cpn->accrualStartDate() >= exerciseBuilder_->noticeDates()[i] && firstFixedRate == Null<Real>())
311 firstFixedRate = cpn->rate();
312 lastFixedRate = cpn->rate();
313 } else if (auto cpn = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c)) {
314 if (cpn->accrualStartDate() >= exerciseBuilder_->noticeDates()[i] &&
315 firstFloatSpread == Null<Real>())
316 firstFloatSpread = cpn->spread();
317 lastFloatSpread = cpn->spread();
318 if (index == nullptr) {
319 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<IborIndex>(cpn->index())) {
320 DLOG("found ibor / ois index '" << tmp->name() << "'");
321 index = tmp;
322 } else if (auto tmp = QuantLib::ext::dynamic_pointer_cast<SwapIndex>(cpn->index())) {
323 DLOG("found cms index " << tmp->name() << ", use key '" << tmp->iborIndex()->name()
324 << "' to look up vol");
325 index = tmp->iborIndex();
326 } else if (auto tmp = QuantLib::ext::dynamic_pointer_cast<BMAIndex>(cpn->index())) {
327 DLOG("found bma/sifma index '" << tmp->name() << "'");
328 index = tmp;
329 }
330 }
331 }
332 }
333 }
334 // if no first fixed rate (float spread) was found, fall back on the last values
335 if(firstFixedRate == Null<Real>())
336 firstFixedRate = lastFixedRate;
337 if(firstFloatSpread == Null<Real>())
338 firstFloatSpread = lastFloatSpread;
339 // construct calibration strike
340 if (firstFixedRate != Null<Real>()) {
341 strikes[i] = firstFixedRate;
342 if (firstFloatSpread != Null<Real>()) {
343 strikes[i] -= firstFloatSpread;
344 }
345 }
346 DLOG("calibration strike for ex date "
347 << QuantLib::io::iso_date(exerciseBuilder_->noticeDates()[i]) << " is "
348 << (strikes[i] == Null<Real>() ? "ATMF" : std::to_string(strikes[i])) << " (fixed rate "
349 << (firstFixedRate == Null<Real>() ? "NA" : std::to_string(firstFixedRate)) << ", spread "
350 << (firstFloatSpread == Null<Real>() ? "NA" : std::to_string(firstFloatSpread)) << ")");
351 }
352
353 // 9.3 get engine and set it
354
355 cpu_timer timer;
356 // use ibor / ois index as key, if possible, otherwise the npv currency
357 auto swaptionEngine = swaptionBuilder->engine(
358 id(), index == nullptr ? npvCurrency_ : IndexNameTranslator::instance().oreName(index->name()),
359 exerciseBuilder_->noticeDates(), underlying_->maturity(), strikes, exerciseType_ == Exercise::American,
360 envelope().additionalField("discount_curve", false), envelope().additionalField("security_spread", false));
361 timer.stop();
362 DLOG("Swaption model calibration time: " << timer.format(default_places, "%w") << " s");
363 swaption->setPricingEngine(swaptionEngine);
364 setSensitivityTemplate(*swaptionBuilder);
365
366 // 9.4 build underlying swaps, add premiums, build option wrapper
367
368 auto swapEngine =
369 swapBuilder->engine(parseCurrency(npvCurrency_), envelope().additionalField("discount_curve", false),
370 envelope().additionalField("security_spread", false));
371
372 std::vector<QuantLib::ext::shared_ptr<Instrument>> underlyingSwaps =
373 buildUnderlyingSwaps(swapEngine, exerciseBuilder_->noticeDates());
374
375 std::vector<QuantLib::ext::shared_ptr<Instrument>> additionalInstruments;
376 std::vector<Real> additionalMultipliers;
377 Real multiplier = positionType_ == Position::Long ? 1.0 : -1.0;
378 Date lastPremiumDate = addPremiums(additionalInstruments, additionalMultipliers, Position::Long ? 1.0 : -1.0,
380 engineFactory, swaptionBuilder->configuration(MarketContext::pricing));
381
382 instrument_ = QuantLib::ext::make_shared<BermudanOptionWrapper>(
383 swaption, positionType_ == Position::Long ? true : false, exerciseBuilder_->noticeDates(),
384 settlementType_ == Settlement::Physical ? true : false, underlyingSwaps, 1.0, 1.0, additionalInstruments,
385 additionalMultipliers);
386
387 maturity_ = std::max(maturity_, lastPremiumDate);
388
389 DLOG("Building Swaption done");
390}
391
392std::vector<QuantLib::ext::shared_ptr<Instrument>>
393Swaption::buildUnderlyingSwaps(const QuantLib::ext::shared_ptr<PricingEngine>& swapEngine,
394 const std::vector<Date>& exerciseDates) {
395 std::vector<QuantLib::ext::shared_ptr<Instrument>> swaps;
396 for (Size i = 0; i < exerciseDates.size(); ++i) {
397 std::vector<Leg> legs = underlying_->legs();
398 std::vector<bool> payer = underlying_->legPayers();
399 for (Size j = 0; j < legs.size(); ++j) {
400 Date ed = exerciseDates[i];
401 auto it = std::lower_bound(legs[j].begin(), legs[j].end(), exerciseDates[i],
402 [&ed](const QuantLib::ext::shared_ptr<CashFlow>& c, const Date& d) {
403 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(c)) {
404 return cpn->accrualStartDate() < ed;
405 } else {
406 return c->date() < ed;
407 }
408 });
409 if (it != legs[j].begin())
410 --it;
411 legs[j].erase(legs[j].begin(), it);
412 }
413 auto newSwap = QuantLib::ext::make_shared<QuantLib::Swap>(legs, payer);
414 if (swapEngine != nullptr) {
415 newSwap->setPricingEngine(swapEngine);
416 }
417 swaps.push_back(newSwap);
418 for (auto const& l : legs) {
419 if (l.empty()) {
420 WLOG("Added empty leg to underlying swap for exercise " << QuantLib::io::iso_date(exerciseDates[i])
421 << "!");
422 } else {
423 Date d;
424 if (auto cpn = QuantLib::ext::dynamic_pointer_cast<Coupon>(l.front())) {
425 d = cpn->accrualStartDate();
426 } else {
427 d = l.front()->date();
428 }
429 DLOG("Added leg with start date " << QuantLib::io::iso_date(d) << " for exercise "
430 << QuantLib::io::iso_date(exerciseDates[i]));
431 }
432 }
433 }
434 return swaps;
435}
436
437QuantLib::Real Swaption::notional() const {
438 Real tmp = 0.0;
439 for (auto const& l : underlying_->legs()) {
440 tmp = std::max(tmp, currentNotional(l));
441 }
442 return tmp;
443}
444
445bool Swaption::isExercised() const { return exerciseBuilder_->isExercised(); }
446
447const std::map<std::string, boost::any>& Swaption::additionalData() const {
448 // use the build time as of date to determine current notionals
449 Date asof = Settings::instance().evaluationDate();
450 for (Size i = 0; i < std::min(legData_.size(), legs_.size()); ++i) {
451 string legID = to_string(i + 1);
452 additionalData_["legType[" + legID + "]"] = legData_[i].legType();
453 additionalData_["isPayer[" + legID + "]"] = legData_[i].isPayer();
454 additionalData_["notionalCurrency[" + legID + "]"] = legData_[i].currency();
455 for (Size j = 0; j < legs_[i].size(); ++j) {
456 QuantLib::ext::shared_ptr<CashFlow> flow = legs_[i][j];
457 // pick flow with earliest future payment date on this leg
458 if (flow->date() > asof) {
459 additionalData_["amount[" + legID + "]"] = flow->amount();
460 additionalData_["paymentDate[" + legID + "]"] = to_string(flow->date());
461 QuantLib::ext::shared_ptr<Coupon> coupon = QuantLib::ext::dynamic_pointer_cast<Coupon>(flow);
462 if (coupon) {
463 additionalData_["currentNotional[" + legID + "]"] = coupon->nominal();
464 additionalData_["rate[" + legID + "]"] = coupon->rate();
465 QuantLib::ext::shared_ptr<FloatingRateCoupon> frc = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(flow);
466 if (frc) {
467 additionalData_["index[" + legID + "]"] = frc->index()->name();
468 additionalData_["spread[" + legID + "]"] = frc->spread();
469 }
470 }
471 break;
472 }
473 }
474 if (legs_[i].size() > 0) {
475 QuantLib::ext::shared_ptr<Coupon> coupon = QuantLib::ext::dynamic_pointer_cast<Coupon>(legs_[i][0]);
476 if (coupon)
477 additionalData_["originalNotional[" + legID + "]"] = coupon->nominal();
478 }
479 }
480 return additionalData_;
481}
482
484 Trade::fromXML(node);
485 XMLNode* swapNode = XMLUtils::getChildNode(node, "SwaptionData");
486 optionData_.fromXML(XMLUtils::getChildNode(swapNode, "OptionData"));
487 legData_.clear();
488 vector<XMLNode*> nodes = XMLUtils::getChildrenNodes(swapNode, "LegData");
489 for (Size i = 0; i < nodes.size(); i++) {
490 LegData ld;
491 ld.fromXML(nodes[i]);
492 legData_.push_back(ld);
493 }
494}
495
497 XMLNode* node = Trade::toXML(doc);
498 XMLNode* swaptionNode = doc.allocNode("SwaptionData");
499 XMLUtils::appendNode(node, swaptionNode);
500
501 XMLUtils::appendNode(swaptionNode, optionData_.toXML(doc));
502 for (Size i = 0; i < legData_.size(); i++)
503 XMLUtils::appendNode(swaptionNode, legData_[i].toXML(doc));
504
505 return node;
506}
507
508map<AssetClass, set<string>>
509Swaption::underlyingIndices(const QuantLib::ext::shared_ptr<ReferenceDataManager>& referenceDataManager) const {
510 map<AssetClass, set<string>> result;
511 if (auto s = envelope().additionalField("security_spread", false); !s.empty())
512 result[AssetClass::BOND] = {s};
513 return result;
514}
515
516} // namespace data
517} // namespace ore
Engine builder for Swaps.
Serializable object holding generic trade data, reporting dimensions.
Definition: envelope.hpp:51
Serializable object holding leg data.
Definition: legdata.hpp:844
virtual void fromXML(XMLNode *node) override
Definition: legdata.cpp:759
const string & settlementMethod() const
Definition: optiondata.hpp:82
const string & longShort() const
Definition: optiondata.hpp:70
const string & style() const
Definition: optiondata.hpp:74
const string & settlement() const
Definition: optiondata.hpp:81
virtual void fromXML(XMLNode *node) override
Definition: optiondata.cpp:32
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: optiondata.cpp:86
const PremiumData & premiumData() const
Definition: optiondata.hpp:83
void addData(const RequiredFixings &requiredFixings)
OptionData optionData_
Definition: swaption.hpp:69
std::vector< QuantLib::ext::shared_ptr< Instrument > > buildUnderlyingSwaps(const QuantLib::ext::shared_ptr< PricingEngine > &, const std::vector< Date > &)
build underlying swaps for exposure simulation
Definition: swaption.cpp:393
QuantLib::ext::shared_ptr< ExerciseBuilder > exerciseBuilder_
Definition: swaption.hpp:77
vector< LegData > legData_
Definition: swaption.hpp:70
QuantLib::Real notional() const override
Return the current notional in npvCurrency. See individual sub-classes for the precise definition.
Definition: swaption.cpp:437
virtual void fromXML(XMLNode *node) override
Definition: swaption.cpp:483
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: swaption.cpp:496
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
Definition: swaption.cpp:509
QuantLib::ext::shared_ptr< ore::data::Swap > underlying_
Definition: swaption.hpp:76
bool isExercised() const
Definition: swaption.cpp:445
Exercise::Type exerciseType_
Definition: swaption.hpp:79
Settlement::Method settlementMethod_
Definition: swaption.hpp:81
Settlement::Type settlementType_
Definition: swaption.hpp:80
void build(const QuantLib::ext::shared_ptr< EngineFactory > &) override
Definition: swaption.cpp:62
Position::Type positionType_
Definition: swaption.hpp:78
const std::map< std::string, boost::any > & additionalData() const override
returns all additional data returned by the trade once built
Definition: swaption.cpp:447
string npvCurrency_
Definition: trade.hpp:201
std::vector< bool > legPayers_
Definition: trade.hpp:200
std::vector< string > legCurrencies_
Definition: trade.hpp:199
const std::vector< QuantLib::Leg > & legs() const
Definition: trade.hpp:143
std::vector< QuantLib::Leg > legs_
Definition: trade.hpp:198
QuantLib::Real notional_
Definition: trade.hpp:202
virtual void fromXML(XMLNode *node) override
Definition: trade.cpp:34
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)
Definition: trade.cpp:58
void setSensitivityTemplate(const EngineBuilder &builder)
Definition: trade.cpp:295
virtual XMLNode * toXML(XMLDocument &doc) const override
Definition: trade.cpp:46
RequiredFixings requiredFixings_
Definition: trade.hpp:223
const Envelope & envelope() const
Definition: trade.hpp:135
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
Small XML Document wrapper class.
Definition: xmlutils.hpp:65
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
Definition: xmlutils.cpp:132
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
Definition: xmlutils.cpp:428
static XMLNode * getChildNode(XMLNode *n, const string &name="")
Definition: xmlutils.cpp:387
static void appendNode(XMLNode *parent, XMLNode *child)
Definition: xmlutils.cpp:406
Exercise::Type parseExerciseType(const std::string &s)
Convert text to QuantLib::Exercise::Type.
Definition: parsers.cpp:466
Settlement::Method parseSettlementMethod(const std::string &s)
Convert text to QuantLib::Settlement::Method.
Definition: parsers.cpp:450
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Definition: parsers.cpp:290
Position::Type parsePositionType(const std::string &s)
Convert text to QuantLib::Position::Type.
Definition: parsers.cpp:404
Settlement::Type parseSettlementType(const std::string &s)
Convert text to QuantLib::Settlement::Type.
Definition: parsers.cpp:434
translates between QuantLib::Index::name() and ORE names
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554
#define WLOG(text)
Logging Macro (Level = Warning)
Definition: log.hpp:550
Real currentNotional(const Leg &leg)
Definition: legdata.cpp:2435
Size size(const ValueType &v)
Definition: value.cpp:145
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
Serializable Credit Default Swap.
Definition: namespaces.docs:23
Wrapper for option instruments, tracks whether option has been exercised or not.
Swaption data model and serialization.
vector< Real > strikes
string conversion utilities