Coverage Report

Created: 2025-11-04 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/instruments/oneassetoption.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2000, 2001, 2002, 2003 RiskMap srl
5
 Copyright (C) 2003 Ferdinando Ametrano
6
 Copyright (C) 2007 StatPro Italia srl
7
8
 This file is part of QuantLib, a free-software/open-source library
9
 for financial quantitative analysts and developers - http://quantlib.org/
10
11
 QuantLib is free software: you can redistribute it and/or modify it
12
 under the terms of the QuantLib license.  You should have received a
13
 copy of the license along with this program; if not, please email
14
 <quantlib-dev@lists.sf.net>. The license is also available online at
15
 <https://www.quantlib.org/license.shtml>.
16
17
 This program is distributed in the hope that it will be useful, but WITHOUT
18
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
19
 FOR A PARTICULAR PURPOSE.  See the license for more details.
20
*/
21
22
/*! \file oneassetoption.hpp
23
    \brief Option on a single asset
24
*/
25
26
#ifndef quantlib_oneasset_option_hpp
27
#define quantlib_oneasset_option_hpp
28
29
#include <ql/option.hpp>
30
31
namespace QuantLib {
32
33
    //! Base class for options on a single asset
34
    class OneAssetOption : public Option {
35
      public:
36
        class engine;
37
        class results;
38
        OneAssetOption(const ext::shared_ptr<Payoff>&,
39
                       const ext::shared_ptr<Exercise>&);
40
        //! \name Instrument interface
41
        //@{
42
        bool isExpired() const override;
43
        //@}
44
        //! \name greeks
45
        //@{
46
        Real delta() const;
47
        Real deltaForward() const;
48
        Real elasticity() const;
49
        Real gamma() const;
50
        Real theta() const;
51
        Real thetaPerDay() const;
52
        Real vega() const;
53
        Real rho() const;
54
        Real dividendRho() const;
55
        Real strikeSensitivity() const;
56
        Real itmCashProbability() const;
57
        //@}
58
        void fetchResults(const PricingEngine::results*) const override;
59
60
      protected:
61
        void setupExpired() const override;
62
        // results
63
        mutable Real delta_, deltaForward_, elasticity_, gamma_, theta_,
64
            thetaPerDay_, vega_, rho_, dividendRho_, strikeSensitivity_,
65
            itmCashProbability_;
66
    };
67
68
    //! %Results from single-asset option calculation
69
    class OneAssetOption::results : public Instrument::results,
70
                                    public Greeks,
71
                                    public MoreGreeks {
72
      public:
73
0
        void reset() override {
74
0
            Instrument::results::reset();
75
0
            Greeks::reset();
76
0
            MoreGreeks::reset();
77
0
        }
78
    };
79
80
    class OneAssetOption::engine :
81
        public GenericEngine<OneAssetOption::arguments,
82
                             OneAssetOption::results> {};
83
84
}
85
86
87
#endif
88