Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yearcounter.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file yearcounter.hpp
20 \brief day counter that returns the nearest integer yearfraction
21*/
22
23#ifndef quantext_year_counter_hpp
24#define quantext_year_counter_hpp
25
26#include <ql/time/daycounter.hpp>
27
28namespace QuantExt {
29
30//! Year counter for when we want a whole number year fraction.
31/*! This day counter computes a day count fraction using an underlying
32 day counter (ACTACT) before rounding the result to
33 the nearest integer.
34
35 \ingroup daycounters
36*/
37class YearCounter : public QuantLib::DayCounter {
38public:
39 YearCounter() : QuantLib::DayCounter(QuantLib::ext::shared_ptr<DayCounter::Impl>(new YearCounter::Impl())) {}
40
41private:
42 class Impl : public DayCounter::Impl {
43 public:
44 std::string name() const override { return "Year"; }
45 QuantLib::Date::serial_type dayCount(const QuantLib::Date& d1, const QuantLib::Date& d2) const override;
46 QuantLib::Time yearFraction(const QuantLib::Date& d1, const QuantLib::Date& d2, const QuantLib::Date&,
47 const QuantLib::Date&) const override;
48 };
49};
50
51} // namespace QuantExt
52
53#endif
QuantLib::Time yearFraction(const QuantLib::Date &d1, const QuantLib::Date &d2, const QuantLib::Date &, const QuantLib::Date &) const override
Definition: yearcounter.cpp:36
std::string name() const override
Definition: yearcounter.hpp:44
QuantLib::Date::serial_type dayCount(const QuantLib::Date &d1, const QuantLib::Date &d2) const override
Definition: yearcounter.cpp:32
Year counter for when we want a whole number year fraction.
Definition: yearcounter.hpp:37