Coverage Report

Created: 2026-10-31 06:47

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/experimental/termstructures/overnightindexedfundingratehelper.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2026 Kyrylo Protsenko
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
 <https://www.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 overnightindexedfundingratehelper.hpp
21
    \brief rate helper for funding margins over compounded overnight rates
22
*/
23
24
#ifndef quantlib_overnight_indexed_funding_rate_helper_hpp
25
#define quantlib_overnight_indexed_funding_rate_helper_hpp
26
27
#include <ql/instruments/swap.hpp>
28
#include <ql/termstructures/yield/ratehelpers.hpp>
29
#include <ql/time/dategenerationrule.hpp>
30
31
namespace QuantLib {
32
33
    class OvernightIndex;
34
35
    //! Rate helper for funding margins over a compounded overnight rate
36
    /*! The underlying instrument exchanges principal at the start and end
37
        and pays the overnight rate plus the quoted margin periodically. All
38
        payments, including the principal exchanges, use the same payment lag.
39
40
        The overnight rate is projected from an exogenous curve. The curve
41
        being bootstrapped discounts all cash flows.
42
    */
43
    class OvernightIndexedFundingRateHelper : public RelativeDateRateHelper {
44
      public:
45
        OvernightIndexedFundingRateHelper(const std::variant<Spread, Handle<Quote>>& margin,
46
                                          const Period& tenor,
47
                                          Natural settlementDays,
48
                                          Calendar calendar,
49
                                          BusinessDayConvention convention,
50
                                          bool endOfMonth,
51
                                          const ext::shared_ptr<OvernightIndex>& overnightIndex,
52
                                          const Period& paymentTenor,
53
                                          DayCounter paymentDayCounter,
54
                                          Integer paymentLag = 0,
55
                                          bool telescopicValueDates = false,
56
                                          DateGeneration::Rule rule = DateGeneration::Backward,
57
                                          Pillar::Choice pillar = Pillar::LastRelevantDate,
58
                                          Date customPillarDate = Date());
59
60
        OvernightIndexedFundingRateHelper(const std::variant<Spread, Handle<Quote>>& margin,
61
                                          const Date& startDate,
62
                                          const Date& endDate,
63
                                          Calendar calendar,
64
                                          BusinessDayConvention convention,
65
                                          bool endOfMonth,
66
                                          const ext::shared_ptr<OvernightIndex>& overnightIndex,
67
                                          const Period& paymentTenor,
68
                                          DayCounter paymentDayCounter,
69
                                          Integer paymentLag = 0,
70
                                          bool telescopicValueDates = false,
71
                                          DateGeneration::Rule rule = DateGeneration::Backward,
72
                                          Pillar::Choice pillar = Pillar::LastRelevantDate,
73
                                          Date customPillarDate = Date());
74
75
        Real impliedQuote() const override;
76
        void setTermStructure(YieldTermStructure*) override;
77
        void accept(AcyclicVisitor&) override;
78
79
        // NOLINTNEXTLINE(cppcoreguidelines-noexcept-swap,performance-noexcept-swap)
80
0
        ext::shared_ptr<Swap> swap() const { return swap_; }
81
82
      private:
83
        void initialize(const ext::shared_ptr<OvernightIndex>& overnightIndex,
84
                        Date customPillarDate);
85
        void initializeDates() override;
86
87
        Period tenor_;
88
        Natural settlementDays_;
89
        Date startDate_, endDate_;
90
        Calendar calendar_;
91
        BusinessDayConvention convention_;
92
        bool endOfMonth_;
93
        ext::shared_ptr<OvernightIndex> overnightIndex_;
94
        Period paymentTenor_;
95
        DayCounter paymentDayCounter_;
96
        Integer paymentLag_;
97
        bool telescopicValueDates_;
98
        DateGeneration::Rule rule_;
99
        Pillar::Choice pillarChoice_;
100
101
        ext::shared_ptr<Swap> swap_;
102
        RelinkableHandle<YieldTermStructure> discountRelinkableHandle_;
103
    };
104
105
}
106
107
#endif