QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
cashflow.hpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5 Copyright (C) 2003, 2004, 2005, 2006, 2007, 2009 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_cash_flow_hpp
26#define quantlib_cash_flow_hpp
27
28#include <ql/event.hpp>
29#include <ql/math/comparison.hpp>
30#include <ql/optional.hpp>
31#include <ql/patterns/lazyobject.hpp>
32#include <vector>
33
34namespace QuantLib {
35
37
40 class CashFlow : public Event, public LazyObject {
41 public:
42 ~CashFlow() override = default;
44
45
46 Date date() const override = 0;
48
51 bool hasOccurred(const Date& refDate = Date(),
52 ext::optional<bool> includeRefDate = ext::nullopt) const override;
54
56 void performCalculations() const override {}
58
60
64 virtual Real amount() const = 0;
66 virtual Date exCouponDate() const { return {}; };
68 bool tradingExCoupon(const Date& refDate = Date()) const;
69
71
73 void accept(AcyclicVisitor&) override;
75 };
76
78 typedef std::vector<ext::shared_ptr<CashFlow> > Leg;
79
80 template <>
85 QL_DEPRECATED
87
91 QL_DEPRECATED
93
97 QL_DEPRECATED
98 typedef bool result_type;
99
100 bool operator()(const CashFlow& c1,
101 const CashFlow& c2) const {
102 return c1.date() < c2.date();
103 }
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
bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const override
returns true if an event has already occurred before a date
Definition: cashflow.cpp:27
void performCalculations() const override
Definition: cashflow.hpp:56
virtual Date exCouponDate() const
returns the date that the cash flow trades exCoupon
Definition: cashflow.hpp:66
bool tradingExCoupon(const Date &refDate=Date()) const
returns true if the cashflow is trading ex-coupon on the refDate
Definition: cashflow.cpp:51
void accept(AcyclicVisitor &) override
Definition: cashflow.cpp:63
Date date() const override=0
virtual Real amount() const =0
returns the amount of the cash flow
~CashFlow() override=default
Concrete date class.
Definition: date.hpp:125
Base class for event.
Definition: event.hpp:40
Framework for calculation on demand and result caching.
Definition: lazyobject.hpp:35
QL_REAL Real
real number
Definition: types.hpp:50
const boost::none_t & nullopt
Definition: optional.cpp:27
Definition: any.hpp:35
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
Definition: cashflow.hpp:78
QL_DEPRECATED typedef bool result_type
Definition: cashflow.hpp:98
bool operator()(const CashFlow &c1, const CashFlow &c2) const
Definition: cashflow.hpp:100
QL_DEPRECATED typedef CashFlow first_argument_type
Definition: cashflow.hpp:86
QL_DEPRECATED typedef CashFlow second_argument_type
Definition: cashflow.hpp:92
compare two objects by date
Definition: comparison.hpp:130