QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
subperiodcoupon.hpp
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) 2008 Toyin Akin
5 Copyright (C) 2021 Marcin Rybacki
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21/*! \file subperiodcoupon.hpp
22 \brief averaging coupons
23*/
24
25#ifndef quantlib_sub_period_coupon_hpp
26#define quantlib_sub_period_coupon_hpp
27
31#include <ql/time/schedule.hpp>
32#include <vector>
33
34namespace QuantLib {
35
36 class IborIndex;
37
38 //! sub-periods coupon
39 /*! %Coupon paying the interest, depending on the averaging convention,
40 due to possible multiple fixing resets in one accrual period.
41 */
43 public:
44 // The index object passed in has a tenor significantly less than the
45 // start/end dates.
46 // Thus endDate-startDate may equal 3M
47 // The Tenor used within the index object should be 1M for
48 // averaging/compounding across three coupons within the
49 // coupon period.
50 SubPeriodsCoupon(const Date& paymentDate,
52 const Date& startDate,
53 const Date& endDate,
55 const ext::shared_ptr<IborIndex>& index,
56 Real gearing = 1.0,
57 Rate couponSpread = 0.0, // Spread added to the computed
58 // averaging/compounding rate.
59 Rate rateSpread = 0.0, // Spread to be added onto each
60 // fixing within the
61 // averaging/compounding calculation
62 const Date& refPeriodStart = Date(),
63 const Date& refPeriodEnd = Date(),
65 const Date& exCouponDate = Date());
66
67 //! \name Inspectors
68 //@{
69 //! fixing dates for the rates to be compounded
70 const std::vector<Date>& fixingDates() const { return fixingDates_; }
71 //! accrual (compounding) periods
72 const std::vector<Time>& dt() const { return dt_; }
73 //! value dates for the rates to be compounded
74 const std::vector<Date>& valueDates() const { return valueDates_; }
75 //! rate spread
76 Spread rateSpread() const { return rateSpread_; }
77 //@}
78 //! \name FloatingRateCoupon interface
79 //@{
80 //! the date when the coupon is fully determined
81 Date fixingDate() const override { return fixingDates_.back(); }
82 //@}
83 //! \name Visitability
84 //@{
85 void accept(AcyclicVisitor&) override;
86 //@}
87 private:
88 Date fixingDate(const Date& valueDate) const;
89
90 std::vector<Date> valueDates_, fixingDates_;
92 std::vector<Time> dt_;
94 };
95
97 public:
98 Rate swapletPrice() const override;
99 Real capletPrice(Rate effectiveCap) const override;
100 Rate capletRate(Rate effectiveCap) const override;
101 Real floorletPrice(Rate effectiveFloor) const override;
102 Rate floorletRate(Rate effectiveFloor) const override;
103 void initialize(const FloatingRateCoupon& coupon) override;
104
105 protected:
107 std::vector<Real> subPeriodFixings_;
108 };
109
111 public:
112 Real swapletRate() const override;
113 };
114
116 public:
117 Real swapletRate() const override;
118 };
119
120 //! helper class building a sequence of overnight coupons
122 public:
123 SubPeriodsLeg(Schedule schedule, ext::shared_ptr<IborIndex> index);
125 SubPeriodsLeg& withNotionals(const std::vector<Real>& notionals);
131 SubPeriodsLeg& withFixingDays(const std::vector<Natural>& fixingDays);
133 SubPeriodsLeg& withGearings(const std::vector<Real>& gearings);
135 SubPeriodsLeg& withCouponSpreads(const std::vector<Spread>& spreads);
137 SubPeriodsLeg& withRateSpreads(const std::vector<Spread>& spreads);
139 const Calendar&,
141 bool endOfMonth = false);
143 operator Leg() const;
144
145 private:
147 ext::shared_ptr<IborIndex> index_;
148 std::vector<Real> notionals_;
153 std::vector<Natural> fixingDays_;
154 std::vector<Real> gearings_;
155 std::vector<Spread> couponSpreads_;
156 std::vector<Spread> rateSpreads_;
162 };
163}
164
165#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Real swapletRate() const override
calendar class
Definition: calendar.hpp:61
Real swapletRate() const override
Date exCouponDate() const override
returns the date that the cash flow trades exCoupon
Definition: coupon.hpp:57
virtual Real nominal() const
Definition: coupon.hpp:100
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base floating-rate coupon class
Natural fixingDays() const
fixing days
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
DayCounter dayCounter() const override
day counter for accrual calculation
const ext::shared_ptr< InterestRateIndex > & index() const
floating index
generic pricer for floating-rate coupons
Payment schedule.
Definition: schedule.hpp:40
std::vector< Date > fixingDates_
Spread rateSpread() const
rate spread
const std::vector< Date > & valueDates() const
value dates for the rates to be compounded
void accept(AcyclicVisitor &) override
std::vector< Date > valueDates_
const std::vector< Time > & dt() const
accrual (compounding) periods
const std::vector< Date > & fixingDates() const
fixing dates for the rates to be compounded
Date fixingDate() const override
the date when the coupon is fully determined
helper class building a sequence of overnight coupons
SubPeriodsLeg & withAveragingMethod(RateAveraging::Type averagingMethod)
SubPeriodsLeg & withExCouponPeriod(const Period &, const Calendar &, BusinessDayConvention, bool endOfMonth=false)
BusinessDayConvention paymentAdjustment_
BusinessDayConvention exCouponAdjustment_
std::vector< Spread > couponSpreads_
SubPeriodsLeg & withPaymentLag(Integer lag)
SubPeriodsLeg & withNotionals(Real notional)
std::vector< Real > notionals_
RateAveraging::Type averagingMethod_
SubPeriodsLeg & withRateSpreads(Spread spread)
std::vector< Natural > fixingDays_
std::vector< Spread > rateSpreads_
SubPeriodsLeg & withCouponSpreads(Spread spread)
SubPeriodsLeg & withGearings(Real gearing)
SubPeriodsLeg & withFixingDays(Natural fixingDays)
SubPeriodsLeg & withPaymentAdjustment(BusinessDayConvention)
SubPeriodsLeg & withPaymentDayCounter(const DayCounter &)
std::vector< Real > gearings_
SubPeriodsLeg & withPaymentCalendar(const Calendar &)
ext::shared_ptr< IborIndex > index_
Real capletPrice(Rate effectiveCap) const override
Rate floorletRate(Rate effectiveFloor) const override
std::vector< Real > subPeriodFixings_
const SubPeriodsCoupon * coupon_
void initialize(const FloatingRateCoupon &coupon) override
Real floorletPrice(Rate effectiveFloor) const override
Rate swapletPrice() const override
Rate capletRate(Rate effectiveCap) const override
Coupon pricers.
Coupon paying a variable index-based rate.
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Real Spread
spreads on interest rates
Definition: types.hpp:74
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
rate-averaging method
date schedule