Coverage Report

Created: 2025-11-04 06:12

next uncovered line (L), next uncovered region (R), next uncovered branch (B)
/src/quantlib/ql/pricingengines/americanpayoffathit.hpp
Line
Count
Source
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2004 Ferdinando Ametrano
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
 <https://www.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
/*! \file americanpayoffathit.hpp
21
    \brief Analytical formulae for american exercise with payoff at hit
22
*/
23
24
#ifndef quantlib_americanpayoffathit_h
25
#define quantlib_americanpayoffathit_h
26
27
#include <ql/instruments/payoffs.hpp>
28
29
namespace QuantLib {
30
31
    //! Analytic formula for American exercise payoff at-hit options
32
    /*! \todo calculate greeks */
33
    class AmericanPayoffAtHit {
34
      public:
35
        AmericanPayoffAtHit(
36
                          Real spot,
37
                          DiscountFactor discount,
38
                          DiscountFactor dividendDiscount,
39
                          Real variance,
40
                          const ext::shared_ptr<StrikedTypePayoff>& payoff);
41
        Real value() const;
42
        Real delta() const;
43
        Real gamma() const;
44
        Real rho(Time maturity) const;
45
      private:
46
        Real spot_;
47
        DiscountFactor discount_, dividendDiscount_;
48
        Real variance_;
49
        Volatility stdDev_;
50
51
        Real strike_, K_, DKDstrike_;
52
53
        Real mu_, lambda_, muPlusLambda_, muMinusLambda_, log_H_S_;
54
55
        Real D1_, D2_, cum_d1_, cum_d2_;
56
57
        Real alpha_, beta_, DalphaDd1_, DbetaDd2_;
58
59
        bool inTheMoney_;
60
        Real forward_, X_, DXDstrike_;
61
    };
62
63
64
    // inline definitions
65
66
0
    inline Real AmericanPayoffAtHit::value() const {
67
0
        return K_ * (forward_ * alpha_ + X_ * beta_);
68
0
    }
69
70
}
71
72
73
#endif