37 : refDate_(discountCurve->referenceDate()) {
41 (floatIdx + 1 < iborLeg.size()) &&
42 (
refDate_ > (ext::dynamic_pointer_cast<Coupon>(iborLeg[floatIdx]))->accrualStartDate()))
44 if (
refDate_ <= (ext::dynamic_pointer_cast<Coupon>(iborLeg[floatIdx]))
45 ->accrualStartDate()) {
46 ext::shared_ptr<Coupon> firstFloatCoupon =
47 ext::dynamic_pointer_cast<Coupon>(iborLeg[floatIdx]);
49 firstFloatCoupon->nominal(), firstFloatCoupon->accrualStartDate())));
51 for (
Size k = floatIdx; k < iborLeg.size(); ++k) {
52 ext::shared_ptr<Coupon> coupon = ext::dynamic_pointer_cast<Coupon>(iborLeg[k]);
54 QL_FAIL(
"FloatingLeg CashFlow is no Coupon.");
55 Date startDate = coupon->accrualStartDate();
56 Date endDate = coupon->accrualEndDate();
57 Rate liborForwardRate = coupon->rate();
58 Rate discForwardRate =
59 (discountCurve->discount(startDate) / discountCurve->discount(endDate) - 1.0) /
60 coupon->accrualPeriod();
63 if (contTenorSpread) {
66 spread = ((1.0 + coupon->accrualPeriod() * liborForwardRate) /
67 (1.0 + coupon->accrualPeriod() * discForwardRate) -
69 coupon->accrualPeriod();
73 spread = liborForwardRate - discForwardRate;
74 payDate = coupon->date();
77 payDate, coupon->nominal(), spread, coupon->dayCounter(), startDate, endDate)));
80 ext::shared_ptr<Coupon> lastFloatCoupon =
81 ext::dynamic_pointer_cast<Coupon>(iborLeg.back());
83 -1.0 * lastFloatCoupon->nominal(), lastFloatCoupon->accrualEndDate())));
101 if (ext::dynamic_pointer_cast<Coupon>(k)->accrualStartDate() >=
refDate_)
111 ext::shared_ptr<Coupon> coupon = ext::dynamic_pointer_cast<Coupon>(k);
112 if (coupon !=
nullptr)
113 annuityWeights_.push_back(coupon->nominal() * coupon->accrualPeriod());
121 bool contTenorSpread)
122 :
SwapCashFlows(swaption->underlying(), discountCurve, contTenorSpread),
123 swaption_(swaption) {
127 for (
Size k = 0; k <
swaption_->exercise()->dates().size(); ++k)
Actual/365 (Fixed) day count convention.
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Coupon paying a fixed interest rate
Shared handle to an observable.
std::vector< Real > floatTimes_
IborLegCashFlows()=default
std::vector< Real > floatWeights_
std::vector< Real > annuityWeights_
std::vector< Real > fixedTimes_
const Leg & fixedLeg() const
std::vector< Real > fixedWeights_
ext::shared_ptr< Swaption > swaption_
SwaptionCashFlows()=default
std::vector< Real > exerciseTimes_
Coupon accruing over a fixed period.
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Option exercise classes and payoff function.
Coupon paying a fixed annual rate.
std::size_t Size
size of a container
void swap(Array &v, Array &w) noexcept
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
global repository for run-time library settings
translate swaption into deterministic fixed and float cash flows