/src/quantlib/ql/pricingengines/inflation/inflationcapfloorengines.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) 2009 Chris Kenyon  | 
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 inflationcapfloorengines.hpp  | 
21  |  |     \brief Inflation cap/floor engines  | 
22  |  |  */  | 
23  |  |  | 
24  |  | #ifndef quantlib_pricers_inflation_capfloor_hpp  | 
25  |  | #define quantlib_pricers_inflation_capfloor_hpp  | 
26  |  |  | 
27  |  | #include <ql/instruments/inflationcapfloor.hpp>  | 
28  |  | #include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp>  | 
29  |  | #include <ql/option.hpp>  | 
30  |  |  | 
31  |  | namespace QuantLib { | 
32  |  |  | 
33  |  |     class Quote;  | 
34  |  |     class YoYOptionletVolatilitySurface;  | 
35  |  |     class YoYInflationIndex;  | 
36  |  |  | 
37  |  |     //! Base YoY inflation cap/floor engine  | 
38  |  |     /*! This class doesn't know yet what sort of vol it is.  The  | 
39  |  |         inflation index must be linked to a yoy inflation term  | 
40  |  |         structure.  | 
41  |  |  | 
42  |  |         \ingroup inflationcapfloorengines  | 
43  |  |     */  | 
44  |  |     class YoYInflationCapFloorEngine : public YoYInflationCapFloor::engine { | 
45  |  |       public:  | 
46  |  |         YoYInflationCapFloorEngine(ext::shared_ptr<YoYInflationIndex>,  | 
47  |  |                                    Handle<YoYOptionletVolatilitySurface> vol,  | 
48  |  |                                    Handle<YieldTermStructure> nominalTermStructure);  | 
49  |  |  | 
50  | 0  |         ext::shared_ptr<YoYInflationIndex> index() const { return index_;} | 
51  | 0  |         Handle<YoYOptionletVolatilitySurface> volatility() const { return volatility_; } | 
52  | 0  |         Handle<YieldTermStructure> nominalTermStructure() const { return nominalTermStructure_; } | 
53  |  |  | 
54  |  |         void setVolatility(const Handle<YoYOptionletVolatilitySurface>& vol);  | 
55  |  |  | 
56  |  |         void calculate() const override;  | 
57  |  |  | 
58  |  |       protected:  | 
59  |  |         //! descendents only need to implement this  | 
60  |  |         virtual Real optionletImpl(Option::Type type, Rate strike,  | 
61  |  |                                    Rate forward, Real stdDev,  | 
62  |  |                                    Real d) const = 0;  | 
63  |  |  | 
64  |  |         ext::shared_ptr<YoYInflationIndex> index_;  | 
65  |  |         Handle<YoYOptionletVolatilitySurface> volatility_;  | 
66  |  |         Handle<YieldTermStructure> nominalTermStructure_;  | 
67  |  |     };  | 
68  |  |  | 
69  |  |  | 
70  |  |  | 
71  |  |     //! Black-formula inflation cap/floor engine (standalone, i.e. no coupon pricer)  | 
72  |  |     class YoYInflationBlackCapFloorEngine  | 
73  |  |     : public YoYInflationCapFloorEngine { | 
74  |  |       public:  | 
75  |  |         YoYInflationBlackCapFloorEngine(const ext::shared_ptr<YoYInflationIndex>&,  | 
76  |  |                                         const Handle<YoYOptionletVolatilitySurface>& vol,  | 
77  |  |                                         const Handle<YieldTermStructure>& nominalTermStructure);  | 
78  |  |       protected:  | 
79  |  |         Real  | 
80  |  |         optionletImpl(Option::Type, Real strike, Real forward, Real stdDev, Real d) const override;  | 
81  |  |     };  | 
82  |  |  | 
83  |  |  | 
84  |  |     //! Unit Displaced Black-formula inflation cap/floor engine (standalone, i.e. no coupon pricer)  | 
85  |  |     class YoYInflationUnitDisplacedBlackCapFloorEngine  | 
86  |  |     : public YoYInflationCapFloorEngine { | 
87  |  |       public:  | 
88  |  |         YoYInflationUnitDisplacedBlackCapFloorEngine(  | 
89  |  |                     const ext::shared_ptr<YoYInflationIndex>&,  | 
90  |  |                     const Handle<YoYOptionletVolatilitySurface>& vol,  | 
91  |  |                     const Handle<YieldTermStructure>& nominalTermStructure);  | 
92  |  |       protected:  | 
93  |  |         Real  | 
94  |  |         optionletImpl(Option::Type, Real strike, Real forward, Real stdDev, Real d) const override;  | 
95  |  |     };  | 
96  |  |  | 
97  |  |  | 
98  |  |     //! Unit Displaced Black-formula inflation cap/floor engine (standalone, i.e. no coupon pricer)  | 
99  |  |     class YoYInflationBachelierCapFloorEngine  | 
100  |  |     : public YoYInflationCapFloorEngine { | 
101  |  |       public:  | 
102  |  |         YoYInflationBachelierCapFloorEngine(  | 
103  |  |                     const ext::shared_ptr<YoYInflationIndex>&,  | 
104  |  |                     const Handle<YoYOptionletVolatilitySurface>& vol,  | 
105  |  |                     const Handle<YieldTermStructure>& nominalTermStructure);  | 
106  |  |       protected:  | 
107  |  |         Real  | 
108  |  |         optionletImpl(Option::Type, Real strike, Real forward, Real stdDev, Real d) const override;  | 
109  |  |     };  | 
110  |  |  | 
111  |  | }  | 
112  |  |  | 
113  |  | #endif  |