QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
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 Observer {
41 public:
42 InterestRateIndex(std::string familyName,
43 const Period& tenor,
44 Natural settlementDays,
48 //! \name Index interface
49 //@{
50 std::string name() const override;
51 Calendar fixingCalendar() const override;
52 bool isValidFixingDate(const Date& fixingDate) const override;
53 Rate fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
54 //@}
55 //! \name Observer interface
56 //@{
57 void update() override;
58 //@}
59 //! \name Inspectors
60 //@{
61 std::string familyName() const { return familyName_; }
62 Period tenor() const { return tenor_; }
63 Natural fixingDays() const { return fixingDays_; }
64 Date fixingDate(const Date& valueDate) const;
65 const Currency& currency() const { return currency_; }
66 const DayCounter& dayCounter() const { return dayCounter_; }
67 //@}
68 /*! \name Date calculations
69
70 These method can be overridden to implement particular
71 conventions (e.g. EurLibor)
72
73 @{
74 */
75 virtual Date valueDate(const Date& fixingDate) const;
76 virtual Date maturityDate(const Date& valueDate) const = 0;
77 //@}
78 //! \name Fixing calculations
79 //@{
80 //! It can be overridden to implement particular conventions
81 virtual Rate forecastFixing(const Date& fixingDate) const = 0;
82 virtual Rate pastFixing(const Date& fixingDate) const;
83 // @}
84 protected:
85 std::string familyName_;
90 std::string name_;
91 private:
93 };
94
95
96 // inline definitions
97
98 inline std::string InterestRateIndex::name() const {
99 return name_;
100 }
101
103 return fixingCalendar_;
104 }
105
106 inline bool InterestRateIndex::isValidFixingDate(const Date& d) const {
108 }
109
112 }
113
114 inline Date InterestRateIndex::fixingDate(const Date& valueDate) const {
116 -static_cast<Integer>(fixingDays_), Days);
117 return fixingDate;
118 }
119
120 inline Date InterestRateIndex::valueDate(const Date& fixingDate) const {
122 fixingDate << " is not a valid fixing date");
124 }
125
126 inline Rate InterestRateIndex::pastFixing(const Date& fixingDate) const {
128 fixingDate << " is not a valid fixing date");
129 return timeSeries()[fixingDate];
130 }
131
132}
133
134#endif
calendar class
calendar class
Definition: calendar.hpp:61
bool isBusinessDay(const Date &d) const
Definition: calendar.hpp:223
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:44
const TimeSeries< Real > & timeSeries() const
returns the fixing TimeSeries
Definition: index.hpp:65
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
virtual Rate pastFixing(const Date &fixingDate) const
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
Date fixingDate(const Date &valueDate) const
std::string familyName() const
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
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:35
period- and frequency-related classes and enumerations