| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2004 Jeff Yu |
| 5 | Copyright (C) 2004 M-Dimension Consulting Inc. |
| 6 | Copyright (C) 2005 StatPro Italia srl |
| 7 | Copyright (C) 2007, 2008, 2010 Ferdinando Ametrano |
| 8 | Copyright (C) 2009 Piter Dias |
| 9 | |
| 10 | This file is part of QuantLib, a free-software/open-source library |
| 11 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 12 | |
| 13 | QuantLib is free software: you can redistribute it and/or modify it |
| 14 | under the terms of the QuantLib license. You should have received a |
| 15 | copy of the license along with this program; if not, please email |
| 16 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 17 | <http://quantlib.org/license.shtml>. |
| 18 | |
| 19 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 20 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 21 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 22 | */ |
| 23 | |
| 24 | /*! \file fixedratebond.hpp |
| 25 | \brief fixed-rate bond |
| 26 | */ |
| 27 | |
| 28 | #ifndef quantlib_fixed_rate_bond_hpp |
| 29 | #define quantlib_fixed_rate_bond_hpp |
| 30 | |
| 31 | #include <ql/instruments/bond.hpp> |
| 32 | #include <ql/time/dategenerationrule.hpp> |
| 33 | #include <ql/time/daycounter.hpp> |
| 34 | #include <ql/interestrate.hpp> |
| 35 | |
| 36 | namespace QuantLib { |
| 37 | |
| 38 | class Schedule; |
| 39 | |
| 40 | //! fixed-rate bond |
| 41 | /*! \ingroup instruments |
| 42 | |
| 43 | \test calculations are tested by checking results against |
| 44 | cached values. |
| 45 | */ |
| 46 | class FixedRateBond : public Bond { |
| 47 | public: |
| 48 | //! simple annual compounding coupon rates |
| 49 | FixedRateBond(Natural settlementDays, |
| 50 | Real faceAmount, |
| 51 | const Schedule& schedule, |
| 52 | const std::vector<Rate>& coupons, |
| 53 | const DayCounter& accrualDayCounter, |
| 54 | BusinessDayConvention paymentConvention = Following, |
| 55 | Real redemption = 100.0, |
| 56 | const Date& issueDate = Date(), |
| 57 | const Calendar& paymentCalendar = Calendar(), |
| 58 | const Period& exCouponPeriod = Period(), |
| 59 | const Calendar& exCouponCalendar = Calendar(), |
| 60 | BusinessDayConvention exCouponConvention = Unadjusted, |
| 61 | bool exCouponEndOfMonth = false, |
| 62 | const DayCounter& firstPeriodDayCounter = DayCounter()); |
| 63 | |
| 64 | /*! \deprecated Use the constructor taking a schedule. |
| 65 | Deprecated in version 1.28. |
| 66 | */ |
| 67 | QL_DEPRECATED |
| 68 | FixedRateBond(Natural settlementDays, |
| 69 | const Calendar& couponCalendar, |
| 70 | Real faceAmount, |
| 71 | const Date& startDate, |
| 72 | const Date& maturityDate, |
| 73 | const Period& tenor, |
| 74 | const std::vector<Rate>& coupons, |
| 75 | const DayCounter& accrualDayCounter, |
| 76 | BusinessDayConvention accrualConvention = Following, |
| 77 | BusinessDayConvention paymentConvention = Following, |
| 78 | Real redemption = 100.0, |
| 79 | const Date& issueDate = Date(), |
| 80 | const Date& stubDate = Date(), |
| 81 | DateGeneration::Rule rule = DateGeneration::Backward, |
| 82 | bool endOfMonth = false, |
| 83 | const Calendar& paymentCalendar = Calendar(), |
| 84 | const Period& exCouponPeriod = Period(), |
| 85 | const Calendar& exCouponCalendar = Calendar(), |
| 86 | BusinessDayConvention exCouponConvention = Unadjusted, |
| 87 | bool exCouponEndOfMonth = false, |
| 88 | const DayCounter& firstPeriodDayCounter = DayCounter()); |
| 89 | |
| 90 | /*! \deprecated Build a FixedRateLeg instead and use it |
| 91 | to create an instance of the base Bond class. |
| 92 | Deprecated in version 1.28. |
| 93 | */ |
| 94 | QL_DEPRECATED |
| 95 | FixedRateBond(Natural settlementDays, |
| 96 | Real faceAmount, |
| 97 | const Schedule& schedule, |
| 98 | const std::vector<InterestRate>& coupons, |
| 99 | BusinessDayConvention paymentConvention = Following, |
| 100 | Real redemption = 100.0, |
| 101 | const Date& issueDate = Date(), |
| 102 | const Calendar& paymentCalendar = Calendar(), |
| 103 | const Period& exCouponPeriod = Period(), |
| 104 | const Calendar& exCouponCalendar = Calendar(), |
| 105 | BusinessDayConvention exCouponConvention = Unadjusted, |
| 106 | bool exCouponEndOfMonth = false); |
| 107 | Frequency frequency() const { return frequency_; } |
| 108 | const DayCounter& dayCounter() const {return dayCounter_;} |
| 109 | const DayCounter& firstPeriodDayCounter() const {return firstPeriodDayCounter_;} |
| 110 | protected: |
| 111 | Frequency frequency_; |
| 112 | DayCounter dayCounter_; |
| 113 | DayCounter firstPeriodDayCounter_; |
| 114 | }; |
| 115 | |
| 116 | } |
| 117 | |
| 118 | #endif |
| 119 | |