QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
exercise.hpp
Go to the documentation of this file.
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
22/*! \file exercise.hpp
23 \brief Option exercise classes and payoff function
24*/
25
26#ifndef quantlib_exercise_type_h
27#define quantlib_exercise_type_h
28
29#include <ql/time/date.hpp>
30#include <vector>
31
32namespace QuantLib {
33
34 //! Base exercise class
35 class Exercise {
36 public:
37 enum Type {
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); }
47 //! Returns all exercise dates
48 const std::vector<Date>& dates() const { return dates_; }
49 Date lastDate() const;
50 protected:
51 std::vector<Date> dates_;
53 };
54
55 //! Early-exercise base class
56 /*! The payoff can be at exercise (the default) or at expiry */
57 class EarlyExercise : public Exercise {
58 public:
60 bool payoffAtExpiry = false)
62 bool payoffAtExpiry() const { return payoffAtExpiry_; }
63 private:
65 };
66
67 //! American exercise
68 /*! An American option can be exercised at any time between two
69 predefined dates; the first date might be omitted, in which
70 case the option can be exercised at any time before the expiry.
71
72 \todo check that everywhere the American condition is applied
73 from earliestDate and not earlier
74 */
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
84 //! Bermudan exercise
85 /*! A Bermudan option can only be exercised at a set of fixed dates.
86 */
88 public:
89 BermudanExercise(const std::vector<Date>& dates,
90 bool payoffAtExpiry = false);
91 };
92
93 //! European exercise
94 /*! A European option can only be exercised at one (expiry) date.
95 */
96 class EuropeanExercise : public Exercise {
97 public:
99 };
100
101}
102
103
104#endif
American exercise.
Definition: exercise.hpp:75
Bermudan exercise.
Definition: exercise.hpp:87
Concrete date class.
Definition: date.hpp:125
Early-exercise base class.
Definition: exercise.hpp:57
bool payoffAtExpiry() const
Definition: exercise.hpp:62
EarlyExercise(Type type, bool payoffAtExpiry=false)
Definition: exercise.hpp:59
European exercise.
Definition: exercise.hpp:96
Base exercise class.
Definition: exercise.hpp:35
std::vector< Date > dates_
Definition: exercise.hpp:51
Date date(Size index) const
Definition: exercise.hpp:45
const std::vector< Date > & dates() const
Returns all exercise dates.
Definition: exercise.hpp:48
Date dateAt(Size index) const
Definition: exercise.hpp:46
virtual ~Exercise()=default
Date lastDate() const
Definition: exercise.cpp:28
Type type() const
Definition: exercise.hpp:44
Exercise(Type type)
Definition: exercise.hpp:41
date- and time-related classes, typedefs and enumerations
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35