QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
iborindex.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2008, 2009 StatPro Italia srl
6 Copyright (C) 2009 Ferdinando Ametrano
7
8 This file is part of QuantLib, a free-software/open-source library
9 for financial quantitative analysts and developers - http://quantlib.org/
10
11 QuantLib is free software: you can redistribute it and/or modify it
12 under the terms of the QuantLib license. You should have received a
13 copy of the license along with this program; if not, please email
14 <quantlib-dev@lists.sf.net>. The license is also available online at
15 <http://quantlib.org/license.shtml>.
16
17 This program is distributed in the hope that it will be useful, but WITHOUT
18 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19 FOR A PARTICULAR PURPOSE. See the license for more details.
20*/
21
26#ifndef quantlib_ibor_index_hpp
27#define quantlib_ibor_index_hpp
28
29#include <ql/indexes/interestrateindex.hpp>
30#include <ql/termstructures/yieldtermstructure.hpp>
31
32namespace QuantLib {
33
36 public:
37 IborIndex(const std::string& familyName,
38 const Period& tenor,
39 Natural settlementDays,
40 const Currency& currency,
42 BusinessDayConvention convention,
43 bool endOfMonth,
47
48 Date maturityDate(const Date& valueDate) const override;
49 Rate forecastFixing(const Date& fixingDate) const override;
50 // @}
52
54 bool endOfMonth() const { return endOfMonth_; }
58
60
61 virtual ext::shared_ptr<IborIndex> clone(
62 const Handle<YieldTermStructure>& forwarding) const;
63 // @}
64 protected:
68 private:
69 // overload to avoid date/time (re)calculation
70 /* This can be called with cached coupon dates (and it does
71 give quite a performance boost to coupon calculations) but
72 is potentially misleading: by passing the wrong dates, one
73 can ask a 6-months index for a 1-year fixing.
74
75 For that reason, we're leaving this method private and
76 we're declaring the IborCoupon class (which uses it) as a
77 friend. Should the need arise, we might promote it to
78 public, but before doing that I'd think hard whether we
79 have any other way to get the same results.
80 */
82 const Date& endDate,
83 Time t) const;
84 friend class IborCoupon;
85 };
86
87
88 class OvernightIndex : public IborIndex {
89 public:
90 OvernightIndex(const std::string& familyName,
91 Natural settlementDays,
92 const Currency& currency,
95 const Handle<YieldTermStructure>& h = {});
97 ext::shared_ptr<IborIndex> clone(const Handle<YieldTermStructure>& h) const override;
98 };
99
100
101 // inline
102
104 return convention_;
105 }
106
109 return termStructure_;
110 }
111
113 const Date& d2,
114 Time t) const {
115 QL_REQUIRE(!termStructure_.empty(),
116 "null term structure set to this instance of " << name());
117 DiscountFactor disc1 = termStructure_->discount(d1);
118 DiscountFactor disc2 = termStructure_->discount(d2);
119 return (disc1/disc2 - 1.0) / t;
120 }
121
122}
123
124#endif
calendar class
Definition: calendar.hpp:61
Currency specification
Definition: currency.hpp:36
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
Shared handle to an observable.
Definition: handle.hpp:41
Coupon paying a Libor-type index
Definition: iborcoupon.hpp:41
base class for Inter-Bank-Offered-Rate indexes (e.g. Libor, etc.)
Definition: iborindex.hpp:35
Handle< YieldTermStructure > forwardingTermStructure() const
the curve used to forecast fixings
Definition: iborindex.hpp:108
Date maturityDate(const Date &valueDate) const override
Definition: iborindex.cpp:54
bool endOfMonth() const
Definition: iborindex.hpp:54
BusinessDayConvention convention_
Definition: iborindex.hpp:65
virtual ext::shared_ptr< IborIndex > clone(const Handle< YieldTermStructure > &forwarding) const
returns a copy of itself linked to a different forwarding curve
Definition: iborindex.cpp:61
Handle< YieldTermStructure > termStructure_
Definition: iborindex.hpp:66
BusinessDayConvention businessDayConvention() const
Definition: iborindex.hpp:103
Rate forecastFixing(const Date &fixingDate) const override
It can be overridden to implement particular conventions.
Definition: iborindex.cpp:42
base class for interest rate indexes
const DayCounter & dayCounter() const
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
const Currency & currency() const
std::string name() const override
Returns the name of the index.
virtual Date valueDate(const Date &fixingDate) const
Date fixingDate(const Date &valueDate) const
std::string familyName() const
ext::shared_ptr< IborIndex > clone(const Handle< YieldTermStructure > &h) const override
returns a copy of itself linked to a different forwarding curve
Definition: iborindex.cpp:85
BusinessDayConvention
Business Day conventions.
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35