QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
actual360.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
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
24#ifndef quantlib_actual360_day_counter_h
25#define quantlib_actual360_day_counter_h
26
27#include <ql/time/daycounter.hpp>
28
29namespace QuantLib {
30
32
37 class Actual360 : public DayCounter {
38 private:
39 class Impl final : public DayCounter::Impl {
40 private:
42 public:
43 explicit Impl(const bool includeLastDay)
44 : includeLastDay_(includeLastDay) {}
45 std::string name() const override {
46 return includeLastDay_ ?
47 std::string("Actual/360 (inc)")
48 : std::string("Actual/360");
49 }
50 Date::serial_type dayCount(const Date& d1, const Date& d2) const override {
51 return (d2-d1) + (includeLastDay_ ? 1 : 0);
52 }
53 Time
54 yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const override {
55 return (daysBetween(d1,d2)
56 + (includeLastDay_ ? 1.0 : 0.0))/360.0;
57 }
58 };
59 public:
60 explicit Actual360(const bool includeLastDay = false)
61 : DayCounter(ext::shared_ptr<DayCounter::Impl>(
62 new Actual360::Impl(includeLastDay))) {}
63 };
64
65}
66
67#endif
Date::serial_type dayCount(const Date &d1, const Date &d2) const override
to be overloaded by more complex day counters
Definition: actual360.hpp:50
Impl(const bool includeLastDay)
Definition: actual360.hpp:43
Time yearFraction(const Date &d1, const Date &d2, const Date &, const Date &) const override
Definition: actual360.hpp:54
std::string name() const override
Definition: actual360.hpp:45
Actual/360 day count convention.
Definition: actual360.hpp:37
Actual360(const bool includeLastDay=false)
Definition: actual360.hpp:60
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
day counter class
Definition: daycounter.hpp:44
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
Definition: any.hpp:35
Time daysBetween(const Date &d1, const Date &d2)
Definition: date.hpp:442