Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/pricingengines/asian/turnbullwakemanasianengine.hpp
Line
Count
Source (jump to first uncovered line)
1
/*
2
 Copyright (C) 2021 Skandinaviska Enskilda Banken AB (publ)
3
4
 This file is part of QuantLib, a free-software/open-source library
5
 for financial quantitative analysts and developers - http://quantlib.org/
6
7
 QuantLib is free software: you can redistribute it and/or modify it
8
 under the terms of the QuantLib license.  You should have received a
9
 copy of the license along with this program; if not, please email
10
 <quantlib-dev@lists.sf.net>. The license is also available online at
11
 <https://www.quantlib.org/license.shtml>.
12
13
 This program is distributed in the hope that it will be useful, but WITHOUT
14
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
15
 FOR A PARTICULAR PURPOSE.  See the license for more details.
16
*/
17
18
/*! \file ql/pricingengines/asian/turnbullwakemanasianengine.hpp
19
    \brief Turnbull Wakeman moment-matching Asian option Engine
20
    \ingroup asianengines
21
*/
22
23
#ifndef quantlib_turnbull_wakeman_asian_engine_hpp
24
#define quantlib_turnbull_wakeman_asian_engine_hpp
25
26
#include <ql/instruments/asianoption.hpp>
27
#include <ql/processes/blackscholesprocess.hpp>
28
#include <utility>
29
30
namespace QuantLib {
31
32
    /*! Turnbull Wakeman two moment-matching Asian option Engine
33
        Analytical pricing based on the two-moment Turnbull-Wakeman
34
        approximation.
35
        References: "Commodity Option Pricing", Iain Clark, Wiley, section 2.7.4.
36
                    "Option Pricing Formulas, Second Edition", E.G. Haug, 2006, pp. 192-202.
37
                    Some parts of the implementation were modeled after calculations from the
38
                    CommodityAveragePriceOptionAnalyticalEngine class in Open Source Risk Engine
39
                    (https://github.com/OpenSourceRisk/Engine).
40
41
        \test
42
        - the correctness of the returned value is tested by reproducing
43
          results in literature with flat as well as upward and downward
44
          sloping volatility term structures.
45
        - the pricing of trades with guaranteed exercise/OTM is also tested.
46
    */
47
    class TurnbullWakemanAsianEngine : public DiscreteAveragingAsianOption::engine {
48
      public:
49
        explicit TurnbullWakemanAsianEngine(ext::shared_ptr<GeneralizedBlackScholesProcess> process)
50
0
        : process_(std::move(process)) {
51
0
            registerWith(process_);
52
0
        }
53
54
        void calculate() const override;
55
56
      private:
57
        ext::shared_ptr<GeneralizedBlackScholesProcess> process_;
58
    };
59
60
}
61
62
#endif