QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
mcpagodaengine.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/mcpagodaengine.hpp>
21
22namespace QuantLib {
23
25 DiscountFactor discount)
26 : discount_(discount), roof_(roof), fraction_(fraction) {}
27
29
30 Size numAssets = multiPath.assetNumber();
31 Size numSteps = multiPath.pathSize();
32
33 Real averagePerformance = 0.0;
34 for (Size i = 1; i < numSteps; i++) {
35 for (Size j = 0; j < numAssets; j++) {
36 averagePerformance +=
37 multiPath[j].front() *
38 (multiPath[j][i]/multiPath[j][i-1] - 1.0);
39 }
40 }
41 averagePerformance /= numAssets;
42
43 return discount_ * fraction_
44 * std::max<Real>(0.0, std::min(roof_, averagePerformance));
45 }
46
47}
48
Correlated multiple asset paths.
Definition: multipath.hpp:39
Size pathSize() const
Definition: multipath.hpp:48
Size assetNumber() const
Definition: multipath.hpp:47
PagodaMultiPathPricer(Real roof, Real fraction, DiscountFactor discount)
Real operator()(const MultiPath &multiPath) const override
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