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) 2004 Ferdinando Ametrano
6  Copyright (C) 2013 BGC Partners L.P.
7 
8  This file is part of QuantLib, a free-software/open-source library
9  for financial quantitative analysts and developers - http://quantlib.org/
10 
11  QuantLib is free software: you can redistribute it and/or modify it
12  under the terms of the QuantLib license.  You should have received a
13  copy of the license along with this program; if not, please email
14  <quantlib-dev@lists.sf.net>. The license is also available online at
15  <http://quantlib.org/license.shtml>.
16 
17  This program is distributed in the hope that it will be useful, but WITHOUT
18  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19  FOR A PARTICULAR PURPOSE.  See the license for more details.
20 */
21 
22 /*! \file actual365fixed.hpp
23     \brief Actual/365 (Fixed) day counter
24 */
25 
26 #ifndef quantlib_actual365fixed_day_counter_h
27 #define quantlib_actual365fixed_day_counter_h
28 
29 #include <ql/time/daycounter.hpp>
30 
31 namespace QuantLib {
32 
33     //! Actual/365 (Fixed) day count convention
34     /*! "Actual/365 (Fixed)" day count convention, also know as
35         "Act/365 (Fixed)", "A/365 (Fixed)", or "A/365F".
36 
37         \warning According to ISDA, "Actual/365" (without "Fixed") is
38                  an alias for "Actual/Actual (ISDA)" (see
39                  ActualActual.)  If Actual/365 is not explicitly
40                  specified as fixed in an instrument specification,
41                  you might want to double-check its meaning.
42 
43         \ingroup daycounters
44     */
45     class Actual365Fixed : public DayCounter {
46       public:
47         enum Convention { Standard, Canadian, NoLeap };
Actual365Fixed(Convention c=Actual365Fixed::Standard)48         explicit Actual365Fixed(Convention c = Actual365Fixed::Standard)
49         : DayCounter(implementation(c)) {}
50 
51       private:
52         class Impl : public DayCounter::Impl {
53           public:
name() const54             std::string name() const { return std::string("Actual/365 (Fixed)"); }
yearFraction(const Date & d1,const Date & d2,const Date &,const Date &) const55             Time yearFraction(const Date& d1,
56                               const Date& d2,
57                               const Date&,
58                               const Date&) const {
59                 return daysBetween(d1,d2)/365.0;
60             }
61         };
62         class CA_Impl : public DayCounter::Impl {
63           public:
name() const64             std::string name() const {
65                 return std::string("Actual/365 (Fixed) Canadian Bond");
66             }
67             Time yearFraction(const Date& d1,
68                               const Date& d2,
69                               const Date& refPeriodStart,
70                               const Date& refPeriodEnd) const;
71         };
72         class NL_Impl : public DayCounter::Impl {
73           public:
name() const74             std::string name() const {
75                 return std::string("Actual/365 (No Leap)");
76             }
77             Date::serial_type dayCount(const Date& d1,
78                                        const Date& d2) const;
79             Time yearFraction(const Date& d1,
80                               const Date& d2,
81                               const Date& refPeriodStart,
82                               const Date& refPeriodEnd) const;
83         };
84         static ext::shared_ptr<DayCounter::Impl> implementation(Convention);
85     };
86 
87 }
88 
89 #endif
90