QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
thirty360.hpp
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 Copyright (C) 2018 Alexey Indiryakov
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 <http://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
25#ifndef quantlib_thirty360_day_counter_h
26#define quantlib_thirty360_day_counter_h
27
28#include <ql/time/daycounter.hpp>
29
30namespace QuantLib {
31
33
76 class Thirty360 : public DayCounter {
77 public:
87 NASD
88 };
89 private:
91 public:
92 Time yearFraction(const Date& d1, const Date& d2,
93 const Date&, const Date&) const override {
94 return dayCount(d1,d2)/360.0;
95 }
96 };
97 class US_Impl final : public Thirty360_Impl {
98 public:
99 std::string name() const override { return std::string("30/360 (US)"); }
100 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
101 };
102 class ISMA_Impl final : public Thirty360_Impl {
103 public:
104 std::string name() const override { return std::string("30/360 (Bond Basis)"); }
105 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
106 };
107 class EU_Impl final : public Thirty360_Impl {
108 public:
109 std::string name() const override { return std::string("30E/360 (Eurobond Basis)"); }
110 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
111 };
112 class IT_Impl final : public Thirty360_Impl {
113 public:
114 std::string name() const override { return std::string("30/360 (Italian)"); }
115 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
116 };
117 class ISDA_Impl final : public Thirty360_Impl {
118 public:
119 explicit ISDA_Impl(const Date& terminationDate)
120 : terminationDate_(terminationDate) {}
121 std::string name() const override { return std::string("30E/360 (ISDA)"); }
122 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
123 private:
125 };
126 class NASD_Impl final : public Thirty360_Impl {
127 public:
128 std::string name() const override { return std::string("30/360 (NASD)"); }
129 Date::serial_type dayCount(const Date& d1, const Date& d2) const override;
130 };
131 static ext::shared_ptr<DayCounter::Impl>
132 implementation(Convention c, const Date& terminationDate);
133 public:
134 explicit Thirty360(Convention c, const Date& terminationDate = Date())
135 : DayCounter(implementation(c, terminationDate)) {}
136 };
137
138}
139
140#endif
Concrete date class.
Definition: date.hpp:125
std::int_fast32_t serial_type
serial number type
Definition: date.hpp:128
abstract base class for day counter implementations
Definition: daycounter.hpp:47
virtual Date::serial_type dayCount(const Date &d1, const Date &d2) const
to be overloaded by more complex day counters
Definition: daycounter.hpp:52
day counter class
Definition: daycounter.hpp:44
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:84
std::string name() const override
Definition: thirty360.hpp:109
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:111
ISDA_Impl(const Date &terminationDate)
Definition: thirty360.hpp:119
std::string name() const override
Definition: thirty360.hpp:121
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:72
std::string name() const override
Definition: thirty360.hpp:104
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:96
std::string name() const override
Definition: thirty360.hpp:114
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:127
std::string name() const override
Definition: thirty360.hpp:128
Time yearFraction(const Date &d1, const Date &d2, const Date &, const Date &) const override
Definition: thirty360.hpp:92
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: thirty360.cpp:57
std::string name() const override
Definition: thirty360.hpp:99
30/360 day count convention
Definition: thirty360.hpp:76
static ext::shared_ptr< DayCounter::Impl > implementation(Convention c, const Date &terminationDate)
Definition: thirty360.cpp:35
Thirty360(Convention c, const Date &terminationDate=Date())
Definition: thirty360.hpp:134
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Definition: any.hpp:35