QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
dividend.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2005 Joseph Wang
5 Copyright (C) 2006 StatPro Italia srl
6
7 This file is part of QuantLib, a free-software/open-source library
8 for financial quantitative analysts and developers - http://quantlib.org/
9
10 QuantLib is free software: you can redistribute it and/or modify it
11 under the terms of the QuantLib license. You should have received a
12 copy of the license along with this program; if not, please email
13 <quantlib-dev@lists.sf.net>. The license is also available online at
14 <http://quantlib.org/license.shtml>.
15
16 This program is distributed in the hope that it will be useful, but WITHOUT
17 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18 FOR A PARTICULAR PURPOSE. See the license for more details.
19*/
20
25#ifndef quantlib_dividend_hpp
26#define quantlib_dividend_hpp
27
28#include <ql/cashflow.hpp>
29#include <ql/utilities/null.hpp>
30#include <vector>
31
32namespace QuantLib {
33
35
36 class Dividend : public CashFlow {
37 public:
39 : date_(date) {}
41
42 Date date() const override { return date_; }
44
46 Real amount() const override = 0;
48 virtual Real amount(Real underlying) const = 0;
50
51 void accept(AcyclicVisitor&) override;
53 protected:
55 };
56
58
59 class FixedDividend : public Dividend {
60 public:
64
65 Real amount() const override { return amount_; }
66 Real amount(Real) const override { return amount_; }
68 protected:
70 };
71
73
75 public:
78
82
83 Real amount() const override {
84 QL_REQUIRE(nominal_ != Null<Real>(), "no nominal given");
85 return rate_ * nominal_;
86 }
87 Real amount(Real underlying) const override { return rate_ * underlying; }
89
91 Real rate() const { return rate_; }
92 Real nominal() const { return nominal_; }
94 protected:
97 };
98
99
101 std::vector<ext::shared_ptr<Dividend> >
102 DividendVector(const std::vector<Date>& dividendDates,
103 const std::vector<Real>& dividends);
104
105}
106
107
108#endif
degenerate base class for the Acyclic Visitor pattern
Definition: visitor.hpp:33
Base class for cash flows.
Definition: cashflow.hpp:40
Concrete date class.
Definition: date.hpp:125
Predetermined cash flow.
Definition: dividend.hpp:36
Dividend(const Date &date)
Definition: dividend.hpp:38
virtual Real amount(Real underlying) const =0
void accept(AcyclicVisitor &) override
Definition: dividend.cpp:26
Real amount() const override=0
returns the amount of the cash flow
Date date() const override
Definition: dividend.hpp:42
Predetermined cash flow.
Definition: dividend.hpp:59
FixedDividend(Real amount, const Date &date)
Definition: dividend.hpp:61
Real amount() const override
returns the amount of the cash flow
Definition: dividend.hpp:65
Real amount(Real) const override
Definition: dividend.hpp:66
Predetermined cash flow.
Definition: dividend.hpp:74
FractionalDividend(Real rate, const Date &date)
Definition: dividend.hpp:76
Real amount() const override
returns the amount of the cash flow
Definition: dividend.hpp:83
Real amount(Real underlying) const override
Definition: dividend.hpp:87
FractionalDividend(Real rate, Real nominal, const Date &date)
Definition: dividend.hpp:79
template class providing a null value for a given type.
Definition: null.hpp:76
QL_REAL Real
real number
Definition: types.hpp:50
Definition: any.hpp:35
std::vector< ext::shared_ptr< Dividend > > DividendVector(const std::vector< Date > &dividendDates, const std::vector< Real > &dividends)
helper function building a sequence of fixed dividends
Definition: dividend.cpp:35