/src/quantlib/ql/pricingengines/forward/mcforwardeuropeanhestonengine.cpp
Line | Count | Source |
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 | | <https://www.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/mcforwardeuropeanhestonengine.hpp> |
17 | | |
18 | | namespace QuantLib { |
19 | | |
20 | | ForwardEuropeanHestonPathPricer::ForwardEuropeanHestonPathPricer( |
21 | | Option::Type type, |
22 | | Real moneyness, |
23 | | Size resetIndex, |
24 | | DiscountFactor discount) |
25 | 0 | : type_(type), moneyness_(moneyness), resetIndex_(resetIndex), |
26 | 0 | discount_(discount) |
27 | 0 | { |
28 | 0 | QL_REQUIRE(moneyness>=0.0, |
29 | 0 | "moneyness less than zero not allowed"); |
30 | 0 | } |
31 | | |
32 | 0 | Real ForwardEuropeanHestonPathPricer::operator()(const MultiPath& multiPath) const { |
33 | 0 | const Path& path = multiPath[0]; |
34 | 0 | const Size n = multiPath.pathSize(); |
35 | 0 | QL_REQUIRE(n>0, "the path cannot be empty"); |
36 | | |
37 | 0 | const Real resetLevel = path[resetIndex_]; |
38 | 0 | const Real strike = resetLevel * moneyness_; |
39 | 0 | const PlainVanillaPayoff payoff = PlainVanillaPayoff(type_, strike); |
40 | |
|
41 | 0 | return payoff(path.back()) * discount_; |
42 | 0 | } |
43 | | |
44 | | } |