| 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 }; |
| 48 | explicit Actual365Fixed(Convention c = Actual365Fixed::Standard) |
| 49 | : DayCounter(implementation(c)) {} |
| 50 | |
| 51 | private: |
| 52 | class Impl final : public DayCounter::Impl { |
| 53 | public: |
| 54 | std::string name() const override { return std::string("Actual/365 (Fixed)" ); } |
| 55 | Time |
| 56 | yearFraction(const Date& d1, const Date& d2, const Date&, const Date&) const override { |
| 57 | return daysBetween(d1,d2)/365.0; |
| 58 | } |
| 59 | }; |
| 60 | class CA_Impl final : public DayCounter::Impl { |
| 61 | public: |
| 62 | std::string name() const override { |
| 63 | return std::string("Actual/365 (Fixed) Canadian Bond" ); |
| 64 | } |
| 65 | Time yearFraction(const Date& d1, |
| 66 | const Date& d2, |
| 67 | const Date& refPeriodStart, |
| 68 | const Date& refPeriodEnd) const override; |
| 69 | }; |
| 70 | class NL_Impl final : public DayCounter::Impl { |
| 71 | public: |
| 72 | std::string name() const override { return std::string("Actual/365 (No Leap)" ); } |
| 73 | Date::serial_type dayCount(const Date& d1, const Date& d2) const override; |
| 74 | Time yearFraction(const Date& d1, |
| 75 | const Date& d2, |
| 76 | const Date& refPeriodStart, |
| 77 | const Date& refPeriodEnd) const override; |
| 78 | }; |
| 79 | static ext::shared_ptr<DayCounter::Impl> implementation(Convention); |
| 80 | }; |
| 81 | |
| 82 | } |
| 83 | |
| 84 | #endif |
| 85 | |