Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/instruments/holderextensibleoption.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) 2014 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
 <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/instruments/holderextensibleoption.hpp>
21
#include <ql/exercise.hpp>
22
23
namespace QuantLib {
24
25
    HolderExtensibleOption::HolderExtensibleOption(
26
                           Option::Type type,
27
                           Real premium,
28
                           Date secondExpiryDate,
29
                           Real secondStrike,
30
                           const ext::shared_ptr<StrikedTypePayoff>& payoff,
31
                           const ext::shared_ptr<Exercise>& exercise)
32
0
    : OneAssetOption(payoff,exercise),
33
0
      premium_(premium),
34
0
      secondExpiryDate_(secondExpiryDate),
35
0
      secondStrike_(secondStrike) {}
Unexecuted instantiation: QuantLib::HolderExtensibleOption::HolderExtensibleOption(QuantLib::Option::Type, double, QuantLib::Date, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
Unexecuted instantiation: QuantLib::HolderExtensibleOption::HolderExtensibleOption(QuantLib::Option::Type, double, QuantLib::Date, double, boost::shared_ptr<QuantLib::StrikedTypePayoff> const&, boost::shared_ptr<QuantLib::Exercise> const&)
36
37
    void HolderExtensibleOption::setupArguments(
38
0
                                       PricingEngine::arguments* args) const {
39
0
        OneAssetOption::setupArguments(args);
40
0
        auto* moreArgs = dynamic_cast<HolderExtensibleOption::arguments*>(args);
41
0
        QL_REQUIRE(moreArgs != nullptr, "wrong argument type");
42
0
        moreArgs->premium = premium_;
43
0
        moreArgs->secondExpiryDate = secondExpiryDate_;
44
0
        moreArgs->secondStrike = secondStrike_;
45
0
    }
46
47
0
    void HolderExtensibleOption:: arguments::validate() const {
48
0
        OneAssetOption::arguments::validate();
49
0
        QL_REQUIRE(premium > 0,"negative premium not allowed");
50
0
        QL_REQUIRE(secondExpiryDate != Date() , "no extending date given");
51
0
        QL_REQUIRE(secondExpiryDate >= exercise->lastDate(),
52
0
                   "extended date is earlier than or equal to first maturity date");
53
0
    }
54
55
}