1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2013, 2018 Peter Caspers
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 floatfloatswaption.hpp
21     \brief floatfloatswaption class
22 */
23 
24 #ifndef quantlib_instruments_floatfloatswaption_hpp
25 #define quantlib_instruments_floatfloatswaption_hpp
26 
27 #include <ql/instruments/swaption.hpp>
28 #include <ql/instruments/floatfloatswap.hpp>
29 #include <ql/pricingengines/swaption/basketgeneratingengine.hpp>
30 #include <ql/termstructures/yieldtermstructure.hpp>
31 #include <ql/termstructures/volatility/swaption/swaptionvolstructure.hpp>
32 #include <ql/models/calibrationhelper.hpp>
33 #include <ql/utilities/disposable.hpp>
34 
35 namespace QuantLib {
36 
37     //! floatfloat swaption class
38     /*! \ingroup instruments
39     */
40 
41     class FloatFloatSwaption : public Option {
42       public:
43         class arguments;
44         class engine;
45         FloatFloatSwaption(
46             const ext::shared_ptr<FloatFloatSwap>& swap,
47             const ext::shared_ptr<Exercise>& exercise,
48             Settlement::Type delivery = Settlement::Physical,
49             Settlement::Method settlementMethod = Settlement::PhysicalOTC);
50         //! \name Instrument interface
51         //@{
52         bool isExpired() const;
53         void setupArguments(PricingEngine::arguments *) const;
54         //@}
55         //! \name Inspectors
56         //@{
settlementType() const57         Settlement::Type settlementType() const { return settlementType_; }
settlementMethod() const58         Settlement::Method settlementMethod() const {
59             return settlementMethod_;
60         }
type() const61         VanillaSwap::Type type() const { return swap_->type(); }
underlyingSwap() const62         const ext::shared_ptr<FloatFloatSwap> &underlyingSwap() const {
63             return swap_;
64         }
65         //@}
66         Disposable<std::vector<ext::shared_ptr<BlackCalibrationHelper> > >
67         calibrationBasket(const ext::shared_ptr<SwapIndex>& standardSwapBase,
68                           const ext::shared_ptr<SwaptionVolatilityStructure>& swaptionVolatility,
69                           BasketGeneratingEngine::CalibrationBasketType basketType =
70                               BasketGeneratingEngine::MaturityStrikeByDeltaGamma) const;
71 
72       private:
73         // arguments
74         ext::shared_ptr<FloatFloatSwap> swap_;
75         Settlement::Type settlementType_;
76         Settlement::Method settlementMethod_;
77     };
78 
79     //! %Arguments for cms swaption calculation
80     class FloatFloatSwaption::arguments : public FloatFloatSwap::arguments,
81                                           public Option::arguments {
82       public:
arguments()83         arguments() {}
84         ext::shared_ptr<FloatFloatSwap> swap;
85         Settlement::Type settlementType;
86         Settlement::Method settlementMethod;
87         void validate() const;
88     };
89 
90     //! base class for cms swaption engines
91     class FloatFloatSwaption::engine
92         : public GenericEngine<FloatFloatSwaption::arguments,
93                                FloatFloatSwaption::results> {};
94 }
95 
96 #endif
97