Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/time/daycounters/actualactual.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) 2000, 2001, 2002, 2003 RiskMap 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
 <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 actualactual.hpp
21
    \brief act/act day counters
22
*/
23
24
#ifndef quantlib_actualactual_day_counter_h
25
#define quantlib_actualactual_day_counter_h
26
27
#include <ql/time/daycounter.hpp>
28
#include <ql/time/schedule.hpp>
29
#include <utility>
30
31
namespace QuantLib {
32
33
    //! Actual/Actual day count
34
    /*! The day count can be calculated according to:
35
36
        - the ISDA convention, also known as "Actual/Actual (Historical)",
37
          "Actual/Actual", "Act/Act", and according to ISDA also "Actual/365",
38
          "Act/365", and "A/365";
39
        - the ISMA and US Treasury convention, also known as
40
          "Actual/Actual (Bond)";
41
        - the AFB convention, also known as "Actual/Actual (Euro)".
42
43
        For more details, refer to
44
        https://www.isda.org/a/pIJEE/The-Actual-Actual-Day-Count-Fraction-1999.pdf
45
46
        \ingroup daycounters
47
48
        \test the correctness of the results is checked against known
49
              good values.
50
    */
51
    class ActualActual : public DayCounter {
52
      public:
53
        enum Convention { ISMA, Bond,
54
                          ISDA, Historical, Actual365,
55
                          AFB, Euro };
56
      private:
57
        class ISMA_Impl final : public DayCounter::Impl {
58
          public:
59
0
            explicit ISMA_Impl(Schedule schedule) : schedule_(std::move(schedule)) {}
60
61
0
            std::string name() const override { return std::string("Actual/Actual (ISMA)"); }
62
            Time yearFraction(const Date& d1,
63
                              const Date& d2,
64
                              const Date& refPeriodStart,
65
                              const Date& refPeriodEnd) const override;
66
67
          private:
68
            Schedule schedule_;
69
        };
70
        class Old_ISMA_Impl final : public DayCounter::Impl {
71
          public:
72
0
            std::string name() const override { return std::string("Actual/Actual (ISMA)"); }
73
            Time yearFraction(const Date& d1,
74
                              const Date& d2,
75
                              const Date& refPeriodStart,
76
                              const Date& refPeriodEnd) const override;
77
        };
78
        class ISDA_Impl final : public DayCounter::Impl {
79
          public:
80
0
            std::string name() const override { return std::string("Actual/Actual (ISDA)"); }
81
            Time
82
            yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const override;
83
        };
84
        class AFB_Impl final : public DayCounter::Impl {
85
          public:
86
0
            std::string name() const override { return std::string("Actual/Actual (AFB)"); }
87
            Time
88
            yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const override;
89
        };
90
        static ext::shared_ptr<DayCounter::Impl> implementation(Convention c, Schedule schedule);
91
      public:
92
        explicit ActualActual(Convention c, Schedule schedule = Schedule())
93
85.0k
        : DayCounter(implementation(c, std::move(schedule))) {}
94
    };
95
96
}
97
98
#endif