QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
equityindex.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) 2023 Marcin Rybacki
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file equityindex.hpp
21 \brief base class for equity indexes
22*/
23
24#ifndef quantlib_equityindex_hpp
25#define quantlib_equityindex_hpp
26
27#include <ql/index.hpp>
28#include <ql/time/calendar.hpp>
29#include <ql/currency.hpp>
31
32namespace QuantLib {
33
34 //! Base class for equity indexes
35 /*! The equity index object allows to retrieve past fixings,
36 as well as project future fixings using either both
37 the risk free interest rate term structure and the dividend
38 term structure, or just the interest rate term structure
39 in which case one can provide a term structure of equity
40 forwards implied from, e.g. option prices.
41
42 In case of the first method, the forward is calculated as:
43 \f[
44 I(t, T) = I(t, t) \frac{P_{D}(t, T)}{P_{R}(t, T)},
45 \f]
46 where \f$ I(t, t) \f$ is today's value of the index,
47 \f$ P_{D}(t, T) \f$ is a discount factor of the dividend
48 curve at future time \f$ T \f$, and \f$ P_{R}(t, T) \f$ is
49 a discount factor of the risk free curve at future time
50 \f$ T \f$.
51
52 In case of the latter method, the forward is calculated as:
53 \f[
54 I(t, T) = I(t, t) \frac{1}{P_{F}(t, T)},
55 \f]
56 where \f$ P_{F}(t, T) \f$ is a discount factor of the equity
57 forward term structure.
58
59 To forecast future fixings, the user can either provide a
60 handle to the current index spot. If spot handle is empty,
61 today's fixing will be used, instead.
62 */
63 class EquityIndex : public Index {
64 public:
65 EquityIndex(std::string name,
68 Handle<YieldTermStructure> interest = {},
69 Handle<YieldTermStructure> dividend = {},
70 Handle<Quote> spot = {});
71
72 /*! \deprecated Use the constructor taking a currency.
73 Deprecated in version 1.36.
74 */
75 [[deprecated("Use the constructor taking a currency")]]
76 EquityIndex(std::string name,
78 Handle<YieldTermStructure> interest = {},
79 Handle<YieldTermStructure> dividend = {},
80 Handle<Quote> spot = {});
81
82 //! \name Index interface
83 //@{
84 std::string name() const override { return name_; }
85 Calendar fixingCalendar() const override { return fixingCalendar_; }
86 bool isValidFixingDate(const Date& fixingDate) const override;
87 Real fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
88 //@}
89 //! \name Inspectors
90 //@{
91 //! The index currency
92 Currency currency() const { return currency_; }
93 //! the rate curve used to forecast fixings
95 //! the dividend curve used to forecast fixings
97 //! index spot value
98 Handle<Quote> spot() const { return spot_; }
99 //@}
100 //! \name Fixing calculations
101 //@{
102 //! It can be overridden to implement particular conventions
103 virtual Real forecastFixing(const Date& fixingDate) const;
104 // @}
105 //! \name Other methods
106 //@{
107 //! returns a copy of itself linked to different interest, dividend curves
108 //! or spot quote
109 virtual ext::shared_ptr<EquityIndex> clone(const Handle<YieldTermStructure>& interest,
110 const Handle<YieldTermStructure>& dividend,
111 const Handle<Quote>& spot) const;
112 // @}
113 private:
114 std::string name_;
120 };
121
122 inline bool EquityIndex::isValidFixingDate(const Date& d) const {
124 }
125}
126
127#endif
calendar class
calendar class
Definition: calendar.hpp:61
bool isBusinessDay(const Date &d) const
Definition: calendar.hpp:229
Currency specification
Definition: currency.hpp:36
Concrete date class.
Definition: date.hpp:125
Base class for equity indexes.
Definition: equityindex.hpp:63
Handle< Quote > spot_
virtual ext::shared_ptr< EquityIndex > clone(const Handle< YieldTermStructure > &interest, const Handle< YieldTermStructure > &dividend, const Handle< Quote > &spot) const
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
Definition: equityindex.hpp:85
virtual Real forecastFixing(const Date &fixingDate) const
It can be overridden to implement particular conventions.
Definition: equityindex.cpp:86
Handle< YieldTermStructure > dividend_
Handle< YieldTermStructure > equityDividendCurve() const
the dividend curve used to forecast fixings
Definition: equityindex.hpp:96
std::string name() const override
Returns the name of the index.
Definition: equityindex.hpp:84
Handle< Quote > spot() const
index spot value
Definition: equityindex.hpp:98
bool isValidFixingDate(const Date &fixingDate) const override
returns TRUE if the fixing date is a valid one
Currency currency() const
The index currency.
Definition: equityindex.hpp:92
Handle< YieldTermStructure > equityInterestRateCurve() const
the rate curve used to forecast fixings
Definition: equityindex.hpp:94
Handle< YieldTermStructure > interest_
Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
returns the fixing at the given date
Definition: equityindex.cpp:63
Shared handle to an observable.
Definition: handle.hpp:41
purely virtual base class for indexes
Definition: index.hpp:45
Currency specification.
Date d
QL_REAL Real
real number
Definition: types.hpp:50
virtual base class for indexes
Definition: any.hpp:37
Interest-rate term structure.