QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
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
34#include <ql/time/schedule.hpp>
35
36namespace QuantLib {
37
38 //! overnight coupon
39 /*! %Coupon paying the interest, depending on the averaging convention,
40 due to daily overnight fixings.
41
42 \warning telescopicValueDates optimizes the schedule for calculation speed,
43 but might fail to produce correct results if the coupon ages by more than
44 a grace period of 7 days. It is therefore recommended not to set this flag
45 to true unless you know exactly what you are doing. The intended use is
46 rather by the OISRateHelper which is safe, since it reinitialises the
47 instrument each time the evaluation date changes.
48 */
50 public:
52 const Date& paymentDate,
54 const Date& startDate,
55 const Date& endDate,
56 const ext::shared_ptr<OvernightIndex>& overnightIndex,
57 Real gearing = 1.0,
58 Spread spread = 0.0,
59 const Date& refPeriodStart = Date(),
60 const Date& refPeriodEnd = Date(),
62 bool telescopicValueDates = false,
64 //! \name Inspectors
65 //@{
66 //! fixing dates for the rates to be compounded
67 const std::vector<Date>& fixingDates() const { return fixingDates_; }
68 //! accrual (compounding) periods
69 const std::vector<Time>& dt() const { return dt_; }
70 //! fixings to be compounded
71 const std::vector<Rate>& indexFixings() const;
72 //! value dates for the rates to be compounded
73 const std::vector<Date>& valueDates() const { return valueDates_; }
74 //! averaging method
76 //@}
77 //! \name FloatingRateCoupon interface
78 //@{
79 //! the date when the coupon is fully determined
80 Date fixingDate() const override { return fixingDates_.back(); }
81 Real accruedAmount(const Date&) const override;
82 //@}
83 //! \name Visitability
84 //@{
85 void accept(AcyclicVisitor&) override;
86 //@}
87 private:
88 std::vector<Date> valueDates_, fixingDates_;
89 mutable std::vector<Rate> fixings_;
91 std::vector<Time> dt_;
93
94 Rate averageRate(const Date& date) const;
95 };
96
97
98 //! helper class building a sequence of overnight coupons
100 public:
101 OvernightLeg(Schedule schedule, ext::shared_ptr<OvernightIndex> overnightIndex);
103 OvernightLeg& withNotionals(const std::vector<Real>& notionals);
109 OvernightLeg& withGearings(const std::vector<Real>& gearings);
111 OvernightLeg& withSpreads(const std::vector<Spread>& spreads);
112 OvernightLeg& withTelescopicValueDates(bool telescopicValueDates);
114 operator Leg() const;
115 private:
117 ext::shared_ptr<OvernightIndex> overnightIndex_;
118 std::vector<Real> notionals_;
123 std::vector<Real> gearings_;
124 std::vector<Spread> spreads_;
127 };
128
129}
130
131#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
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
const RateAveraging::Type averagingMethod() const
averaging method
const std::vector< Date > & valueDates() const
value dates for the rates to be compounded
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
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 & 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 & withSpreads(Spread spread)
OvernightLeg & withPaymentLag(Integer lag)
Payment schedule.
Definition: schedule.hpp:40
Coupon paying a variable index-based rate.
BusinessDayConvention
Business Day conventions.
QL_REAL Real
real number
Definition: types.hpp:50
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:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
rate-averaging method
date schedule