/src/quantlib/ql/experimental/callablebonds/treecallablebondengine.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 treecallablebondengine.hpp |
21 | | \brief Numerical lattice engines for callable/puttable bonds |
22 | | */ |
23 | | |
24 | | #ifndef quantlib_tree_callable_bond_engine_hpp |
25 | | #define quantlib_tree_callable_bond_engine_hpp |
26 | | |
27 | | #include <ql/experimental/callablebonds/callablebond.hpp> |
28 | | #include <ql/pricingengines/latticeshortratemodelengine.hpp> |
29 | | |
30 | | namespace QuantLib { |
31 | | |
32 | | //! Numerical lattice engine for callable fixed rate bonds |
33 | | /*! \ingroup bondengines */ |
34 | | class TreeCallableFixedRateBondEngine |
35 | | : public LatticeShortRateModelEngine<CallableBond::arguments, |
36 | | CallableBond::results> { |
37 | | public: |
38 | | /*! \name Constructors |
39 | | \note the term structure is only needed when the short-rate |
40 | | model cannot provide one itself. |
41 | | */ |
42 | | //@{ |
43 | | TreeCallableFixedRateBondEngine( |
44 | | const ext::shared_ptr<ShortRateModel>&, |
45 | | Size timeSteps, |
46 | | Handle<YieldTermStructure> termStructure = Handle<YieldTermStructure>()); |
47 | | TreeCallableFixedRateBondEngine( |
48 | | const ext::shared_ptr<ShortRateModel>&, |
49 | | const TimeGrid& timeGrid, |
50 | | Handle<YieldTermStructure> termStructure = Handle<YieldTermStructure>()); |
51 | | //@} |
52 | | void calculate() const override; |
53 | | |
54 | | private: |
55 | | void calculateWithSpread(Spread s) const; |
56 | | Handle<YieldTermStructure> termStructure_; |
57 | | }; |
58 | | |
59 | | //! Numerical lattice engine for callable zero coupon bonds |
60 | | /*! \ingroup bondengines */ |
61 | | class TreeCallableZeroCouponBondEngine |
62 | | : public TreeCallableFixedRateBondEngine { |
63 | | |
64 | | public: |
65 | | TreeCallableZeroCouponBondEngine( |
66 | | const ext::shared_ptr<ShortRateModel>& model, |
67 | | const Size timeSteps, |
68 | | const Handle<YieldTermStructure>& termStructure = |
69 | | Handle<YieldTermStructure>()) |
70 | 0 | : TreeCallableFixedRateBondEngine(model, timeSteps, termStructure) {} |
71 | | |
72 | | TreeCallableZeroCouponBondEngine( |
73 | | const ext::shared_ptr<ShortRateModel>& model, |
74 | | const TimeGrid& timeGrid, |
75 | | const Handle<YieldTermStructure>& termStructure = |
76 | | Handle<YieldTermStructure>()) |
77 | 0 | : TreeCallableFixedRateBondEngine(model, timeGrid, termStructure) {} |
78 | | }; |
79 | | |
80 | | } |
81 | | |
82 | | #endif |