QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
interestrateindex.hpp
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) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 StatPro Italia srl
6 Copyright (C) 2006, 2011 Ferdinando Ametrano
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 interestrateindex.hpp
23 \brief base class for interest rate indexes
24*/
25
26#ifndef quantlib_interestrateindex_hpp
27#define quantlib_interestrateindex_hpp
28
29#include <ql/index.hpp>
30#include <ql/time/calendar.hpp>
31#include <ql/currency.hpp>
33#include <ql/time/period.hpp>
34
35namespace QuantLib {
36
37 //! base class for interest rate indexes
38 /*! \todo add methods returning InterestRate */
39 class InterestRateIndex : public Index {
40 public:
41 InterestRateIndex(std::string familyName,
42 const Period& tenor,
43 Natural settlementDays,
47 //! \name Index interface
48 //@{
49 std::string name() const override;
50 Calendar fixingCalendar() const override;
51 bool isValidFixingDate(const Date& fixingDate) const override;
52 Rate fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
53 //@}
54 //! \name Inspectors
55 //@{
56 std::string familyName() const { return familyName_; }
57 Period tenor() const { return tenor_; }
58 Natural fixingDays() const { return fixingDays_; }
59 const Currency& currency() const { return currency_; }
60 const DayCounter& dayCounter() const { return dayCounter_; }
61 //@}
62 /*! \name Date calculations
63
64 These method can be overridden to implement particular
65 conventions (e.g. EurLibor)
66
67 @{
68 */
69 virtual Date fixingDate(const Date& valueDate) const;
70 virtual Date valueDate(const Date& fixingDate) const;
71 virtual Date maturityDate(const Date& valueDate) const = 0;
72 //@}
73 //! \name Fixing calculations
74 //@{
75 //! It can be overridden to implement particular conventions
76 virtual Rate forecastFixing(const Date& fixingDate) const = 0;
77 // @}
78 protected:
79 std::string familyName_;
84 std::string name_;
85 private:
87 };
88
89
90 // inline definitions
91
92 inline std::string InterestRateIndex::name() const {
93 return name_;
94 }
95
97 return fixingCalendar_;
98 }
99
100 inline bool InterestRateIndex::isValidFixingDate(const Date& d) const {
102 }
103
104 inline Date InterestRateIndex::fixingDate(const Date& valueDate) const {
106 -static_cast<Integer>(fixingDays_), Days);
107 return fixingDate;
108 }
109
110 inline Date InterestRateIndex::valueDate(const Date& fixingDate) const {
112 fixingDate << " is not a valid fixing date");
114 }
115}
116
117#endif
calendar class
calendar class
Definition: calendar.hpp:61
bool isBusinessDay(const Date &d) const
Definition: calendar.hpp:229
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
Definition: calendar.cpp:130
Currency specification
Definition: currency.hpp:36
Concrete date class.
Definition: date.hpp:125
day counter class
Definition: daycounter.hpp:44
purely virtual base class for indexes
Definition: index.hpp:45
base class for interest rate indexes
virtual Rate forecastFixing(const Date &fixingDate) const =0
It can be overridden to implement particular conventions.
virtual Date maturityDate(const Date &valueDate) const =0
const DayCounter & dayCounter() const
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
const Currency & currency() const
Rate fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
returns the fixing at the given date
std::string name() const override
Returns the name of the index.
virtual Date valueDate(const Date &fixingDate) const
bool isValidFixingDate(const Date &fixingDate) const override
returns TRUE if the fixing date is a valid one
virtual Date fixingDate(const Date &valueDate) const
std::string familyName() const
Currency specification.
day counter class
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
Date d
unsigned QL_INTEGER Natural
positive integer
Definition: types.hpp:43
QL_INTEGER Integer
integer number
Definition: types.hpp:35
Real Rate
interest rates
Definition: types.hpp:70
virtual base class for indexes
Definition: any.hpp:37
period- and frequency-related classes and enumerations