QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
equityindex.hpp
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
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>
30#include <ql/termstructures/yieldtermstructure.hpp>
31
32namespace QuantLib {
33
35
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
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;
78
80 void update() override;
82
84
89 Handle<Quote> spot() const { return spot_; }
91
93
94 virtual Real forecastFixing(const Date& fixingDate) const;
95 virtual Real pastFixing(const Date& fixingDate) const;
96 // @}
98
99
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 {
114 return fixingCalendar().isBusinessDay(d);
115 }
116
118}
119
120#endif
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
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35