QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mcforwardeuropeanbsengine.cpp
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
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 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}
ForwardEuropeanBSPathPricer(Option::Type type, Real moneyness, Size resetIndex, DiscountFactor discount)
Real operator()(const Path &path) const override
single-factor random walk
Definition: path.hpp:40
Size length() const
Definition: path.hpp:94
Real back() const
final asset value
Definition: path.hpp:130
Plain-vanilla payoff.
Definition: payoffs.hpp:105
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
Definition: any.hpp:35