Coverage Report

Created: 2025-12-08 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/experimental/exoticoptions/mceverestengine.cpp
Line
Count
Source
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
 <https://www.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
22
namespace QuantLib {
23
24
    EverestMultiPathPricer::EverestMultiPathPricer(Real notional,
25
                                                   Real guarantee,
26
                                                   DiscountFactor discount)
27
0
    : notional_(notional), guarantee_(guarantee), discount_(discount) {}
28
29
0
    Real EverestMultiPathPricer::operator()(const MultiPath& multiPath) const {
30
31
0
        Size n = multiPath.pathSize();
32
0
        QL_REQUIRE(n>0, "the path cannot be empty");
33
34
0
        Size numAssets = multiPath.assetNumber();
35
0
        QL_REQUIRE(numAssets>0, "there must be some paths");
36
37
        // We search the yield min
38
0
        Real minYield = multiPath[0].back() / multiPath[0].front() - 1.0;
39
0
        for (Size j=1; j<numAssets; ++j) {
40
0
            Rate yield = multiPath[j].back() / multiPath[j].front() - 1.0;
41
0
            minYield = std::min(minYield, yield);
42
0
        }
43
0
        return (1.0 + minYield + guarantee_) * notional_ * discount_;
44
0
    }
45
46
}
47