QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
overnightindexedcoupon.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) 2009 Roland Lichters
5 Copyright (C) 2009 Ferdinando Ametrano
6 Copyright (C) 2014 Peter Caspers
7 Copyright (C) 2017 Joseph Jeisman
8 Copyright (C) 2017 Fabrice Lecuyer
9
10 This file is part of QuantLib, a free-software/open-source library
11 for financial quantitative analysts and developers - http://quantlib.org/
12
13 QuantLib is free software: you can redistribute it and/or modify it
14 under the terms of the QuantLib license. You should have received a
15 copy of the license along with this program; if not, please email
16 <quantlib-dev@lists.sf.net>. The license is also available online at
17 <http://quantlib.org/license.shtml>.
18
19 This program is distributed in the hope that it will be useful, but WITHOUT
20 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21 FOR A PARTICULAR PURPOSE. See the license for more details.
22*/
23
24/*! \file overnightindexedcoupon.hpp
25 \brief coupon paying the compounded daily overnight rate
26*/
27
28#ifndef quantlib_overnight_indexed_coupon_hpp
29#define quantlib_overnight_indexed_coupon_hpp
30
35#include <ql/time/schedule.hpp>
36
37namespace QuantLib {
38
39 //! overnight coupon
40 /*! %Coupon paying the interest, depending on the averaging convention,
41 due to daily overnight fixings.
42
43 \warning telescopicValueDates optimizes the schedule for calculation speed,
44 but might fail to produce correct results if the coupon ages by more than
45 a grace period of 7 days. It is therefore recommended not to set this flag
46 to true unless you know exactly what you are doing. The intended use is
47 rather by the OISRateHelper which is safe, since it reinitialises the
48 instrument each time the evaluation date changes.
49 */
51 public:
53 const Date& paymentDate,
55 const Date& startDate,
56 const Date& endDate,
57 const ext::shared_ptr<OvernightIndex>& overnightIndex,
58 Real gearing = 1.0,
59 Spread spread = 0.0,
60 const Date& refPeriodStart = Date(),
61 const Date& refPeriodEnd = Date(),
63 bool telescopicValueDates = false,
65 Natural lookbackDays = Null<Natural>(),
67 bool applyObservationShift = false);
68 //! \name Inspectors
69 //@{
70 //! fixing dates for the rates to be compounded
71 const std::vector<Date>& fixingDates() const { return fixingDates_; }
72 //! accrual (compounding) periods
73 const std::vector<Time>& dt() const { return dt_; }
74 //! fixings to be compounded
75 const std::vector<Rate>& indexFixings() const;
76 //! value dates for the rates to be compounded
77 const std::vector<Date>& valueDates() const { return valueDates_; }
78 //! interest dates for the rates to be compounded
79 const std::vector<Date>& interestDates() const { return interestDates_; }
80 //! averaging method
82 //! lockout days
83 Natural lockoutDays() const { return lockoutDays_; }
84 //! apply observation shift
86 //@}
87 //! \name FloatingRateCoupon interface
88 //@{
89 //! the date when the coupon is fully determined
90 Date fixingDate() const override { return fixingDates_.back(); }
91 Real accruedAmount(const Date&) const override;
92 //@}
93 //! \name Visitability
94 //@{
95 void accept(AcyclicVisitor&) override;
96 //@}
97 //! \name Telescopic property
98 //! Telescopic formula cannot be used with lookback days
99 //! being different than intrinsic index fixing delay.
100 //! Only when index fixing delay is 0 and observation shift is used,
101 //! we can apply telescopic formula, when applying lookback period.
102 //@{
104 return fixingDays_ == index_->fixingDays() ||
105 (applyObservationShift_ && index_->fixingDays() == 0);
106 }
107 //@}
108 private:
110 mutable std::vector<Rate> fixings_;
112 std::vector<Time> dt_;
116
117 Rate averageRate(const Date& date) const;
118 };
119
120 //! helper class building a sequence of overnight coupons
122 public:
123 OvernightLeg(Schedule schedule, ext::shared_ptr<OvernightIndex> overnightIndex);
125 OvernightLeg& withNotionals(const std::vector<Real>& notionals);
131 OvernightLeg& withGearings(const std::vector<Real>& gearings);
133 OvernightLeg& withSpreads(const std::vector<Spread>& spreads);
134 OvernightLeg& withTelescopicValueDates(bool telescopicValueDates);
138 OvernightLeg& withObservationShift(bool applyObservationShift = true);
139 operator Leg() const;
140 private:
142 ext::shared_ptr<OvernightIndex> overnightIndex_;
143 std::vector<Real> notionals_;
148 std::vector<Real> gearings_;
149 std::vector<Spread> spreads_;
155 };
156
157}
158
159#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
calendar class
Definition: calendar.hpp:61
virtual Real nominal() const
Definition: coupon.hpp:100
Date date() const override
Definition: coupon.hpp:53
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
base floating-rate coupon class
ext::shared_ptr< InterestRateIndex > index_
Real gearing() const
index gearing, i.e. multiplicative coefficient for the index
DayCounter dayCounter() const override
day counter for accrual calculation
Spread spread() const
spread paid over the fixing of the underlying index
template class providing a null value for a given type.
Definition: null.hpp:59
const std::vector< Date > & valueDates() const
value dates for the rates to be compounded
const std::vector< Date > & interestDates() const
interest dates for the rates to be compounded
Natural lockoutDays() const
lockout days
bool applyObservationShift() const
apply observation shift
const std::vector< Rate > & indexFixings() const
fixings to be compounded
void accept(AcyclicVisitor &) override
Real accruedAmount(const Date &) const override
accrued amount at the given date
const std::vector< Time > & dt() const
accrual (compounding) periods
const std::vector< Date > & fixingDates() const
fixing dates for the rates to be compounded
RateAveraging::Type averagingMethod() const
averaging method
Date fixingDate() const override
the date when the coupon is fully determined
Rate averageRate(const Date &date) const
helper class building a sequence of overnight coupons
ext::shared_ptr< OvernightIndex > overnightIndex_
BusinessDayConvention paymentAdjustment_
OvernightLeg & withObservationShift(bool applyObservationShift=true)
OvernightLeg & withGearings(Real gearing)
OvernightLeg & withPaymentCalendar(const Calendar &)
OvernightLeg & withTelescopicValueDates(bool telescopicValueDates)
OvernightLeg & withPaymentAdjustment(BusinessDayConvention)
std::vector< Spread > spreads_
OvernightLeg & withNotionals(Real notional)
RateAveraging::Type averagingMethod_
OvernightLeg & withAveragingMethod(RateAveraging::Type averagingMethod)
OvernightLeg & withPaymentDayCounter(const DayCounter &)
OvernightLeg & withLockoutDays(Natural lockoutDays)
OvernightLeg & withSpreads(Spread spread)
OvernightLeg & withPaymentLag(Integer lag)
OvernightLeg & withLookbackDays(Natural lookbackDays)
Payment schedule.
Definition: schedule.hpp:40
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
base class for Inter-Bank-Offered-Rate indexes
Definition: any.hpp:37
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
rate-averaging method
date schedule