24#include <ql/cashflows/capflooredcoupon.hpp>
25#include <ql/cashflows/cashflowvectors.hpp>
26#include <ql/cashflows/couponpricer.hpp>
27#include <ql/cashflows/iborcoupon.hpp>
28#include <ql/indexes/interestrateindex.hpp>
29#include <ql/termstructures/yieldtermstructure.hpp>
30#include <ql/optional.hpp>
37 const Date& startDate,
40 const ext::shared_ptr<IborIndex>& iborIndex,
43 const Date& refPeriodStart,
44 const Date& refPeriodEnd,
47 const Date& exCouponDate)
49 fixingDays, iborIndex, gearing, spread,
50 refPeriodStart, refPeriodEnd,
51 dayCounter, isInArrears, exCouponDate),
52 iborIndex_(iborIndex) {
57 auto p = ext::dynamic_pointer_cast<IborCouponPricer>(
pricer_);
58 QL_REQUIRE(p,
"IborCoupon: pricer not set or not derived from IborCouponPricer");
59 p->initializeCachedData(*
this);
146 usingAtParCoupons_ =
false;
150 return usingAtParCoupons_;
155 QL_REQUIRE(
index_,
"no index provided");
199 gearings_ = std::vector<Real>(1,gearing);
209 spreads_ = std::vector<Spread>(1,spread);
219 caps_ = std::vector<Rate>(1,cap);
229 floors_ = std::vector<Rate>(1,floor);
269 IborLeg::operator
Leg()
const {
271 Leg leg = FloatingLeg<IborIndex, IborCoupon, CappedFlooredIborCoupon>(
272 schedule_, notionals_, index_, paymentDayCounter_,
273 paymentAdjustment_, fixingDays_, gearings_, spreads_,
274 caps_, floors_, inArrears_, zeroPayments_, paymentLag_, paymentCalendar_,
275 exCouponPeriod_, exCouponCalendar_, exCouponAdjustment_, exCouponEndOfMonth_);
277 if (caps_.empty() && floors_.empty() && !inArrears_) {
278 ext::shared_ptr<IborCouponPricer> pricer = ext::make_shared<BlackIborCouponPricer>(
281 Handle<Quote>(ext::make_shared<SimpleQuote>(1.0)), useIndexedCoupons_);
degenerate base class for the Acyclic Visitor pattern
base floating-rate coupon class
virtual Date fixingDate() const
fixing date
ext::shared_ptr< InterestRateIndex > index_
virtual void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &)
ext::shared_ptr< FloatingRateCouponPricer > pricer_
void accept(AcyclicVisitor &) override
const ext::shared_ptr< InterestRateIndex > & index() const
floating index
ext::shared_ptr< FloatingRateCouponPricer > pricer() const
Shared handle to an observable.
bool usingAtParCoupons() const
void createIndexedCoupons()
When called, IborCoupons are created as par coupons instead of indexed coupons.
void createAtParCoupons()
When called, IborCoupons are created as indexed coupons instead of par coupons.
void initializeCachedData() const
Time spanningTimeIndexMaturity() const
Period underlying the index fixing, as a year fraction.
Rate indexFixing() const override
fixing of the underlying index
Time spanningTimeIndexMaturity_
ext::shared_ptr< IborIndex > iborIndex_
void accept(AcyclicVisitor &) override
const Date & fixingValueDate() const
Start of the deposit period underlying the index fixing.
void setPricer(const ext::shared_ptr< FloatingRateCouponPricer > &) override
IborCoupon(const Date &paymentDate, Real nominal, const Date &startDate, const Date &endDate, Natural fixingDays, const ext::shared_ptr< IborIndex > &index, Real gearing=1.0, Spread spread=0.0, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date(), const DayCounter &dayCounter=DayCounter(), bool isInArrears=false, const Date &exCouponDate=Date())
bool cachedDataIsInitialized_
const Date & fixingEndDate() const
End of the deposit period underlying the coupon fixing.
const Date & fixingMaturityDate() const
End of the deposit period underlying the index fixing.
Time spanningTime() const
Period underlying the coupon fixing, as a year fraction.
helper class building a sequence of capped/floored ibor-rate coupons
IborLeg & withSpreads(Spread spread)
IborLeg & withPaymentLag(Natural lag)
BusinessDayConvention paymentAdjustment_
std::vector< Rate > caps_
IborLeg & withPaymentCalendar(const Calendar &)
BusinessDayConvention exCouponAdjustment_
IborLeg & withPaymentAdjustment(BusinessDayConvention)
Calendar paymentCalendar_
IborLeg(Schedule schedule, ext::shared_ptr< IborIndex > index)
ext::optional< bool > useIndexedCoupons_
std::vector< Real > notionals_
std::vector< Spread > spreads_
IborLeg & withPaymentDayCounter(const DayCounter &)
IborLeg & inArrears(bool flag=true)
IborLeg & withFloors(Rate floor)
IborLeg & withNotionals(Real notional)
std::vector< Natural > fixingDays_
IborLeg & withGearings(Real gearing)
Calendar exCouponCalendar_
std::vector< Rate > floors_
IborLeg & withZeroPayments(bool flag=true)
IborLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
IborLeg & withCaps(Rate cap)
IborLeg & withIndexedCoupons(ext::optional< bool > b=true)
IborLeg & withFixingDays(Natural fixingDays)
IborLeg & withAtParCoupons(bool b=true)
std::vector< Real > gearings_
DayCounter paymentDayCounter_
ext::shared_ptr< IborIndex > index_
template class providing a null value for a given type.
static Settings & instance()
access to the unique instance
Visitor for a specific class
virtual void visit(T &)=0
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates
void setCouponPricer(const Leg &leg, const ext::shared_ptr< FloatingRateCouponPricer > &pricer)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.