Coverage Report

Created: 2025-12-08 06:13

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/instruments/quantovanillaoption.cpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2002, 2003 Ferdinando Ametrano
5
 Copyright (C) 2007 StatPro Italia srl
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <https://www.quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
#include <ql/instruments/quantovanillaoption.hpp>
22
23
namespace QuantLib {
24
25
    QuantoVanillaOption::QuantoVanillaOption(
26
                   const ext::shared_ptr<StrikedTypePayoff>& payoff,
27
                   const ext::shared_ptr<Exercise>& exercise)
28
0
    : OneAssetOption(payoff, exercise) {}
Unexecuted instantiation: QuantLib::QuantoVanillaOption::QuantoVanillaOption(boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
Unexecuted instantiation: QuantLib::QuantoVanillaOption::QuantoVanillaOption(boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
29
30
0
    Real QuantoVanillaOption::qvega() const {
31
0
        calculate();
32
0
        QL_REQUIRE(qvega_ != Null<Real>(),
33
0
                   "exchange rate vega calculation failed");
34
0
        return qvega_;
35
0
    }
36
37
0
    Real QuantoVanillaOption::qrho() const {
38
0
        calculate();
39
0
        QL_REQUIRE(qrho_ != Null<Real>(),
40
0
                   "foreign interest rate rho calculation failed");
41
0
        return qrho_;
42
0
    }
43
44
0
    Real QuantoVanillaOption::qlambda() const {
45
0
        calculate();
46
0
        QL_REQUIRE(qlambda_ != Null<Real>(),
47
0
                   "quanto correlation sensitivity calculation failed");
48
0
        return qlambda_;
49
0
    }
50
51
0
    void QuantoVanillaOption::setupExpired() const {
52
0
        OneAssetOption::setupExpired();
53
0
        qvega_ = qrho_ = qlambda_ = 0.0;
54
0
    }
55
56
    void QuantoVanillaOption::fetchResults(
57
0
                                      const PricingEngine::results* r) const {
58
0
        OneAssetOption::fetchResults(r);
59
0
        const auto* quantoResults = dynamic_cast<const QuantoVanillaOption::results*>(r);
60
0
        QL_ENSURE(quantoResults != nullptr, "no quanto results returned from pricing engine");
61
0
        qrho_    = quantoResults->qrho;
62
0
        qvega_   = quantoResults->qvega;
63
0
        qlambda_ = quantoResults->qlambda;
64
0
    }
65
66
}
67