/src/quantlib/ql/experimental/termstructures/basisswapratehelpers.hpp
Line | Count | Source (jump to first uncovered line) |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2021 StatPro Italia srl |
5 | | |
6 | | This file is part of QuantLib, a free-software/open-source library |
7 | | for financial quantitative analysts and developers - http://quantlib.org/ |
8 | | |
9 | | QuantLib is free software: you can redistribute it and/or modify it |
10 | | under the terms of the QuantLib license. You should have received a |
11 | | copy of the license along with this program; if not, please email |
12 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
13 | | <http://quantlib.org/license.shtml>. |
14 | | |
15 | | This program is distributed in the hope that it will be useful, but WITHOUT |
16 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
17 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
18 | | */ |
19 | | |
20 | | /*! \file basisswapratehelpers.hpp |
21 | | \brief ibor-ibor and ois-ibor basis swap rate helpers |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_basisswapratehelpers_hpp |
25 | | #define quantlib_basisswapratehelpers_hpp |
26 | | |
27 | | #include <ql/termstructures/yield/ratehelpers.hpp> |
28 | | |
29 | | namespace QuantLib { |
30 | | |
31 | | //! Rate helper for bootstrapping over ibor-ibor basis swaps |
32 | | /*! The swap is assumed to pay baseIndex + basis and receive |
33 | | otherIndex. The helper can be used to bootstrap the forecast |
34 | | curve for baseIndex (in which case you'll have to pass |
35 | | bootstrapBaseCurve = true and provide otherIndex with a |
36 | | forecast curve) or the forecast curve for otherIndex (in which |
37 | | case bootstrapBaseCurve = false and baseIndex will need a |
38 | | forecast curve). |
39 | | In both cases, an exogenous discount curve is required. |
40 | | */ |
41 | | class IborIborBasisSwapRateHelper : public RelativeDateRateHelper { |
42 | | public: |
43 | | IborIborBasisSwapRateHelper(const Handle<Quote>& basis, |
44 | | const Period& tenor, |
45 | | Natural settlementDays, |
46 | | Calendar calendar, |
47 | | BusinessDayConvention convention, |
48 | | bool endOfMonth, |
49 | | const ext::shared_ptr<IborIndex>& baseIndex, |
50 | | const ext::shared_ptr<IborIndex>& otherIndex, |
51 | | Handle<YieldTermStructure> discountHandle, |
52 | | bool bootstrapBaseCurve); |
53 | | |
54 | | Real impliedQuote() const override; |
55 | | void accept(AcyclicVisitor&) override; |
56 | | // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
57 | 0 | ext::shared_ptr<Swap> swap() const { return swap_; } |
58 | | private: |
59 | | void initializeDates() override; |
60 | | void setTermStructure(YieldTermStructure*) override; |
61 | | |
62 | | Period tenor_; |
63 | | Natural settlementDays_; |
64 | | Calendar calendar_; |
65 | | BusinessDayConvention convention_; |
66 | | bool endOfMonth_; |
67 | | ext::shared_ptr<IborIndex> baseIndex_; |
68 | | ext::shared_ptr<IborIndex> otherIndex_; |
69 | | Handle<YieldTermStructure> discountHandle_; |
70 | | bool bootstrapBaseCurve_; |
71 | | |
72 | | ext::shared_ptr<Swap> swap_; |
73 | | |
74 | | RelinkableHandle<YieldTermStructure> termStructureHandle_; |
75 | | }; |
76 | | |
77 | | |
78 | | //! Rate helper for bootstrapping over overnight-ibor basis swaps |
79 | | /*! The swap is assumed to pay baseIndex + basis and receive |
80 | | otherIndex. This helper can be used to bootstrap the forecast |
81 | | curve for otherIndex; baseIndex will need an existing forecast |
82 | | curve. An exogenous discount curve can be passed; if not, |
83 | | the overnight-index curve will be used. |
84 | | */ |
85 | | class OvernightIborBasisSwapRateHelper : public RelativeDateRateHelper { |
86 | | public: |
87 | | OvernightIborBasisSwapRateHelper(const Handle<Quote>& basis, |
88 | | const Period& tenor, |
89 | | Natural settlementDays, |
90 | | Calendar calendar, |
91 | | BusinessDayConvention convention, |
92 | | bool endOfMonth, |
93 | | const ext::shared_ptr<OvernightIndex>& baseIndex, |
94 | | const ext::shared_ptr<IborIndex>& otherIndex, |
95 | | Handle<YieldTermStructure> discountHandle = Handle<YieldTermStructure>()); |
96 | | |
97 | | Real impliedQuote() const override; |
98 | | void accept(AcyclicVisitor&) override; |
99 | | // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap) |
100 | 0 | ext::shared_ptr<Swap> swap() const { return swap_; } |
101 | | private: |
102 | | void initializeDates() override; |
103 | | void setTermStructure(YieldTermStructure*) override; |
104 | | |
105 | | Period tenor_; |
106 | | Natural settlementDays_; |
107 | | Calendar calendar_; |
108 | | BusinessDayConvention convention_; |
109 | | bool endOfMonth_; |
110 | | ext::shared_ptr<OvernightIndex> baseIndex_; |
111 | | ext::shared_ptr<IborIndex> otherIndex_; |
112 | | Handle<YieldTermStructure> discountHandle_; |
113 | | |
114 | | ext::shared_ptr<Swap> swap_; |
115 | | |
116 | | RelinkableHandle<YieldTermStructure> termStructureHandle_; |
117 | | }; |
118 | | |
119 | | } |
120 | | |
121 | | #endif |