37 ext::shared_ptr<Bond> bond,
41 const ext::shared_ptr<IborIndex>& iborIndex,
46 :
AssetSwap(payBondCoupon,
std::move(bond), bondCleanPrice, iborIndex, spread,
47 Schedule(), floatingDayCounter, parSwap, gearing,
48 nonParRepayment, dealMaturity) {}
51 ext::shared_ptr<Bond> bond,
53 const ext::shared_ptr<IborIndex>& iborIndex,
61 :
Swap(2), bond_(
std::move(bond)), bondCleanPrice_(bondCleanPrice),
62 nonParRepayment_(nonParRepayment), spread_(spread), parSwap_(parSwap) {
64 auto overnight = ext::dynamic_pointer_cast<OvernightIndex>(iborIndex);
67 "floating schedule is needed when using an overnight index");
72 bond_->maturityDate(),
74 iborIndex->fixingCalendar(),
75 iborIndex->businessDayConvention(),
76 iborIndex->businessDayConvention(),
79 : std::move(floatSchedule);
81 if (dealMaturity ==
Date())
82 dealMaturity = schedule.
back();
84 "deal maturity " << dealMaturity <<
85 " cannot be later than (adjusted) bond maturity " <<
88 "deal maturity " << dealMaturity <<
89 " must be later than swap start date " <<
96 dealMaturity, paymentAdjustment);
97 schedule = schedule.
until(finalDate);
109 notional *= dirtyPrice/100.0;
116 bool includeOnUpfrontDate =
false;
120 Leg::const_iterator i;
121 for (i =
bondLeg.begin(); i <
bondLeg.end()-1 && (*i)->date()<=dealMaturity; ++i) {
122 if (!(*i)->hasOccurred(
upfrontDate_, includeOnUpfrontDate))
123 legs_[0].push_back(*i);
129 auto c = ext::dynamic_pointer_cast<Coupon>(*i);
131 Real accruedAmount = c->accruedAmount(dealMaturity);
133 ext::make_shared<SimpleCashFlow>(accruedAmount, finalDate);
134 legs_[0].push_back(accruedCoupon);
140 auto redemption =
bondLeg.back();
142 ext::make_shared<SimpleCashFlow>(redemption->amount(), finalDate);
143 legs_[0].push_back(finalFlow);
148 legs_[0].push_back(finalFlow);
163 IborLeg(std::move(schedule), iborIndex)
173 Real upfront = (dirtyPrice-100.0)/100.0 * notional;
174 auto upfrontCashFlow =
175 ext::make_shared<SimpleCashFlow>(upfront,
upfrontDate_);
176 legs_[1].insert(
legs_[1].begin(), upfrontCashFlow);
178 Real backPayment = notional;
179 auto backPaymentCashFlow =
180 ext::make_shared<SimpleCashFlow>(backPayment, finalDate);
181 legs_[1].push_back(backPaymentCashFlow);
185 ext::make_shared<SimpleCashFlow>(notional, finalDate);
186 legs_[1].push_back(finalCashFlow);
192 for (
const auto& c:
leg)
216 vector<Date>(fixedCoupons.size());
219 for (
Size i=0; i<fixedCoupons.size(); ++i) {
220 ext::shared_ptr<FixedRateCoupon> coupon =
221 ext::dynamic_pointer_cast<FixedRateCoupon>(fixedCoupons[i]);
232 vector<Date>(floatingCoupons.size());
234 vector<Time>(floatingCoupons.size());
236 vector<Spread>(floatingCoupons.size());
238 for (
Size i=0; i<floatingCoupons.size(); ++i) {
239 ext::shared_ptr<FloatingRateCoupon> coupon =
240 ext::dynamic_pointer_cast<FloatingRateCoupon>(floatingCoupons[i]);
251 static const Spread basisPoint = 1.0e-4;
259 QL_FAIL(
"fair spread not available");
266 "floating-leg BPS not available");
273 "floating-leg NPV not available");
283 "fair clean price not available for seasoned deal");
305 "fair non par repayment not available for expired leg");
336 "number of fixed start dates different from "
337 "number of fixed payment dates");
339 "number of fixed payment dates different from "
340 "number of fixed coupon amounts");
342 "number of floating start dates different from "
343 "number of floating payment dates");
345 "number of floating fixing dates different from "
346 "number of floating payment dates");
348 "number of floating accrual times different from "
349 "number of floating payment dates");
351 "number of floating spreads different from "
352 "number of floating payment dates");
Bullet bond vs Libor swap.
Cash flow vector builders.
Arguments for asset swap calculation
std::vector< Date > floatingResetDates
std::vector< Spread > floatingSpreads
std::vector< Date > floatingFixingDates
std::vector< Date > fixedPayDates
std::vector< Date > fixedResetDates
void validate() const override
std::vector< Time > floatingAccrualTimes
std::vector< Real > fixedCoupons
std::vector< Date > floatingPayDates
Results from simple swap calculation
Bullet bond vs Libor swap.
Real fairNonParRepayment_
Real fairCleanPrice() const
const Leg & floatingLeg() const
Spread fairSpread() const
AssetSwap(bool payBondCoupon, ext::shared_ptr< Bond > bond, Real bondCleanPrice, const ext::shared_ptr< IborIndex > &iborIndex, Spread spread, Schedule floatSchedule=Schedule(), const DayCounter &floatingDayCount=DayCounter(), bool parAssetSwap=true, Real gearing=1.0, Real nonParRepayment=Null< Real >(), Date dealMaturity=Date())
Real floatingLegBPS() const
Real fairNonParRepayment() const
void setupArguments(PricingEngine::arguments *args) const override
const Leg & bondLeg() const
ext::shared_ptr< Bond > bond_
void setupExpired() const override
Real floatingLegNPV() const
void fetchResults(const PricingEngine::results *) const override
bool payBondCoupon() const
Date adjust(const Date &, BusinessDayConvention convention=Following) const
helper class building a sequence of capped/floored ibor-rate coupons
IborLeg & withSpreads(Spread spread)
IborLeg & withPaymentAdjustment(BusinessDayConvention)
IborLeg & withPaymentDayCounter(const DayCounter &)
IborLeg & withNotionals(Real notional)
IborLeg & withGearings(Real gearing)
void calculate() const override
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
helper class building a sequence of overnight coupons
OvernightLeg & withGearings(Real gearing)
OvernightLeg & withPaymentAdjustment(BusinessDayConvention)
OvernightLeg & withNotionals(Real notional)
OvernightLeg & withPaymentDayCounter(const DayCounter &)
OvernightLeg & withSpreads(Spread spread)
const Date & front() const
const Calendar & calendar() const
const Date & startDate() const
const Date & back() const
Schedule until(const Date &truncationDate) const
DiscountFactor npvDateDiscount_
void setupArguments(PricingEngine::arguments *) const override
std::vector< Real > legNPV_
const Leg & leg(Size j) const
std::vector< Real > legBPS_
std::vector< DiscountFactor > startDiscounts_
void setupExpired() const override
void fetchResults(const PricingEngine::results *) const override
std::vector< DiscountFactor > endDiscounts_
std::vector< Real > payer_
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Coupon paying a fixed annual rate.
BusinessDayConvention
Business Day conventions.
Real Spread
spreads on interest rates
std::size_t Size
size of a container
Coupon paying a Libor-type index.
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
coupon paying the compounded daily overnight rate
ext::shared_ptr< YieldTermStructure > r