/src/quantlib/ql/experimental/callablebonds/blackcallablebondengine.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) 2008 Allen Kuo |
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 blackcallablebondengine.hpp |
21 | | \brief Black-formula callable bond engines |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_black_callable_bond_engine_hpp |
25 | | #define quantlib_black_callable_bond_engine_hpp |
26 | | |
27 | | #include <ql/experimental/callablebonds/callablebond.hpp> |
28 | | #include <ql/experimental/callablebonds/callablebondvolstructure.hpp> |
29 | | |
30 | | namespace QuantLib { |
31 | | |
32 | | //! Black-formula callable fixed rate bond engine |
33 | | /*! Callable fixed rate bond Black engine. The embedded (European) |
34 | | option follows the Black "European bond option" treatment in |
35 | | Hull, Fourth Edition, Chapter 20. |
36 | | |
37 | | \todo set additionalResults (e.g. vega, fairStrike, etc.) |
38 | | |
39 | | \warning This class has yet to be tested |
40 | | |
41 | | \ingroup bondengines |
42 | | */ |
43 | | class BlackCallableFixedRateBondEngine |
44 | | : public CallableFixedRateBond::engine { |
45 | | public: |
46 | | //! volatility is the quoted fwd yield volatility, not price vol |
47 | | BlackCallableFixedRateBondEngine(const Handle<Quote>& fwdYieldVol, |
48 | | Handle<YieldTermStructure> discountCurve); |
49 | | //! volatility is the quoted fwd yield volatility, not price vol |
50 | | BlackCallableFixedRateBondEngine(Handle<CallableBondVolatilityStructure> yieldVolStructure, |
51 | | Handle<YieldTermStructure> discountCurve); |
52 | | void calculate() const override; |
53 | | |
54 | | private: |
55 | | Handle<CallableBondVolatilityStructure> volatility_; |
56 | | Handle<YieldTermStructure> discountCurve_; |
57 | | // present value of all coupons paid during the life of option |
58 | | Real spotIncome() const; |
59 | | // converts the yield volatility into a forward price volatility |
60 | | Volatility forwardPriceVolatility() const; |
61 | | }; |
62 | | |
63 | | |
64 | | //! Black-formula callable zero coupon bond engine |
65 | | /*! Callable zero coupon bond, where the embedded (European) |
66 | | option price is assumed to obey the Black formula. Follows |
67 | | "European bond option" treatment in Hull, Fourth Edition, |
68 | | Chapter 20. |
69 | | |
70 | | \warning This class has yet to be tested. |
71 | | |
72 | | \ingroup bondengines |
73 | | */ |
74 | | class BlackCallableZeroCouponBondEngine : |
75 | | public BlackCallableFixedRateBondEngine { |
76 | | public: |
77 | | //! volatility is the quoted fwd yield volatility, not price vol |
78 | | BlackCallableZeroCouponBondEngine( |
79 | | const Handle<Quote>& fwdYieldVol, |
80 | | const Handle<YieldTermStructure>& discountCurve) |
81 | 0 | : BlackCallableFixedRateBondEngine(fwdYieldVol, discountCurve) {} |
82 | | |
83 | | //! volatility is the quoted fwd yield volatility, not price vol |
84 | | BlackCallableZeroCouponBondEngine( |
85 | | const Handle<CallableBondVolatilityStructure>& yieldVolStructure, |
86 | | const Handle<YieldTermStructure>& discountCurve) |
87 | 0 | : BlackCallableFixedRateBondEngine(yieldVolStructure, discountCurve) {} |
88 | | }; |
89 | | |
90 | | } |
91 | | |
92 | | |
93 | | #endif |