QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
mcforwardeuropeanhestonengine.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
17
18namespace QuantLib {
19
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
33 const Path& path = multiPath[0];
34 const Size n = multiPath.pathSize();
35 QL_REQUIRE(n>0, "the path cannot be empty");
36
37 const Real resetLevel = path[resetIndex_];
38 const Real strike = resetLevel * moneyness_;
40
41 return payoff(path.back()) * discount_;
42 }
43
44}
ForwardEuropeanHestonPathPricer(Option::Type type, Real moneyness, Size resetIndex, DiscountFactor discount)
Real operator()(const MultiPath &multiPath) const override
Correlated multiple asset paths.
Definition: multipath.hpp:39
Size pathSize() const
Definition: multipath.hpp:48
single-factor random walk
Definition: path.hpp:40
Real back() const
final asset value
Definition: path.hpp:130
Plain-vanilla payoff.
Definition: payoffs.hpp:105
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
std::size_t Size
size of a container
Definition: types.hpp:58
ext::shared_ptr< QuantLib::Payoff > payoff
Monte Carlo engine for forward-starting strike-reset European options using Heston-like process.
Definition: any.hpp:35