QuantLib
: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
ql
exercise.hpp
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
5
Copyright (C) 2003 Ferdinando Ametrano
6
Copyright (C) 2006 StatPro Italia srl
7
8
This file is part of QuantLib, a free-software/open-source library
9
for financial quantitative analysts and developers - http://quantlib.org/
10
11
QuantLib is free software: you can redistribute it and/or modify it
12
under the terms of the QuantLib license. You should have received a
13
copy of the license along with this program; if not, please email
14
<quantlib-dev@lists.sf.net>. The license is also available online at
15
<http://quantlib.org/license.shtml>.
16
17
This program is distributed in the hope that it will be useful, but WITHOUT
18
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
FOR A PARTICULAR PURPOSE. See the license for more details.
20
*/
21
26
#ifndef quantlib_exercise_type_h
27
#define quantlib_exercise_type_h
28
29
#include <ql/time/date.hpp>
30
#include <vector>
31
32
namespace
QuantLib
{
33
35
class
Exercise
{
36
public
:
37
enum
Type
{
38
American
,
Bermudan
,
European
39
};
40
// constructor
41
explicit
Exercise
(
Type
type
) :
type_
(
type
) {}
42
virtual
~Exercise
() =
default
;
43
// inspectors
44
Type
type
()
const
{
return
type_
; }
45
Date
date
(
Size
index)
const
{
return
dates_
[index]; }
46
Date
dateAt
(
Size
index)
const
{
return
dates_
.at(index); }
48
const
std::vector<Date>&
dates
()
const
{
return
dates_
; }
49
Date
lastDate
()
const
;
50
protected
:
51
std::vector<Date>
dates_
;
52
Type
type_
;
53
};
54
56
57
class
EarlyExercise
:
public
Exercise
{
58
public
:
59
EarlyExercise
(
Type
type
,
60
bool
payoffAtExpiry
=
false
)
61
:
Exercise
(
type
),
payoffAtExpiry_
(
payoffAtExpiry
) {}
62
bool
payoffAtExpiry
()
const
{
return
payoffAtExpiry_
; }
63
private
:
64
bool
payoffAtExpiry_
;
65
};
66
68
75
class
AmericanExercise
:
public
EarlyExercise
{
76
public
:
77
AmericanExercise
(
const
Date
& earliestDate,
78
const
Date
& latestDate,
79
bool
payoffAtExpiry
=
false
);
80
AmericanExercise
(
const
Date
& latestDate,
81
bool
payoffAtExpiry
=
false
);
82
};
83
85
87
class
BermudanExercise
:
public
EarlyExercise
{
88
public
:
89
BermudanExercise
(
const
std::vector<Date>&
dates
,
90
bool
payoffAtExpiry
=
false
);
91
};
92
94
96
class
EuropeanExercise
:
public
Exercise
{
97
public
:
98
EuropeanExercise
(
const
Date
&
date
);
99
};
100
101
}
102
103
104
#endif
QuantLib::AmericanExercise
American exercise.
Definition:
exercise.hpp:75
QuantLib::BermudanExercise
Bermudan exercise.
Definition:
exercise.hpp:87
QuantLib::Date
Concrete date class.
Definition:
date.hpp:125
QuantLib::EarlyExercise
Early-exercise base class.
Definition:
exercise.hpp:57
QuantLib::EarlyExercise::payoffAtExpiry
bool payoffAtExpiry() const
Definition:
exercise.hpp:62
QuantLib::EarlyExercise::payoffAtExpiry_
bool payoffAtExpiry_
Definition:
exercise.hpp:64
QuantLib::EarlyExercise::EarlyExercise
EarlyExercise(Type type, bool payoffAtExpiry=false)
Definition:
exercise.hpp:59
QuantLib::EuropeanExercise
European exercise.
Definition:
exercise.hpp:96
QuantLib::Exercise
Base exercise class.
Definition:
exercise.hpp:35
QuantLib::Exercise::Type
Type
Definition:
exercise.hpp:37
QuantLib::Exercise::European
@ European
Definition:
exercise.hpp:38
QuantLib::Exercise::American
@ American
Definition:
exercise.hpp:38
QuantLib::Exercise::Bermudan
@ Bermudan
Definition:
exercise.hpp:38
QuantLib::Exercise::dates_
std::vector< Date > dates_
Definition:
exercise.hpp:51
QuantLib::Exercise::date
Date date(Size index) const
Definition:
exercise.hpp:45
QuantLib::Exercise::dates
const std::vector< Date > & dates() const
Returns all exercise dates.
Definition:
exercise.hpp:48
QuantLib::Exercise::dateAt
Date dateAt(Size index) const
Definition:
exercise.hpp:46
QuantLib::Exercise::~Exercise
virtual ~Exercise()=default
QuantLib::Exercise::lastDate
Date lastDate() const
Definition:
exercise.cpp:28
QuantLib::Exercise::type
Type type() const
Definition:
exercise.hpp:44
QuantLib::Exercise::Exercise
Exercise(Type type)
Definition:
exercise.hpp:41
QuantLib::Exercise::type_
Type type_
Definition:
exercise.hpp:52
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
QuantLib
Definition:
any.hpp:35
Generated by
Doxygen
1.9.5