QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
swapindex.hpp
1/*
2 Copyright (C) 2006, 2009 Ferdinando Ametrano
3 Copyright (C) 2006, 2007, 2009 StatPro Italia srl
4
5 This file is part of QuantLib, a free-software/open-source library
6 for financial quantitative analysts and developers - http://quantlib.org/
7
8 QuantLib is free software: you can redistribute it and/or modify it
9 under the terms of the QuantLib license. You should have received a
10 copy of the license along with this program; if not, please email
11 <quantlib-dev@lists.sf.net>. The license is also available online at
12 <http://quantlib.org/license.shtml>.
13
14
15 This program is distributed in the hope that it will be useful, but
16 WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
17 or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */
18
23#ifndef quantlib_swapindex_hpp
24#define quantlib_swapindex_hpp
25
26#include <ql/indexes/interestrateindex.hpp>
27#include <ql/termstructures/yieldtermstructure.hpp>
28#include <ql/cashflows/rateaveraging.hpp>
29
30namespace QuantLib {
31
32 class Schedule;
33
34 class IborIndex;
35 class VanillaSwap;
36
37 class OvernightIndex;
38 class OvernightIndexedSwap;
39
42 public:
43 SwapIndex(const std::string& familyName,
44 const Period& tenor,
45 Natural settlementDays,
46 const Currency& currency,
48 const Period& fixedLegTenor,
50 const DayCounter& fixedLegDayCounter,
51 ext::shared_ptr<IborIndex> iborIndex);
52 SwapIndex(const std::string& familyName,
53 const Period& tenor,
54 Natural settlementDays,
55 const Currency& currency,
57 const Period& fixedLegTenor,
59 const DayCounter& fixedLegDayCounter,
60 ext::shared_ptr<IborIndex> iborIndex,
63
64 Date maturityDate(const Date& valueDate) const override;
66
70 ext::shared_ptr<IborIndex> iborIndex() const { return iborIndex_; }
73 bool exogenousDiscount() const;
77 ext::shared_ptr<VanillaSwap> underlyingSwap(
78 const Date& fixingDate) const;
80
82
83 virtual ext::shared_ptr<SwapIndex> clone(
84 const Handle<YieldTermStructure>& forwarding) const;
86 virtual ext::shared_ptr<SwapIndex> clone(
87 const Handle<YieldTermStructure>& forwarding,
88 const Handle<YieldTermStructure>& discounting) const;
90 virtual ext::shared_ptr<SwapIndex> clone(
91 const Period& tenor) const;
92 // @}
93 protected:
94 Rate forecastFixing(const Date& fixingDate) const override;
96 ext::shared_ptr<IborIndex> iborIndex_;
101 // cache data to avoid swap recreation when the same fixing date
102 // is used multiple time to forecast changing fixing
103 mutable ext::shared_ptr<VanillaSwap> lastSwap_;
105 };
106
107
110 public:
112 const std::string& familyName,
113 const Period& tenor,
114 Natural settlementDays,
115 const Currency& currency,
116 const ext::shared_ptr<OvernightIndex>& overnightIndex,
117 bool telescopicValueDates = false,
120
121 ext::shared_ptr<OvernightIndex> overnightIndex() const;
125 ext::shared_ptr<OvernightIndexedSwap> underlyingSwap(
126 const Date& fixingDate) const;
128 protected:
129 ext::shared_ptr<OvernightIndex> overnightIndex_;
132 // cache data to avoid swap recreation when the same fixing date
133 // is used multiple time to forecast changing fixing
134 mutable ext::shared_ptr<OvernightIndexedSwap> lastSwap_;
136 };
137
138 // inline definitions
139
141 return fixedLegConvention_;
142 }
143
144 inline bool SwapIndex::exogenousDiscount() const {
145 return exogenousDiscount_;
146 }
147
148 inline ext::shared_ptr<OvernightIndex>
150 return overnightIndex_;
151 }
152
153}
154
155#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
base class for interest rate indexes
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
const Currency & currency() const
virtual Date valueDate(const Date &fixingDate) const
Date fixingDate(const Date &valueDate) const
std::string familyName() const
base class for overnight indexed swap indexes
Definition: swapindex.hpp:109
ext::shared_ptr< OvernightIndex > overnightIndex_
Definition: swapindex.hpp:129
ext::shared_ptr< OvernightIndex > overnightIndex() const
Definition: swapindex.hpp:149
ext::shared_ptr< OvernightIndexedSwap > lastSwap_
Definition: swapindex.hpp:134
ext::shared_ptr< OvernightIndexedSwap > underlyingSwap(const Date &fixingDate) const
Definition: swapindex.cpp:202
RateAveraging::Type averagingMethod_
Definition: swapindex.hpp:131
base class for swap-rate indexes
Definition: swapindex.hpp:41
virtual ext::shared_ptr< SwapIndex > clone(const Handle< YieldTermStructure > &forwarding) const
returns a copy of itself linked to a different forwarding curve
Definition: swapindex.cpp:112
Handle< YieldTermStructure > discount_
Definition: swapindex.hpp:100
ext::shared_ptr< VanillaSwap > underlyingSwap(const Date &fixingDate) const
Definition: swapindex.cpp:77
Handle< YieldTermStructure > forwardingTermStructure() const
Definition: swapindex.cpp:64
BusinessDayConvention fixedLegConvention() const
Definition: swapindex.hpp:140
ext::shared_ptr< VanillaSwap > lastSwap_
Definition: swapindex.hpp:103
ext::shared_ptr< IborIndex > iborIndex_
Definition: swapindex.hpp:96
Date maturityDate(const Date &valueDate) const override
Definition: swapindex.cpp:106
BusinessDayConvention fixedLegConvention_
Definition: swapindex.hpp:98
ext::shared_ptr< IborIndex > iborIndex() const
Definition: swapindex.hpp:70
bool exogenousDiscount() const
Definition: swapindex.hpp:144
Period fixedLegTenor() const
Definition: swapindex.hpp:68
Handle< YieldTermStructure > discountingTermStructure() const
Definition: swapindex.cpp:68
Rate forecastFixing(const Date &fixingDate) const override
It can be overridden to implement particular conventions.
Definition: swapindex.cpp:72
BusinessDayConvention
Business Day conventions.
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35