/src/quantlib/ql/pricingengines/americanpayoffatexpiry.hpp
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) 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 | | <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 | | /*! \file americanpayoffatexpiry.hpp |
21 | | \brief Analytical formulae for american exercise with payoff at expiry |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_americanpayoffatexpiry_h |
25 | | #define quantlib_americanpayoffatexpiry_h |
26 | | |
27 | | #include <ql/instruments/payoffs.hpp> |
28 | | |
29 | | namespace QuantLib { |
30 | | |
31 | | //! Analytic formula for American exercise payoff at-expiry options |
32 | | /*! \todo calculate greeks */ |
33 | | class AmericanPayoffAtExpiry { |
34 | | public: |
35 | | AmericanPayoffAtExpiry( |
36 | | Real spot, |
37 | | DiscountFactor discount, |
38 | | DiscountFactor dividendDiscount, |
39 | | Real variance, |
40 | | const ext::shared_ptr<StrikedTypePayoff>& payoff, |
41 | | bool knock_in = true); |
42 | | Real value() const; |
43 | | private: |
44 | | Real spot_; |
45 | | DiscountFactor discount_, dividendDiscount_; |
46 | | Real variance_; |
47 | | |
48 | | Real forward_; |
49 | | Volatility stdDev_; |
50 | | |
51 | | Real strike_, K_; |
52 | | |
53 | | Real mu_, log_H_S_; |
54 | | |
55 | | Real D1_, D2_, cum_d1_, cum_d2_, n_d1_, n_d2_; |
56 | | |
57 | | bool inTheMoney_; |
58 | | Real Y_, X_; |
59 | | bool knock_in_; |
60 | | }; |
61 | | |
62 | | |
63 | | // inline definitions |
64 | | |
65 | 0 | inline Real AmericanPayoffAtExpiry::value() const { |
66 | 0 | return discount_ * K_ * (X_ * cum_d1_ + Y_ * cum_d2_); |
67 | 0 | } |
68 | | |
69 | | } |
70 | | |
71 | | |
72 | | #endif |