Coverage Report

Created: 2025-11-04 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/pricingengines/forward/mcforwardeuropeanbsengine.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/mcforwardeuropeanbsengine.hpp>
17
18
namespace QuantLib {
19
20
    ForwardEuropeanBSPathPricer::ForwardEuropeanBSPathPricer(
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 ForwardEuropeanBSPathPricer::operator()(const Path& path) const {
33
0
        Size n = path.length() - 1;
34
0
        QL_REQUIRE(n>0, "the path cannot be empty");
35
36
0
        const Real resetLevel = path[resetIndex_];
37
0
        const Real strike = resetLevel * moneyness_;
38
0
        const PlainVanillaPayoff payoff = PlainVanillaPayoff(type_, strike);
39
40
0
        return payoff(path.back()) * discount_;
41
0
    }
42
43
}