QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
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, public Observer {
64 public:
65 EquityIndex(std::string name,
67 Handle<YieldTermStructure> interest = {},
68 Handle<YieldTermStructure> dividend = {},
69 Handle<Quote> spot = {});
70
71 //! \name Index interface
72 //@{
73 std::string name() const override { return name_; }
74 Calendar fixingCalendar() const override { return fixingCalendar_; }
75 bool isValidFixingDate(const Date& fixingDate) const override;
76 Real fixing(const Date& fixingDate, bool forecastTodaysFixing = false) const override;
77 //@}
78 //! \name Observer interface
79 //@{
80 void update() override;
81 //@}
82 //! \name Inspectors
83 //@{
84 //! the rate curve used to forecast fixings
86 //! the dividend curve used to forecast fixings
88 //! index spot value
89 Handle<Quote> spot() const { return spot_; }
90 //@}
91 //! \name Fixing calculations
92 //@{
93 //! It can be overridden to implement particular conventions
94 virtual Real forecastFixing(const Date& fixingDate) const;
95 virtual Real pastFixing(const Date& fixingDate) const;
96 // @}
97 //! \name Other methods
98 //@{
99 //! returns a copy of itself linked to different interest, dividend curves
100 //! or spot quote
101 virtual ext::shared_ptr<EquityIndex> clone(const Handle<YieldTermStructure>& interest,
102 const Handle<YieldTermStructure>& dividend,
103 const Handle<Quote>& spot) const;
104 // @}
105 private:
106 std::string name_;
111 };
112
113 inline bool EquityIndex::isValidFixingDate(const Date& d) const {
115 }
116
118}
119
120#endif
calendar class
calendar class
Definition: calendar.hpp:61
bool isBusinessDay(const Date &d) const
Definition: calendar.hpp:223
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
Definition: equityindex.cpp:95
void update() override
Calendar fixingCalendar() const override
returns the calendar defining valid fixing dates
Definition: equityindex.hpp:74
virtual Real forecastFixing(const Date &fixingDate) const
It can be overridden to implement particular conventions.
Definition: equityindex.cpp:77
Handle< YieldTermStructure > dividend_
Handle< YieldTermStructure > equityDividendCurve() const
the dividend curve used to forecast fixings
Definition: equityindex.hpp:87
virtual Real pastFixing(const Date &fixingDate) const
Definition: equityindex.cpp:72
std::string name() const override
Returns the name of the index.
Definition: equityindex.hpp:73
Handle< Quote > spot() const
index spot value
Definition: equityindex.hpp:89
bool isValidFixingDate(const Date &fixingDate) const override
returns TRUE if the fixing date is a valid one
Handle< YieldTermStructure > equityInterestRateCurve() const
the rate curve used to forecast fixings
Definition: equityindex.hpp:85
Handle< YieldTermStructure > interest_
Real fixing(const Date &fixingDate, bool forecastTodaysFixing=false) const override
returns the fixing at the given date
Definition: equityindex.cpp:49
Shared handle to an observable.
Definition: handle.hpp:41
purely virtual base class for indexes
Definition: index.hpp:44
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
Currency specification.
Date d
QL_REAL Real
real number
Definition: types.hpp:50
virtual base class for indexes
Definition: any.hpp:35
Interest-rate term structure.