File: oisratehelper.hpp

package info (click to toggle)
quantlib 1.41-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 41,480 kB
  • sloc: cpp: 400,885; makefile: 6,547; python: 214; sh: 150; lisp: 86
file content (176 lines) | stat: -rw-r--r-- 7,612 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */

/*
 Copyright (C) 2009, 2012 Roland Lichters
 Copyright (C) 2009, 2012 Ferdinando Ametrano

 This file is part of QuantLib, a free-software/open-source library
 for financial quantitative analysts and developers - http://quantlib.org/

 QuantLib is free software: you can redistribute it and/or modify it
 under the terms of the QuantLib license.  You should have received a
 copy of the license along with this program; if not, please email
 <quantlib-dev@lists.sf.net>. The license is also available online at
 <https://www.quantlib.org/license.shtml>.

 This program is distributed in the hope that it will be useful, but WITHOUT
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
 FOR A PARTICULAR PURPOSE.  See the license for more details.
*/

/*! \file oisratehelper.hpp
    \brief Overnight Indexed Swap (aka OIS) rate helpers
*/

#ifndef quantlib_oisratehelper_hpp
#define quantlib_oisratehelper_hpp

#include <ql/termstructures/yield/ratehelpers.hpp>
#include <ql/instruments/overnightindexedswap.hpp>
#include <ql/optional.hpp>
#include <variant>

namespace QuantLib {

    class FloatingRateCouponPricer;

    //! Rate helper for bootstrapping over Overnight Indexed Swap rates
    class OISRateHelper : public RelativeDateRateHelper {
      public:
        OISRateHelper(
          Natural settlementDays,
          const Period& tenor, // swap maturity
          const std::variant<Rate, Handle<Quote>>& fixedRate,
          const ext::shared_ptr<OvernightIndex>& overnightIndex,
          // exogenous discounting curve
          Handle<YieldTermStructure> discountingCurve = {},
          bool telescopicValueDates = false,
          Integer paymentLag = 0,
          BusinessDayConvention paymentConvention = Following,
          Frequency paymentFrequency = Annual,
          Calendar paymentCalendar = Calendar(),
          const Period& forwardStart = 0 * Days,
          const std::variant<Spread, Handle<Quote>>& overnightSpread = Spread(0.0),
          Pillar::Choice pillar = Pillar::LastRelevantDate,
          Date customPillarDate = Date(),
          RateAveraging::Type averagingMethod = RateAveraging::Compound,
          ext::optional<bool> endOfMonth = ext::nullopt,
          ext::optional<Frequency> fixedPaymentFrequency = ext::nullopt,
          Calendar fixedCalendar = Calendar(),
          Natural lookbackDays = Null<Natural>(),
          Natural lockoutDays = 0,
          bool applyObservationShift = false,
          ext::shared_ptr<FloatingRateCouponPricer> pricer = {},
          DateGeneration::Rule rule = DateGeneration::Backward,
          Calendar overnightCalendar = Calendar(),
          BusinessDayConvention convention = ModifiedFollowing);

        OISRateHelper(
          const Date& startDate,
          const Date& endDate,
          const std::variant<Rate, Handle<Quote>>& fixedRate,
          const ext::shared_ptr<OvernightIndex>& overnightIndex,
          // exogenous discounting curve
          Handle<YieldTermStructure> discountingCurve = {},
          bool telescopicValueDates = false,
          Integer paymentLag = 0,
          BusinessDayConvention paymentConvention = Following,
          Frequency paymentFrequency = Annual,
          Calendar paymentCalendar = Calendar(),
          const std::variant<Spread, Handle<Quote>>& overnightSpread = Spread(0.0),
          Pillar::Choice pillar = Pillar::LastRelevantDate,
          Date customPillarDate = Date(),
          RateAveraging::Type averagingMethod = RateAveraging::Compound,
          ext::optional<bool> endOfMonth = ext::nullopt,
          ext::optional<Frequency> fixedPaymentFrequency = ext::nullopt,
          Calendar fixedCalendar = Calendar(),
          Natural lookbackDays = Null<Natural>(),
          Natural lockoutDays = 0,
          bool applyObservationShift = false,
          ext::shared_ptr<FloatingRateCouponPricer> pricer = {},
          DateGeneration::Rule rule = DateGeneration::Backward,
          Calendar overnightCalendar = Calendar(),
          BusinessDayConvention convention = ModifiedFollowing);

        //! \name RateHelper interface
        //@{
        Real impliedQuote() const override;
        void setTermStructure(YieldTermStructure*) override;
        //@}
        //! \name inspectors
        //@{
        // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
        ext::shared_ptr<OvernightIndexedSwap> swap() const { return swap_; }
        //@}
        //! \name Visitability
        //@{
        void accept(AcyclicVisitor&) override;
        //@}
      protected:
        void initialize(const ext::shared_ptr<OvernightIndex>& overnightIndex,
                        Date customPillarDate);
        void initializeDates() override;

        Natural settlementDays_;
        Period tenor_;
        Date startDate_, endDate_;
        ext::shared_ptr<OvernightIndex> overnightIndex_;

        ext::shared_ptr<OvernightIndexedSwap> swap_;
        RelinkableHandle<YieldTermStructure> termStructureHandle_;

        Handle<YieldTermStructure> discountHandle_;
        bool telescopicValueDates_;
        RelinkableHandle<YieldTermStructure> discountRelinkableHandle_;

        Integer paymentLag_;
        BusinessDayConvention paymentConvention_;
        Frequency paymentFrequency_;
        Calendar paymentCalendar_;
        Period forwardStart_;
        Handle<Quote> overnightSpread_;
        Pillar::Choice pillarChoice_;
        RateAveraging::Type averagingMethod_;
        ext::optional<bool> endOfMonth_;
        ext::optional<Frequency> fixedPaymentFrequency_;
        Calendar fixedCalendar_;
        Calendar overnightCalendar_;
        BusinessDayConvention convention_;
        Natural lookbackDays_;
        Natural lockoutDays_;
        bool applyObservationShift_;
        ext::shared_ptr<FloatingRateCouponPricer> pricer_;
        DateGeneration::Rule rule_ = DateGeneration::Backward;

    };

    /*! \deprecated Use OISRateHelper instead.
                    Deprecated in version 1.37.
    */
    class [[deprecated("Use OISRateHelper instead")]] DatedOISRateHelper : public OISRateHelper {
      public:
        DatedOISRateHelper(const Date& startDate,
                           const Date& endDate,
                           const Handle<Quote>& fixedRate,
                           const ext::shared_ptr<OvernightIndex>& overnightIndex,
                           // exogenous discounting curve
                           Handle<YieldTermStructure> discountingCurve = {},
                           bool telescopicValueDates = false,
                           RateAveraging::Type averagingMethod = RateAveraging::Compound,
                           Integer paymentLag = 0,
                           BusinessDayConvention paymentConvention = Following,
                           Frequency paymentFrequency = Annual,
                           const Calendar& paymentCalendar = Calendar(),
                           Spread overnightSpread = {},
                           ext::optional<bool> endOfMonth = ext::nullopt,
                           ext::optional<Frequency> fixedPaymentFrequency = ext::nullopt,
                           const Calendar& fixedCalendar = Calendar(),
                           Natural lookbackDays = Null<Natural>(),
                           Natural lockoutDays = 0,
                           bool applyObservationShift = false,
                           const ext::shared_ptr<FloatingRateCouponPricer>& pricer = {});
    };

}

#endif