QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
actualactual.hpp
Go to the documentation of this file.
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 <http://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
28#include <ql/time/schedule.hpp>
29#include <utility>
30
31namespace 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:
56 private:
57 class ISMA_Impl final : public DayCounter::Impl {
58 public:
59 explicit ISMA_Impl(Schedule schedule) : schedule_(std::move(schedule)) {}
60
61 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:
69 };
70 class Old_ISMA_Impl final : public DayCounter::Impl {
71 public:
72 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 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 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 : DayCounter(implementation(c, std::move(schedule))) {}
94 };
95
96}
97
98#endif
Time yearFraction(const Date &d1, const Date &d2, const Date &, const Date &) const override
std::string name() const override
Time yearFraction(const Date &d1, const Date &d2, const Date &, const Date &) const override
std::string name() const override
Time yearFraction(const Date &d1, const Date &d2, const Date &refPeriodStart, const Date &refPeriodEnd) const override
std::string name() const override
Time yearFraction(const Date &d1, const Date &d2, const Date &refPeriodStart, const Date &refPeriodEnd) const override
std::string name() const override
Actual/Actual day count.
static ext::shared_ptr< DayCounter::Impl > implementation(Convention c, Schedule schedule)
ActualActual(Convention c, Schedule schedule=Schedule())
Concrete date class.
Definition: date.hpp:125
abstract base class for day counter implementations
Definition: daycounter.hpp:47
day counter class
Definition: daycounter.hpp:44
Payment schedule.
Definition: schedule.hpp:40
day counter class
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Definition: any.hpp:35
STL namespace.
date schedule