QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
discretizedasset.cpp
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) 2004 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
21
#include <
ql/discretizedasset.hpp
>
22
23
namespace
QuantLib
{
24
25
void
DiscretizedOption::postAdjustValuesImpl
() {
26
/* In the real world, with time flowing forward, first
27
any payment is settled and only after options can be
28
exercised. Here, with time flowing backward, options
29
must be exercised before performing the adjustment.
30
*/
31
underlying_
->partialRollback(
time
());
32
underlying_
->preAdjustValues();
33
Size
i;
34
switch
(
exerciseType_
) {
35
case
Exercise::American
:
36
if
(
time_
>=
exerciseTimes_
[0] &&
time_
<=
exerciseTimes_
[1])
37
applyExerciseCondition
();
38
break
;
39
case
Exercise::Bermudan
:
40
case
Exercise::European
:
41
for
(i=0; i<
exerciseTimes_
.size(); i++) {
42
Time
t
=
exerciseTimes_
[i];
43
if
(
t
>= 0.0 &&
isOnTime
(
t
))
44
applyExerciseCondition
();
45
}
46
break
;
47
default
:
48
QL_FAIL
(
"invalid exercise type"
);
49
}
50
underlying_
->postAdjustValues();
51
}
52
53
}
54
QuantLib::DiscretizedAsset::time
Time time() const
Definition:
discretizedasset.hpp:45
QuantLib::DiscretizedAsset::isOnTime
bool isOnTime(Time t) const
Definition:
discretizedasset.hpp:215
QuantLib::DiscretizedAsset::time_
Time time_
Definition:
discretizedasset.hpp:138
QuantLib::DiscretizedOption::postAdjustValuesImpl
void postAdjustValuesImpl() override
Definition:
discretizedasset.cpp:25
QuantLib::DiscretizedOption::exerciseTimes_
std::vector< Time > exerciseTimes_
Definition:
discretizedasset.hpp:175
QuantLib::DiscretizedOption::exerciseType_
Exercise::Type exerciseType_
Definition:
discretizedasset.hpp:174
QuantLib::DiscretizedOption::applyExerciseCondition
void applyExerciseCondition()
Definition:
discretizedasset.hpp:239
QuantLib::DiscretizedOption::underlying_
ext::shared_ptr< DiscretizedAsset > underlying_
Definition:
discretizedasset.hpp:173
QuantLib::Exercise::European
@ European
Definition:
exercise.hpp:38
QuantLib::Exercise::American
@ American
Definition:
exercise.hpp:38
QuantLib::Exercise::Bermudan
@ Bermudan
Definition:
exercise.hpp:38
t
const DefaultType & t
Definition:
defaultprobabilitykey.cpp:39
discretizedasset.hpp
Discretized asset classes.
QL_FAIL
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Definition:
errors.hpp:92
QuantLib::Time
Real Time
continuous quantity with 1-year units
Definition:
types.hpp:62
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