QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
floatfloatswap.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2013 Peter Caspers
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
32#include <ql/optional.hpp>
33#include <utility>
34
35namespace QuantLib {
36
38 const Real nominal1,
39 const Real nominal2,
40 Schedule schedule1,
41 ext::shared_ptr<InterestRateIndex> index1,
42 DayCounter dayCount1,
43 Schedule schedule2,
44 ext::shared_ptr<InterestRateIndex> index2,
45 DayCounter dayCount2,
46 const bool intermediateCapitalExchange,
47 const bool finalCapitalExchange,
48 const Real gearing1,
49 const Real spread1,
50 const Real cappedRate1,
51 const Real flooredRate1,
52 const Real gearing2,
53 const Real spread2,
54 const Real cappedRate2,
55 const Real flooredRate2,
56 const ext::optional<BusinessDayConvention>& paymentConvention1,
57 const ext::optional<BusinessDayConvention>& paymentConvention2)
58 : Swap(2), type_(type), nominal1_(std::vector<Real>(schedule1.size() - 1, nominal1)),
59 nominal2_(std::vector<Real>(schedule2.size() - 1, nominal2)),
60 schedule1_(std::move(schedule1)), schedule2_(std::move(schedule2)),
61 index1_(std::move(index1)), index2_(std::move(index2)),
62 gearing1_(std::vector<Real>(schedule1_.size() - 1, gearing1)),
63 gearing2_(std::vector<Real>(schedule2_.size() - 1, gearing2)),
64 spread1_(std::vector<Real>(schedule1_.size() - 1, spread1)),
65 spread2_(std::vector<Real>(schedule2_.size() - 1, spread2)),
66 cappedRate1_(std::vector<Real>(schedule1_.size() - 1, cappedRate1)),
67 flooredRate1_(std::vector<Real>(schedule1_.size() - 1, flooredRate1)),
68 cappedRate2_(std::vector<Real>(schedule2_.size() - 1, cappedRate2)),
69 flooredRate2_(std::vector<Real>(schedule2_.size() - 1, flooredRate2)),
70 dayCount1_(std::move(dayCount1)), dayCount2_(std::move(dayCount2)),
71 intermediateCapitalExchange_(intermediateCapitalExchange),
72 finalCapitalExchange_(finalCapitalExchange) {
73
75 }
76
78 std::vector<Real> nominal1,
79 std::vector<Real> nominal2,
80 Schedule schedule1,
81 ext::shared_ptr<InterestRateIndex> index1,
82 DayCounter dayCount1,
83 Schedule schedule2,
84 ext::shared_ptr<InterestRateIndex> index2,
85 DayCounter dayCount2,
86 const bool intermediateCapitalExchange,
87 const bool finalCapitalExchange,
88 std::vector<Real> gearing1,
89 std::vector<Real> spread1,
90 std::vector<Real> cappedRate1,
91 std::vector<Real> flooredRate1,
92 std::vector<Real> gearing2,
93 std::vector<Real> spread2,
94 std::vector<Real> cappedRate2,
95 std::vector<Real> flooredRate2,
96 const ext::optional<BusinessDayConvention>& paymentConvention1,
97 const ext::optional<BusinessDayConvention>& paymentConvention2)
98 : Swap(2), type_(type), nominal1_(std::move(nominal1)), nominal2_(std::move(nominal2)),
99 schedule1_(std::move(schedule1)), schedule2_(std::move(schedule2)),
100 index1_(std::move(index1)), index2_(std::move(index2)), gearing1_(std::move(gearing1)),
101 gearing2_(std::move(gearing2)), spread1_(std::move(spread1)), spread2_(std::move(spread2)),
102 cappedRate1_(std::move(cappedRate1)), flooredRate1_(std::move(flooredRate1)),
103 cappedRate2_(std::move(cappedRate2)), flooredRate2_(std::move(flooredRate2)),
104 dayCount1_(std::move(dayCount1)), dayCount2_(std::move(dayCount2)),
105 intermediateCapitalExchange_(intermediateCapitalExchange),
106 finalCapitalExchange_(finalCapitalExchange) {
107
109 }
110
112 ext::optional<BusinessDayConvention> paymentConvention1,
113 ext::optional<BusinessDayConvention> paymentConvention2) {
114
115 QL_REQUIRE(nominal1_.size() == schedule1_.size() - 1,
116 "nominal1 size (" << nominal1_.size()
117 << ") does not match schedule1 size ("
118 << schedule1_.size() << ")");
119 QL_REQUIRE(nominal2_.size() == schedule2_.size() - 1,
120 "nominal2 size (" << nominal2_.size()
121 << ") does not match schedule2 size ("
122 << nominal2_.size() << ")");
123 QL_REQUIRE(gearing1_.empty() || gearing1_.size() == nominal1_.size(),
124 "nominal1 size (" << nominal1_.size() << ") does not match gearing1 size ("
125 << gearing1_.size() << ")");
126 QL_REQUIRE(gearing2_.empty() || gearing2_.size() == nominal2_.size(),
127 "nominal2 size (" << nominal2_.size() << ") does not match gearing2 size ("
128 << gearing2_.size() << ")");
129 QL_REQUIRE(cappedRate1_.empty() || cappedRate1_.size() == nominal1_.size(),
130 "nominal1 size (" << nominal1_.size() << ") does not match cappedRate1 size ("
131 << cappedRate1_.size() << ")");
132 QL_REQUIRE(cappedRate2_.empty() || cappedRate2_.size() == nominal2_.size(),
133 "nominal2 size (" << nominal2_.size() << ") does not match cappedRate2 size ("
134 << cappedRate2_.size() << ")");
135 QL_REQUIRE(flooredRate1_.empty() || flooredRate1_.size() == nominal1_.size(),
136 "nominal1 size (" << nominal1_.size() << ") does not match flooredRate1 size ("
137 << flooredRate1_.size() << ")");
138 QL_REQUIRE(flooredRate2_.empty() || flooredRate2_.size() == nominal2_.size(),
139 "nominal2 size (" << nominal2_.size() << ") does not match flooredRate2 size ("
140 << flooredRate2_.size() << ")");
141
142 if (paymentConvention1) // NOLINT(readability-implicit-bool-conversion)
144 else
146
147 if (paymentConvention2) // NOLINT(readability-implicit-bool-conversion)
149 else
151
152 if (gearing1_.empty())
153 gearing1_ = std::vector<Real>(nominal1_.size(), 1.0);
154 if (gearing2_.empty())
155 gearing2_ = std::vector<Real>(nominal2_.size(), 1.0);
156 if (spread1_.empty())
157 spread1_ = std::vector<Real>(nominal1_.size(), 0.0);
158 if (spread2_.empty())
159 spread2_ = std::vector<Real>(nominal2_.size(), 0.0);
160 if (cappedRate1_.empty())
161 cappedRate1_ = std::vector<Real>(nominal1_.size(), Null<Real>());
162 if (cappedRate2_.empty())
163 cappedRate2_ = std::vector<Real>(nominal2_.size(), Null<Real>());
164 if (flooredRate1_.empty())
165 flooredRate1_ = std::vector<Real>(nominal1_.size(), Null<Real>());
166 if (flooredRate2_.empty())
167 flooredRate2_ = std::vector<Real>(nominal2_.size(), Null<Real>());
168
169 bool isNull;
170 isNull = cappedRate1_[0] == Null<Real>();
171 for (Size i = 0; i < cappedRate1_.size(); i++) {
172 if (isNull)
174 "cappedRate1 must be null for all or none entry ("
175 << (i + 1) << "th is " << cappedRate1_[i]
176 << ")");
177 else
179 "cappedRate 1 must be null for all or none entry ("
180 << "1st is " << cappedRate1_[0] << ")");
181 }
182 isNull = cappedRate2_[0] == Null<Real>();
183 for (Size i = 0; i < cappedRate2_.size(); i++) {
184 if (isNull)
186 "cappedRate2 must be null for all or none entry ("
187 << (i + 1) << "th is " << cappedRate2_[i]
188 << ")");
189 else
191 "cappedRate2 must be null for all or none entry ("
192 << "1st is " << cappedRate2_[0] << ")");
193 }
194 isNull = flooredRate1_[0] == Null<Real>();
195 for (Size i = 0; i < flooredRate1_.size(); i++) {
196 if (isNull)
198 "flooredRate1 must be null for all or none entry ("
199 << (i + 1) << "th is " << flooredRate1_[i]
200 << ")");
201 else
203 "flooredRate 1 must be null for all or none entry ("
204 << "1st is " << flooredRate1_[0] << ")");
205 }
206 isNull = flooredRate2_[0] == Null<Real>();
207 for (Size i = 0; i < flooredRate2_.size(); i++) {
208 if (isNull)
210 "flooredRate2 must be null for all or none entry ("
211 << (i + 1) << "th is " << flooredRate2_[i]
212 << ")");
213 else
215 "flooredRate2 must be null for all or none entry ("
216 << "1st is " << flooredRate2_[0] << ")");
217 }
218
219 // if the gearing is zero then the ibor / cms leg will be set up with
220 // fixed coupons which makes trouble here in this context. We therefore
221 // use a dirty trick and enforce the gearing to be non zero.
222 for (Real& i : gearing1_)
223 if (close(i, 0.0))
224 i = QL_EPSILON;
225 for (Real& i : gearing2_)
226 if (close(i, 0.0))
227 i = QL_EPSILON;
228
229 ext::shared_ptr<IborIndex> ibor1 =
230 ext::dynamic_pointer_cast<IborIndex>(index1_);
231 ext::shared_ptr<IborIndex> ibor2 =
232 ext::dynamic_pointer_cast<IborIndex>(index2_);
233 ext::shared_ptr<SwapIndex> cms1 =
234 ext::dynamic_pointer_cast<SwapIndex>(index1_);
235 ext::shared_ptr<SwapIndex> cms2 =
236 ext::dynamic_pointer_cast<SwapIndex>(index2_);
237 ext::shared_ptr<SwapSpreadIndex> cmsspread1 =
238 ext::dynamic_pointer_cast<SwapSpreadIndex>(index1_);
239 ext::shared_ptr<SwapSpreadIndex> cmsspread2 =
240 ext::dynamic_pointer_cast<SwapSpreadIndex>(index2_);
241
242 QL_REQUIRE(ibor1 != nullptr || cms1 != nullptr || cmsspread1 != nullptr,
243 "index1 must be ibor or cms or cms spread");
244 QL_REQUIRE(ibor2 != nullptr || cms2 != nullptr || cmsspread2 != nullptr,
245 "index2 must be ibor or cms");
246
247 if (ibor1 != nullptr) {
248 IborLeg leg(schedule1_, ibor1);
249 leg = leg.withNotionals(nominal1_)
250 .withPaymentDayCounter(dayCount1_)
251 .withPaymentAdjustment(paymentConvention1_)
252 .withSpreads(spread1_)
253 .withGearings(gearing1_);
254 if (cappedRate1_[0] != Null<Real>())
255 leg = leg.withCaps(cappedRate1_);
256 if (flooredRate1_[0] != Null<Real>())
257 leg = leg.withFloors(flooredRate1_);
258 legs_[0] = leg;
259 }
260
261 if (ibor2 != nullptr) {
262 IborLeg leg(schedule2_, ibor2);
263 leg = leg.withNotionals(nominal2_)
264 .withPaymentDayCounter(dayCount2_)
265 .withPaymentAdjustment(paymentConvention2_)
266 .withSpreads(spread2_)
267 .withGearings(gearing2_);
268 if (cappedRate2_[0] != Null<Real>())
269 leg = leg.withCaps(cappedRate2_);
270 if (flooredRate2_[0] != Null<Real>())
271 leg = leg.withFloors(flooredRate2_);
272 legs_[1] = leg;
273 }
274
275 if (cms1 != nullptr) {
276 CmsLeg leg(schedule1_, cms1);
277 leg = leg.withNotionals(nominal1_)
278 .withPaymentDayCounter(dayCount1_)
279 .withPaymentAdjustment(paymentConvention1_)
280 .withSpreads(spread1_)
281 .withGearings(gearing1_);
282 if (cappedRate1_[0] != Null<Real>())
283 leg = leg.withCaps(cappedRate1_);
284 if (flooredRate1_[0] != Null<Real>())
285 leg = leg.withFloors(flooredRate1_);
286 legs_[0] = leg;
287 }
288
289 if (cms2 != nullptr) {
290 CmsLeg leg(schedule2_, cms2);
291 leg = leg.withNotionals(nominal2_)
292 .withPaymentDayCounter(dayCount2_)
293 .withPaymentAdjustment(paymentConvention2_)
294 .withSpreads(spread2_)
295 .withGearings(gearing2_);
296 if (cappedRate2_[0] != Null<Real>())
297 leg = leg.withCaps(cappedRate2_);
298 if (flooredRate2_[0] != Null<Real>())
299 leg = leg.withFloors(flooredRate2_);
300 legs_[1] = leg;
301 }
302
303 if (cmsspread1 != nullptr) {
304 CmsSpreadLeg leg(schedule1_, cmsspread1);
305 leg = leg.withNotionals(nominal1_)
306 .withPaymentDayCounter(dayCount1_)
307 .withPaymentAdjustment(paymentConvention1_)
308 .withSpreads(spread1_)
309 .withGearings(gearing1_);
310 if (cappedRate1_[0] != Null<Real>())
311 leg = leg.withCaps(cappedRate1_);
312 if (flooredRate1_[0] != Null<Real>())
313 leg = leg.withFloors(flooredRate1_);
314 legs_[0] = leg;
315 }
316
317 if (cmsspread2 != nullptr) {
318 CmsSpreadLeg leg(schedule2_, cmsspread2);
319 leg = leg.withNotionals(nominal2_)
320 .withPaymentDayCounter(dayCount2_)
321 .withPaymentAdjustment(paymentConvention2_)
322 .withSpreads(spread2_)
323 .withGearings(gearing2_);
324 if (cappedRate2_[0] != Null<Real>())
325 leg = leg.withCaps(cappedRate2_);
326 if (flooredRate2_[0] != Null<Real>())
327 leg = leg.withFloors(flooredRate2_);
328 legs_[1] = leg;
329 }
330
332 for (Size i = 0; i < legs_[0].size() - 1; i++) {
333 Real cap = nominal1_[i] - nominal1_[i + 1];
334 if (!close(cap, 0.0)) {
335 auto it1 = legs_[0].begin();
336 std::advance(it1, i + 1);
337 legs_[0].insert(
338 it1, ext::shared_ptr<CashFlow>(
339 new Redemption(cap, legs_[0][i]->date())));
340 auto it2 = nominal1_.begin();
341 std::advance(it2, i + 1);
342 nominal1_.insert(it2, nominal1_[i]);
343 i++;
344 }
345 }
346 for (Size i = 0; i < legs_[1].size() - 1; i++) {
347 Real cap = nominal2_[i] - nominal2_[i + 1];
348 if (!close(cap, 0.0)) {
349 auto it1 = legs_[1].begin();
350 std::advance(it1, i + 1);
351 legs_[1].insert(
352 it1, ext::shared_ptr<CashFlow>(
353 new Redemption(cap, legs_[1][i]->date())));
354 auto it2 = nominal2_.begin();
355 std::advance(it2, i + 1);
356 nominal2_.insert(it2, nominal2_[i]);
357 i++;
358 }
359 }
360 }
361
363 legs_[0].push_back(ext::shared_ptr<CashFlow>(
364 new Redemption(nominal1_.back(), legs_[0].back()->date())));
365 nominal1_.push_back(nominal1_.back());
366 legs_[1].push_back(ext::shared_ptr<CashFlow>(
367 new Redemption(nominal2_.back(), legs_[1].back()->date())));
368 nominal2_.push_back(nominal2_.back());
369 }
370
371 for (Leg::const_iterator i = legs_[0].begin(); i < legs_[0].end(); ++i)
372 registerWith(*i);
373
374 for (Leg::const_iterator i = legs_[1].begin(); i < legs_[1].end(); ++i)
375 registerWith(*i);
376
377 switch (type_) {
378 case Swap::Payer:
379 payer_[0] = -1.0;
380 payer_[1] = +1.0;
381 break;
382 case Swap::Receiver:
383 payer_[0] = +1.0;
384 payer_[1] = -1.0;
385 break;
386 default:
387 QL_FAIL("Unknown float float - swap type");
388 }
389 }
390
392
394
395 auto* arguments = dynamic_cast<FloatFloatSwap::arguments*>(args);
396
397 if (arguments == nullptr)
398 return; // swap engine ... // QL_REQUIRE(arguments != 0, "argument type does not match");
399
405
406 const Leg &leg1Coupons = leg1();
407 const Leg &leg2Coupons = leg2();
408
410 arguments->leg1FixingDates = std::vector<Date>(leg1Coupons.size());
412 arguments->leg2FixingDates = std::vector<Date>(leg2Coupons.size());
413
415 arguments->leg1Gearings = std::vector<Real>(leg1Coupons.size());
417 arguments->leg2Gearings = std::vector<Real>(leg2Coupons.size());
418
420 std::vector<Real>(leg1Coupons.size(), Null<Real>());
422 std::vector<Real>(leg2Coupons.size(), Null<Real>());
423
425 std::vector<bool>(leg1Coupons.size(), false);
427 std::vector<bool>(leg2Coupons.size(), false);
428
430 std::vector<Real>(leg1Coupons.size(), Null<Real>());
432 std::vector<Real>(leg2Coupons.size(), Null<Real>());
433
434 for (Size i = 0; i < leg1Coupons.size(); ++i) {
435 ext::shared_ptr<FloatingRateCoupon> coupon =
436 ext::dynamic_pointer_cast<FloatingRateCoupon>(leg1Coupons[i]);
437 if (coupon != nullptr) {
438 arguments->leg1AccrualTimes[i] = coupon->accrualPeriod();
439 arguments->leg1PayDates[i] = coupon->date();
440 arguments->leg1ResetDates[i] = coupon->accrualStartDate();
441 arguments->leg1FixingDates[i] = coupon->fixingDate();
442 arguments->leg1Spreads[i] = coupon->spread();
443 arguments->leg1Gearings[i] = coupon->gearing();
444 try {
445 arguments->leg1Coupons[i] = coupon->amount();
446 }
447 catch (Error &) {
449 }
450 ext::shared_ptr<CappedFlooredCoupon> cfcoupon =
451 ext::dynamic_pointer_cast<CappedFlooredCoupon>(
452 leg1Coupons[i]);
453 if (cfcoupon != nullptr) {
454 arguments->leg1CappedRates[i] = cfcoupon->cap();
455 arguments->leg1FlooredRates[i] = cfcoupon->floor();
456 }
457 } else {
458 ext::shared_ptr<CashFlow> cashflow =
459 ext::dynamic_pointer_cast<CashFlow>(leg1Coupons[i]);
460 std::vector<Date>::const_iterator j =
461 std::find(arguments->leg1PayDates.begin(),
462 arguments->leg1PayDates.end(), cashflow->date());
464 "nominal redemption on "
465 << cashflow->date()
466 << "has no corresponding coupon");
467 Size jIdx = j - arguments->leg1PayDates.begin();
469 arguments->leg1Coupons[i] = cashflow->amount();
473 arguments->leg1AccrualTimes[i] = 0.0;
474 arguments->leg1Spreads[i] = 0.0;
475 arguments->leg1Gearings[i] = 1.0;
476 arguments->leg1PayDates[i] = cashflow->date();
477 }
478 }
479
480 for (Size i = 0; i < leg2Coupons.size(); ++i) {
481 ext::shared_ptr<FloatingRateCoupon> coupon =
482 ext::dynamic_pointer_cast<FloatingRateCoupon>(leg2Coupons[i]);
483 if (coupon != nullptr) {
484 arguments->leg2AccrualTimes[i] = coupon->accrualPeriod();
485 arguments->leg2PayDates[i] = coupon->date();
486 arguments->leg2ResetDates[i] = coupon->accrualStartDate();
487 arguments->leg2FixingDates[i] = coupon->fixingDate();
488 arguments->leg2Spreads[i] = coupon->spread();
489 arguments->leg2Gearings[i] = coupon->gearing();
490 try {
491 arguments->leg2Coupons[i] = coupon->amount();
492 }
493 catch (Error &) {
495 }
496 ext::shared_ptr<CappedFlooredCoupon> cfcoupon =
497 ext::dynamic_pointer_cast<CappedFlooredCoupon>(
498 leg2Coupons[i]);
499 if (cfcoupon != nullptr) {
500 arguments->leg2CappedRates[i] = cfcoupon->cap();
501 arguments->leg2FlooredRates[i] = cfcoupon->floor();
502 }
503 } else {
504 ext::shared_ptr<CashFlow> cashflow =
505 ext::dynamic_pointer_cast<CashFlow>(leg2Coupons[i]);
506 std::vector<Date>::const_iterator j =
507 std::find(arguments->leg2PayDates.begin(),
508 arguments->leg2PayDates.end(), cashflow->date());
510 "nominal redemption on "
511 << cashflow->date()
512 << "has no corresponding coupon");
513 Size jIdx = j - arguments->leg2PayDates.begin();
515 arguments->leg2Coupons[i] = cashflow->amount();
519 arguments->leg2AccrualTimes[i] = 0.0;
520 arguments->leg2Spreads[i] = 0.0;
521 arguments->leg2Gearings[i] = 1.0;
522 arguments->leg2PayDates[i] = cashflow->date();
523 }
524 }
525 }
526
528
531 }
532
534
536
537 QL_REQUIRE(nominal1.size() == leg1ResetDates.size(),
538 "nominal1 size is different from resetDates1 size");
539 QL_REQUIRE(nominal1.size() == leg1FixingDates.size(),
540 "nominal1 size is different from fixingDates1 size");
541 QL_REQUIRE(nominal1.size() == leg1PayDates.size(),
542 "nominal1 size is different from payDates1 size");
543 QL_REQUIRE(nominal1.size() == leg1Spreads.size(),
544 "nominal1 size is different from spreads1 size");
545 QL_REQUIRE(nominal1.size() == leg1Gearings.size(),
546 "nominal1 size is different from gearings1 size");
547 QL_REQUIRE(nominal1.size() == leg1CappedRates.size(),
548 "nominal1 size is different from cappedRates1 size");
549 QL_REQUIRE(nominal1.size() == leg1FlooredRates.size(),
550 "nominal1 size is different from flooredRates1 size");
551 QL_REQUIRE(nominal1.size() == leg1Coupons.size(),
552 "nominal1 size is different from coupons1 size");
553 QL_REQUIRE(nominal1.size() == leg1AccrualTimes.size(),
554 "nominal1 size is different from accrualTimes1 size");
556 "nominal1 size is different from redemption1 size");
557
558 QL_REQUIRE(nominal2.size() == leg2ResetDates.size(),
559 "nominal2 size is different from resetDates2 size");
560 QL_REQUIRE(nominal2.size() == leg2FixingDates.size(),
561 "nominal2 size is different from fixingDates2 size");
562 QL_REQUIRE(nominal2.size() == leg2PayDates.size(),
563 "nominal2 size is different from payDates2 size");
564 QL_REQUIRE(nominal2.size() == leg2Spreads.size(),
565 "nominal2 size is different from spreads2 size");
566 QL_REQUIRE(nominal2.size() == leg2Gearings.size(),
567 "nominal2 size is different from gearings2 size");
568 QL_REQUIRE(nominal2.size() == leg2CappedRates.size(),
569 "nominal2 size is different from cappedRates2 size");
570 QL_REQUIRE(nominal2.size() == leg2FlooredRates.size(),
571 "nominal2 size is different from flooredRates2 size");
572 QL_REQUIRE(nominal2.size() == leg2Coupons.size(),
573 "nominal2 size is different from coupons2 size");
574 QL_REQUIRE(nominal2.size() == leg2AccrualTimes.size(),
575 "nominal2 size is different from accrualTimes2 size");
577 "nominal2 size is different from redemption2 size");
578
579 QL_REQUIRE(index1 != nullptr, "index1 is null");
580 QL_REQUIRE(index2 != nullptr, "index2 is null");
581 }
582
584}
Floating rate coupon with additional cap/floor.
Cash-flow analysis functions.
Cash flow vector builders.
helper class building a sequence of capped/floored cms-rate coupons
Definition: cmscoupon.hpp:70
helper class building a sequence of capped/floored cms-spread-rate coupons
day counter class
Definition: daycounter.hpp:44
Base error class.
Definition: errors.hpp:39
Arguments for float float swap calculation
ext::shared_ptr< InterestRateIndex > index1
ext::shared_ptr< InterestRateIndex > index2
std::vector< Real > cappedRate2_
std::vector< Real > flooredRate2_
std::vector< Real > gearing2_
const Leg & leg2() const
const Leg & leg1() const
std::vector< Real > nominal1_
std::vector< Real > spread1_
std::vector< Real > cappedRate1_
BusinessDayConvention paymentConvention2() const
std::vector< Real > spread2_
const bool intermediateCapitalExchange_
std::vector< Real > nominal2_
std::vector< Real > gearing1_
BusinessDayConvention paymentConvention2_
FloatFloatSwap(Swap::Type type, Real nominal1, Real nominal2, Schedule schedule1, ext::shared_ptr< InterestRateIndex > index1, DayCounter dayCount1, Schedule schedule2, ext::shared_ptr< InterestRateIndex > index2, DayCounter dayCount2, bool intermediateCapitalExchange=false, bool finalCapitalExchange=false, Real gearing1=1.0, Real spread1=0.0, Real cappedRate1=Null< Real >(), Real flooredRate1=Null< Real >(), Real gearing2=1.0, Real spread2=0.0, Real cappedRate2=Null< Real >(), Real flooredRate2=Null< Real >(), const ext::optional< BusinessDayConvention > &paymentConvention1=ext::nullopt, const ext::optional< BusinessDayConvention > &paymentConvention2=ext::nullopt)
void setupArguments(PricingEngine::arguments *args) const override
BusinessDayConvention paymentConvention1_
std::vector< Real > flooredRate1_
ext::shared_ptr< InterestRateIndex > index1_
void init(ext::optional< BusinessDayConvention > paymentConvention1, ext::optional< BusinessDayConvention > paymentConvention2)
void setupExpired() const override
ext::shared_ptr< InterestRateIndex > index2_
void fetchResults(const PricingEngine::results *) const override
BusinessDayConvention paymentConvention1() const
helper class building a sequence of capped/floored ibor-rate coupons
Definition: iborcoupon.hpp:134
template class providing a null value for a given type.
Definition: null.hpp:76
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Definition: observable.hpp:228
Bond redemption.
Payment schedule.
Definition: schedule.hpp:40
Size size() const
Definition: schedule.hpp:69
BusinessDayConvention businessDayConvention() const
Definition: schedule.hpp:196
void validate() const override
Definition: swap.cpp:171
void reset() override
Definition: swap.cpp:176
Interest rate swap.
Definition: swap.hpp:41
void setupArguments(PricingEngine::arguments *) const override
Definition: swap.cpp:87
std::vector< Leg > legs_
Definition: swap.hpp:133
const Leg & leg(Size j) const
Definition: swap.hpp:111
void setupExpired() const override
Definition: swap.cpp:78
void fetchResults(const PricingEngine::results *) const override
Definition: swap.cpp:95
std::vector< Real > payer_
Definition: swap.hpp:134
CMS coupon.
CMS spread coupon.
Coupon pricers.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition: errors.hpp:92
swap exchanging capped floored Libor or CMS coupons with quite general specification....
#define QL_EPSILON
Definition: qldefines.hpp:178
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
Coupon paying a Libor-type index.
base class for Inter-Bank-Offered-Rate indexes
Definition: any.hpp:35
bool close(const Quantity &m1, const Quantity &m2, Size n)
Definition: quantity.cpp:163
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
STL namespace.
Maps optional to either the boost or std implementation.
ext::shared_ptr< YieldTermStructure > r
Predetermined cash flow.
swap-rate indexes
Interest-rate term structure.