QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
equitycashflow.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_equity_cash_flow_hpp
25#define quantlib_equity_cash_flow_hpp
26
27#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
28#include <ql/termstructures/yield/zeroyieldstructure.hpp>
29#include <ql/cashflows/indexedcashflow.hpp>
30#include <ql/patterns/visitor.hpp>
31
32namespace QuantLib {
33
34 class EquityIndex;
35 class EquityCashFlowPricer;
36
38 public:
40 ext::shared_ptr<EquityIndex> index,
41 const Date& baseDate,
42 const Date& fixingDate,
43 const Date& paymentDate,
44 bool growthOnly = true);
46
47 Real amount() const override;
49
51 void accept(AcyclicVisitor&) override;
53 void setPricer(const ext::shared_ptr<EquityCashFlowPricer>&);
54 const ext::shared_ptr<EquityCashFlowPricer>& pricer() const { return pricer_; };
55
56 private:
57 ext::shared_ptr<EquityCashFlowPricer> pricer_;
58 };
59
61 auto* v1 = dynamic_cast<Visitor<EquityCashFlow>*>(&v);
62 if (v1 != nullptr)
63 v1->visit(*this);
64 else
66 }
67
68 void setCouponPricer(const Leg& leg, const ext::shared_ptr<EquityCashFlowPricer>&);
69
70 class EquityCashFlowPricer : public virtual Observer, public virtual Observable {
71 public:
74
75 virtual Real price() const = 0;
76 virtual void initialize(const EquityCashFlow&) = 0;
78
80
81 void update() override { notifyObservers(); }
83 protected:
84 ext::shared_ptr<EquityIndex> index_;
87 };
88
90 public:
92 Handle<BlackVolTermStructure> equityVolatility,
94 Handle<Quote> correlation);
96
97 Real price() const override;
98 void initialize(const EquityCashFlow&) override;
100 private:
104 };
105}
106
107#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Concrete date class.
Definition: date.hpp:125
ext::shared_ptr< EquityCashFlowPricer > pricer_
const ext::shared_ptr< EquityCashFlowPricer > & pricer() const
Real amount() const override
returns the amount of the cash flow
void accept(AcyclicVisitor &) override
void setPricer(const ext::shared_ptr< EquityCashFlowPricer > &)
ext::shared_ptr< EquityIndex > index_
virtual Real price() const =0
virtual void initialize(const EquityCashFlow &)=0
void initialize(const EquityCashFlow &) override
Handle< YieldTermStructure > quantoTermStructure
Handle< BlackVolTermStructure > fxVolatility_
Handle< YieldTermStructure > quantoCurrencyTermStructure_
Handle< BlackVolTermStructure > equityVolatility_
Shared handle to an observable.
Definition: handle.hpp:41
Cash flow dependent on an index ratio.
virtual Date fixingDate() const
virtual Real notional() const
void accept(AcyclicVisitor &) override
virtual Date baseDate() const
virtual bool growthOnly() const
virtual ext::shared_ptr< Index > index() const
Object that notifies its changes to a set of observers.
Definition: observable.hpp:62
Object that gets notified when a given observable changes.
Definition: observable.hpp:116
Visitor for a specific class
Definition: visitor.hpp:40
virtual void visit(T &)=0
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
void setCouponPricer(const Leg &leg, const ext::shared_ptr< FloatingRateCouponPricer > &pricer)
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78