Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/experimental/basismodels/swaptioncfs.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) 2018 Sebastian Schlenkrich
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 swaptioncfs.hpp
21
    \brief translate swaption into deterministic fixed and float cash flows
22
*/
23
24
#ifndef quantlib_swaptioncfs_hpp
25
#define quantlib_swaptioncfs_hpp
26
27
#include <ql/instruments/swaption.hpp>
28
#include <ql/option.hpp>
29
#include <ql/termstructures/yieldtermstructure.hpp>
30
#include <ql/time/date.hpp>
31
32
namespace QuantLib {
33
34
    class IborLegCashFlows {
35
      protected:
36
        Date refDate_; // today, base for time calculations w.r.t. Act/365 (Fixed)
37
        Leg floatLeg_;
38
        std::vector<Real> floatTimes_;
39
        std::vector<Real> floatWeights_;
40
41
      public:
42
0
        const Leg& floatLeg() const { return floatLeg_; }
43
0
        const std::vector<Real>& floatTimes() const { return floatTimes_; }
44
0
        const std::vector<Real>& floatWeights() const { return floatWeights_; }
45
        IborLegCashFlows(const Leg& iborLeg,
46
                         const Handle<YieldTermStructure>& discountCurve,
47
                         bool contTenorSpread = true);
48
        IborLegCashFlows() = default;
49
        ; // allow default constructor which does nothing
50
    };
51
52
53
    class SwapCashFlows : public IborLegCashFlows {
54
      protected:
55
        // resulting cash flows as leg
56
        Leg fixedLeg_;
57
        std::vector<Real> fixedTimes_;
58
        std::vector<Real> fixedWeights_;
59
        std::vector<Real> annuityWeights_;
60
61
      public:
62
        SwapCashFlows(const ext::shared_ptr<FixedVsFloatingSwap>& swap,
63
                      const Handle<YieldTermStructure>& discountCurve,
64
                      bool contTenorSpread = true);
65
        SwapCashFlows() = default;
66
        ; // allow default constructor which does nothing
67
          // inspectors
68
0
        const Leg& fixedLeg() const { return fixedLeg_; }
69
0
        const std::vector<Real>& fixedTimes() const { return fixedTimes_; }
70
0
        const std::vector<Real>& fixedWeights() const { return fixedWeights_; }
71
0
        const std::vector<Real>& annuityWeights() const { return annuityWeights_; }
72
    };
73
74
75
    class SwaptionCashFlows : public SwapCashFlows {
76
      protected:
77
        ext::shared_ptr<Swaption> swaption_;
78
        std::vector<Real> exerciseTimes_;
79
80
      public:
81
        SwaptionCashFlows(const ext::shared_ptr<Swaption>& swaption,
82
                          const Handle<YieldTermStructure>& discountCurve,
83
                          bool contTenorSpread = true);
84
        SwaptionCashFlows() = default;
85
        ; // allow default constructor which does nothing
86
        // inspectors
87
0
        ext::shared_ptr<Swaption> swaption() const { return swaption_; }
88
0
        const std::vector<Real>& exerciseTimes() const { return exerciseTimes_; }
89
    };
90
91
92
}
93
94
#endif