QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mceverestengine.cpp
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2008 Master IMAFA - Polytech'Nice Sophia - Université de Nice Sophia Antipolis
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20#include <ql/experimental/exoticoptions/mceverestengine.hpp>
21
22namespace QuantLib {
23
25 Real guarantee,
26 DiscountFactor discount)
27 : notional_(notional), guarantee_(guarantee), discount_(discount) {}
28
30
31 Size n = multiPath.pathSize();
32 QL_REQUIRE(n>0, "the path cannot be empty");
33
34 Size numAssets = multiPath.assetNumber();
35 QL_REQUIRE(numAssets>0, "there must be some paths");
36
37 // We search the yield min
38 Real minYield = multiPath[0].back() / multiPath[0].front() - 1.0;
39 for (Size j=1; j<numAssets; ++j) {
40 Rate yield = multiPath[j].back() / multiPath[j].front() - 1.0;
41 minYield = std::min(minYield, yield);
42 }
43 return (1.0 + minYield + guarantee_) * notional_ * discount_;
44 }
45
46}
47
Real operator()(const MultiPath &multiPath) const override
EverestMultiPathPricer(Real notional, Rate guarantee, DiscountFactor discount)
Correlated multiple asset paths.
Definition: multipath.hpp:39
Size pathSize() const
Definition: multipath.hpp:48
Size assetNumber() const
Definition: multipath.hpp:47
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
Real Rate
interest rates
Definition: types.hpp:70
std::size_t Size
size of a container
Definition: types.hpp:58
Definition: any.hpp:35