QuantLib
: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
ql
pricingengines
forward
mcforwardeuropeanbsengine.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
This file is part of QuantLib, a free-software/open-source library
5
for financial quantitative analysts and developers - http://quantlib.org/
6
QuantLib is free software: you can redistribute it and/or modify it
7
under the terms of the QuantLib license. You should have received a
8
copy of the license along with this program; if not, please email
9
<quantlib-dev@lists.sf.net>. The license is also available online at
10
<http://quantlib.org/license.shtml>.
11
This program is distributed in the hope that it will be useful, but WITHOUT
12
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13
FOR A PARTICULAR PURPOSE. See the license for more details.
14
*/
15
16
#include <
ql/pricingengines/forward/mcforwardeuropeanbsengine.hpp
>
17
18
namespace
QuantLib
{
19
20
ForwardEuropeanBSPathPricer::ForwardEuropeanBSPathPricer
(
21
Option::Type
type,
22
Real
moneyness,
23
Size
resetIndex,
24
DiscountFactor
discount)
25
: type_(type), moneyness_(moneyness), resetIndex_(resetIndex),
26
discount_(discount)
27
{
28
QL_REQUIRE
(moneyness>=0.0,
29
"moneyness less than zero not allowed"
);
30
}
31
32
Real
ForwardEuropeanBSPathPricer::operator()
(
const
Path
& path)
const
{
33
Size
n
= path.
length
() - 1;
34
QL_REQUIRE
(
n
>0,
"the path cannot be empty"
);
35
36
const
Real
resetLevel = path[
resetIndex_
];
37
const
Real
strike = resetLevel *
moneyness_
;
38
const
PlainVanillaPayoff
payoff
=
PlainVanillaPayoff
(
type_
, strike);
39
40
return
payoff
(path.
back
()) *
discount_
;
41
}
42
43
}
n
Size n
Definition:
andreasenhugevolatilityinterpl.cpp:47
QuantLib::ForwardEuropeanBSPathPricer::discount_
DiscountFactor discount_
Definition:
mcforwardeuropeanbsengine.hpp:101
QuantLib::ForwardEuropeanBSPathPricer::moneyness_
Real moneyness_
Definition:
mcforwardeuropeanbsengine.hpp:99
QuantLib::ForwardEuropeanBSPathPricer::resetIndex_
Size resetIndex_
Definition:
mcforwardeuropeanbsengine.hpp:100
QuantLib::ForwardEuropeanBSPathPricer::ForwardEuropeanBSPathPricer
ForwardEuropeanBSPathPricer(Option::Type type, Real moneyness, Size resetIndex, DiscountFactor discount)
Definition:
mcforwardeuropeanbsengine.cpp:20
QuantLib::ForwardEuropeanBSPathPricer::type_
Option::Type type_
Definition:
mcforwardeuropeanbsengine.hpp:98
QuantLib::ForwardEuropeanBSPathPricer::operator()
Real operator()(const Path &path) const override
Definition:
mcforwardeuropeanbsengine.cpp:32
QuantLib::Option::Type
Type
Definition:
option.hpp:39
QuantLib::Path
single-factor random walk
Definition:
path.hpp:40
QuantLib::Path::length
Size length() const
Definition:
path.hpp:94
QuantLib::Path::back
Real back() const
final asset value
Definition:
path.hpp:130
QuantLib::PlainVanillaPayoff
Plain-vanilla payoff.
Definition:
payoffs.hpp:105
QL_REQUIRE
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition:
errors.hpp:117
QuantLib::Real
QL_REAL Real
real number
Definition:
types.hpp:50
QuantLib::DiscountFactor
Real DiscountFactor
discount factor between dates
Definition:
types.hpp:66
QuantLib::Size
std::size_t Size
size of a container
Definition:
types.hpp:58
payoff
ext::shared_ptr< QuantLib::Payoff > payoff
Definition:
integralhestonvarianceoptionengine.cpp:350
mcforwardeuropeanbsengine.hpp
Monte Carlo engine for forward-starting strike-reset European options using BS process.
QuantLib
Definition:
any.hpp:35
Generated by
Doxygen
1.9.5