Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/experimental/barrieroption/quantodoublebarrieroption.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2015 Thema Consulting SA
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/barrieroption/quantodoublebarrieroption.hpp>
21
22
namespace QuantLib {
23
24
    QuantoDoubleBarrierOption::QuantoDoubleBarrierOption(
25
                        DoubleBarrier::Type barrierType,
26
                        Real barrier_lo,
27
                        Real barrier_hi,
28
                        Real rebate,
29
                        const ext::shared_ptr<StrikedTypePayoff>& payoff,
30
                        const ext::shared_ptr<Exercise>& exercise)
31
0
    : DoubleBarrierOption(barrierType, barrier_lo, barrier_hi, rebate, payoff, exercise) {}
Unexecuted instantiation: QuantLib::QuantoDoubleBarrierOption::QuantoDoubleBarrierOption(QuantLib::DoubleBarrier::Type, double, double, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
Unexecuted instantiation: QuantLib::QuantoDoubleBarrierOption::QuantoDoubleBarrierOption(QuantLib::DoubleBarrier::Type, double, double, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
32
33
0
    Real QuantoDoubleBarrierOption::qvega() const {
34
0
        calculate();
35
0
        QL_REQUIRE(qvega_ != Null<Real>(),
36
0
                   "exchange rate vega calculation failed");
37
0
        return qvega_;
38
0
    }
39
40
0
    Real QuantoDoubleBarrierOption::qrho() const {
41
0
        calculate();
42
0
        QL_REQUIRE(qrho_ != Null<Real>(),
43
0
                   "foreign interest rate rho calculation failed");
44
0
        return qrho_;
45
0
    }
46
47
0
    Real QuantoDoubleBarrierOption::qlambda() const {
48
0
        calculate();
49
0
        QL_REQUIRE(qlambda_ != Null<Real>(),
50
0
                   "quanto correlation sensitivity calculation failed");
51
0
        return qlambda_;
52
0
    }
53
54
0
    void QuantoDoubleBarrierOption::setupExpired() const {
55
0
        DoubleBarrierOption::setupExpired();
56
0
        qvega_ = qrho_ = qlambda_ = 0.0;
57
0
    }
58
59
    void QuantoDoubleBarrierOption::fetchResults(
60
0
                                      const PricingEngine::results* r) const {
61
0
        DoubleBarrierOption::fetchResults(r);
62
0
        const auto* quantoResults = dynamic_cast<const QuantoDoubleBarrierOption::results*>(r);
63
0
        QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine");
64
0
        qrho_    = quantoResults->qrho;
65
0
        qvega_   = quantoResults->qvega;
66
0
        qlambda_ = quantoResults->qlambda;
67
0
    }
68
69
}
70