Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/instruments/forwardvanillaoption.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) 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/forwardvanillaoption.hpp>
22
23
namespace QuantLib {
24
25
    ForwardVanillaOption::ForwardVanillaOption(
26
                           Real moneyness,
27
                           const Date& resetDate,
28
                           const ext::shared_ptr<StrikedTypePayoff>& payoff,
29
                           const ext::shared_ptr<Exercise>& exercise)
30
0
    : OneAssetOption(payoff, exercise),
31
0
      moneyness_(moneyness), resetDate_(resetDate) {}
Unexecuted instantiation: QuantLib::ForwardVanillaOption::ForwardVanillaOption(double, QuantLib::Date const&, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
Unexecuted instantiation: QuantLib::ForwardVanillaOption::ForwardVanillaOption(double, QuantLib::Date const&, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
32
33
    void ForwardVanillaOption::setupArguments(
34
0
                                       PricingEngine::arguments* args) const {
35
0
        OneAssetOption::setupArguments(args);
36
0
        auto* arguments = dynamic_cast<ForwardVanillaOption::arguments*>(args);
37
0
        QL_REQUIRE(arguments != nullptr, "wrong argument type");
38
39
0
        arguments->moneyness = moneyness_;
40
0
        arguments->resetDate = resetDate_;
41
42
0
    }
43
44
    void ForwardVanillaOption::fetchResults(
45
0
                                      const PricingEngine::results* r) const {
46
0
        OneAssetOption::fetchResults(r);
47
0
        const auto* results = dynamic_cast<const ForwardVanillaOption::results*>(r);
48
0
        QL_ENSURE(results != nullptr, "no results returned from pricing engine");
49
0
        delta_       = results->delta;
50
0
        gamma_       = results->gamma;
51
0
        theta_       = results->theta;
52
0
        vega_        = results->vega;
53
0
        rho_         = results->rho;
54
0
        dividendRho_ = results->dividendRho;
55
0
    }
56
57
}
58