Coverage Report

Created: 2026-09-28 06:23

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/termstructures/yield/oisratehelper.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2009, 2012 Roland Lichters
5
 Copyright (C) 2009, 2012 Ferdinando Ametrano
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <https://www.quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
/*! \file oisratehelper.hpp
22
    \brief Overnight Indexed Swap (aka OIS) rate helpers
23
*/
24
25
#ifndef quantlib_oisratehelper_hpp
26
#define quantlib_oisratehelper_hpp
27
28
#include <ql/termstructures/yield/ratehelpers.hpp>
29
#include <ql/instruments/overnightindexedswap.hpp>
30
#include <ql/optional.hpp>
31
#include <variant>
32
33
namespace QuantLib {
34
35
    class FloatingRateCouponPricer;
36
37
    //! Rate helper for bootstrapping over Overnight Indexed Swap rates
38
    class OISRateHelper : public RelativeDateRateHelper {
39
      public:
40
        OISRateHelper(
41
          Natural settlementDays,
42
          const Period& tenor, // swap maturity
43
          const std::variant<Rate, Handle<Quote>>& fixedRate,
44
          const ext::shared_ptr<OvernightIndex>& overnightIndex,
45
          // exogenous discounting curve
46
          Handle<YieldTermStructure> discountingCurve = {},
47
          bool telescopicValueDates = false,
48
          Integer paymentLag = 0,
49
          BusinessDayConvention paymentConvention = Following,
50
          Frequency paymentFrequency = Annual,
51
          Calendar paymentCalendar = Calendar(),
52
          const Period& forwardStart = 0 * Days,
53
          const std::variant<Spread, Handle<Quote>>& overnightSpread = Spread(0.0),
54
          Pillar::Choice pillar = Pillar::LastRelevantDate,
55
          Date customPillarDate = Date(),
56
          RateAveraging::Type averagingMethod = RateAveraging::Compound,
57
          std::optional<bool> endOfMonth = std::nullopt,
58
          std::optional<Frequency> fixedPaymentFrequency = std::nullopt,
59
          Calendar fixedCalendar = Calendar(),
60
          Natural lookbackDays = Null<Natural>(),
61
          Natural lockoutDays = 0,
62
          bool applyObservationShift = false,
63
          ext::shared_ptr<FloatingRateCouponPricer> pricer = {},
64
          DateGeneration::Rule rule = DateGeneration::Backward,
65
          Calendar overnightCalendar = Calendar(),
66
          BusinessDayConvention convention = ModifiedFollowing,
67
          DayCounter fixedDayCount = DayCounter());
68
69
        OISRateHelper(
70
          const Date& startDate,
71
          const Date& endDate,
72
          const std::variant<Rate, Handle<Quote>>& fixedRate,
73
          const ext::shared_ptr<OvernightIndex>& overnightIndex,
74
          // exogenous discounting curve
75
          Handle<YieldTermStructure> discountingCurve = {},
76
          bool telescopicValueDates = false,
77
          Integer paymentLag = 0,
78
          BusinessDayConvention paymentConvention = Following,
79
          Frequency paymentFrequency = Annual,
80
          Calendar paymentCalendar = Calendar(),
81
          const std::variant<Spread, Handle<Quote>>& overnightSpread = Spread(0.0),
82
          Pillar::Choice pillar = Pillar::LastRelevantDate,
83
          Date customPillarDate = Date(),
84
          RateAveraging::Type averagingMethod = RateAveraging::Compound,
85
          std::optional<bool> endOfMonth = std::nullopt,
86
          std::optional<Frequency> fixedPaymentFrequency = std::nullopt,
87
          Calendar fixedCalendar = Calendar(),
88
          Natural lookbackDays = Null<Natural>(),
89
          Natural lockoutDays = 0,
90
          bool applyObservationShift = false,
91
          ext::shared_ptr<FloatingRateCouponPricer> pricer = {},
92
          DateGeneration::Rule rule = DateGeneration::Backward,
93
          Calendar overnightCalendar = Calendar(),
94
          BusinessDayConvention convention = ModifiedFollowing,
95
          DayCounter fixedDayCount = DayCounter());
96
97
        //! \name RateHelper interface
98
        //@{
99
        Real impliedQuote() const override;
100
        void setTermStructure(YieldTermStructure*) override;
101
        //@}
102
        //! \name inspectors
103
        //@{
104
        // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
105
0
        ext::shared_ptr<OvernightIndexedSwap> swap() const { return swap_; }
106
        //@}
107
        //! \name Visitability
108
        //@{
109
        void accept(AcyclicVisitor&) override;
110
        //@}
111
      protected:
112
        void initialize(const ext::shared_ptr<OvernightIndex>& overnightIndex,
113
                        Date customPillarDate);
114
        void initializeDates() override;
115
116
        Natural settlementDays_;
117
        Period tenor_;
118
        Date startDate_, endDate_;
119
        ext::shared_ptr<OvernightIndex> overnightIndex_;
120
121
        ext::shared_ptr<OvernightIndexedSwap> swap_;
122
        RelinkableHandle<YieldTermStructure> termStructureHandle_;
123
124
        Handle<YieldTermStructure> discountHandle_;
125
        bool telescopicValueDates_;
126
        RelinkableHandle<YieldTermStructure> discountRelinkableHandle_;
127
128
        Integer paymentLag_;
129
        BusinessDayConvention paymentConvention_;
130
        Frequency paymentFrequency_;
131
        Calendar paymentCalendar_;
132
        Period forwardStart_;
133
        Handle<Quote> overnightSpread_;
134
        Pillar::Choice pillarChoice_;
135
        RateAveraging::Type averagingMethod_;
136
        std::optional<bool> endOfMonth_;
137
        std::optional<Frequency> fixedPaymentFrequency_;
138
        Calendar fixedCalendar_;
139
        Calendar overnightCalendar_;
140
        BusinessDayConvention convention_;
141
        DayCounter fixedDayCount_;
142
        Natural lookbackDays_;
143
        Natural lockoutDays_;
144
        bool applyObservationShift_;
145
        ext::shared_ptr<FloatingRateCouponPricer> pricer_;
146
        DateGeneration::Rule rule_ = DateGeneration::Backward;
147
148
    };
149
150
}
151
152
#endif