Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
yearcounter.cpp
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) 2019 Quaternion Risk Management Ltd
5 All rights reserved.
6
7 This file is part of ORE, a free-software/open-source library
8 for transparent pricing and risk analysis - http://opensourcerisk.org
9
10 ORE is free software: you can redistribute it and/or modify it
11 under the terms of the Modified BSD License. You should have received a
12 copy of the license along with this program.
13 The license is also available online at <http://opensourcerisk.org>
14
15 This program is distributed on the basis that it will form a useful
16 contribution to risk analytics and model standardisation, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
18 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
21#include <ql/time/daycounters/actualactual.hpp>
23
24using QuantLib::Date;
25using QuantLib::Time;
26
27namespace QuantExt {
28namespace {
29 QuantLib::DayCounter underlyingDCF = QuantLib::ActualActual(QuantLib::ActualActual::ISDA);
30}
31
32Date::serial_type YearCounter::Impl::dayCount(const Date& d1, const Date& d2) const {
33 return underlyingDCF.dayCount(d1, d2);
34}
35
36Time YearCounter::Impl::yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const {
37 Time t = underlyingDCF.yearFraction(d1, d2);
38
39 return std::floor(0.5 + t); // rounding to the nearest integer
40}
41
42} // namespace QuantExt
QuantLib::Time yearFraction(const QuantLib::Date &d1, const QuantLib::Date &d2, const QuantLib::Date &, const QuantLib::Date &) const override
Definition: yearcounter.cpp:36
QuantLib::Date::serial_type dayCount(const QuantLib::Date &d1, const QuantLib::Date &d2) const override
Definition: yearcounter.cpp:32
day counter that returns the nearest integer yearfraction