swaptionvolstructure.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2006, 2010 Ferdinando Ametrano
5  Copyright (C) 2006 Silvia Frasson
6  Copyright (C) 2006 Mario Pucci
7  Copyright (C) 2006, 2007 Giorgio Facchinetti
8  Copyright (C) 2007 Eric Ehlers
9 
10  This file is part of QuantLib, a free-software/open-source library
11  for financial quantitative analysts and developers - http://quantlib.org/
12 
13  QuantLib is free software: you can redistribute it and/or modify it
14  under the terms of the QuantLib license. You should have received a
15  copy of the license along with this program; if not, please email
16  <quantlib-dev@lists.sf.net>. The license is also available online at
17  <http://quantlib.org/license.shtml>.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the license for more details.
22 */
23 
24 #ifndef qla_swaptionvolstructure_hpp
25 #define qla_swaptionvolstructure_hpp
26 
27 #include <qlo/termstructures.hpp>
28 #include <qlo/smilesection.hpp>
29 #include <ql/time/businessdayconvention.hpp>
30 
31 namespace QuantLib {
32  class Calendar;
33  class SwaptionVolatilityCube;
34  class SwapIndex;
35  class Matrix;
36  class Period;
37 }
38 
39 namespace QuantLibAddin {
40 
41  class ConstantSwaptionVolatility : public SwaptionVolatilityStructure {
42  public:
44  const boost::shared_ptr<ObjectHandler::ValueObject>&,
45  QuantLib::Natural settlementDays,
46  const QuantLib::Calendar& cal,
47  QuantLib::BusinessDayConvention bdc,
49  const QuantLib::DayCounter& dayCounter,
50  bool permanent);
51  };
52 
53  class SpreadedSwaptionVolatility : public SwaptionVolatilityStructure {
54  public:
56  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
57  const QuantLib::Handle<QuantLib::SwaptionVolatilityStructure>& underlyingVolStructure,
59  bool permanent);
60  };
61 
62  class SwaptionVolatilityMatrix : public SwaptionVolatilityDiscrete {
63  public:
64  SwaptionVolatilityMatrix(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
65  const QuantLib::Calendar& calendar,
66  const QuantLib::BusinessDayConvention bdc,
67  const std::vector<QuantLib::Period>& optionTenors,
68  const std::vector<QuantLib::Period>& tenors,
69  const std::vector<std::vector<QuantLib::Handle<QuantLib::Quote> > >& vols,
70  const QuantLib::DayCounter& dayCounter,
71  bool permanent);
72  std::vector<long> locate(const QuantLib::Date& d,
73  const QuantLib::Period& p);
74  };
75 
76  class SwaptionVolCube2 : public SwaptionVolatilityCube {
77  public:
79  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
81  const std::vector<QuantLib::Period>& optionTenors,
82  const std::vector<QuantLib::Period>& swapTenors,
83  const std::vector<QuantLib::Spread>& strikeSpreads,
84  const std::vector<std::vector<QuantLib::Handle<QuantLib::Quote> > >& volSpreads,
85  const boost::shared_ptr<QuantLib::SwapIndex>& swapIndexBase,
86  const boost::shared_ptr<QuantLib::SwapIndex>& shortSwapIndexBase,
87  bool vegaWeightedSmileFit,
88  bool permanent);
89  };
90 
91  // The 2 functions below must declare their input parameters as pass by value rather
92  // than pass by reference to allow clients of these functions to pass temporary objects.
93  std::vector<std::vector<ObjectHandler::property_t> > getSabrParameters(QuantLib::Matrix sabrParameters);
94  std::vector<std::vector<ObjectHandler::property_t> > getVolCube(QuantLib::Matrix volCube);
95 
96  class SwaptionVolCube1 : public SwaptionVolatilityCube {
97  public:
99  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
101  const std::vector<QuantLib::Period>& optionTenors,
102  const std::vector<QuantLib::Period>& swapTenors,
103  const std::vector<QuantLib::Spread>& strikeSpreads,
104  const std::vector<std::vector<QuantLib::Handle<QuantLib::Quote> > >& volSpreads,
105  const boost::shared_ptr<QuantLib::SwapIndex>& swapIndexBase,
106  const boost::shared_ptr<QuantLib::SwapIndex>& shortSwapIndexBase,
107  bool vegaWeightedSmileFit,
108  const std::vector<std::vector<QuantLib::Handle<QuantLib::Quote> > >& parametersGuess,
109  const std::vector<bool>& isParameterFixed,
110  bool isAtmCalibrated,
111  const boost::shared_ptr<QuantLib::EndCriteria>& endCriteria,
112  QuantLib::Real maxErrorTolerance,
113  const boost::shared_ptr<QuantLib::OptimizationMethod>& optMethod,
114  bool permanent);
115  std::vector<std::vector<ObjectHandler::property_t> > getSparseSabrParameters();
116  std::vector<std::vector<ObjectHandler::property_t> > getDenseSabrParameters();
117  std::vector<std::vector<ObjectHandler::property_t> > getMarketVolCube();
118  std::vector<std::vector<ObjectHandler::property_t> > getVolCubeAtmCalibrated();
119  };
120 
121  class SmileSectionByCube : public SmileSection {
122  public:
124  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
125  const boost::shared_ptr<QuantLib::SwaptionVolatilityCube>& cube,
126  const QuantLib::Period& optionTenors,
127  const QuantLib::Period& swapTenors,
128  bool permanent);
130  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
131  const boost::shared_ptr<QuantLib::SwaptionVolatilityCube>& cube,
132  const QuantLib::Date& optionDate,
133  const QuantLib::Period& swapTenors,
134  bool permanent);
135  };
136 
137 }
138 
139 #endif
SpreadedSwaptionVolatility(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Handle< QuantLib::SwaptionVolatilityStructure > &underlyingVolStructure, const QuantLib::Handle< QuantLib::Quote > &, bool permanent)
std::vector< std::vector< ObjectHandler::property_t > > getVolCubeAtmCalibrated()
Definition: swaptionvolstructure.hpp:121
SwaptionVolatilityMatrix(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Calendar &calendar, const QuantLib::BusinessDayConvention bdc, const std::vector< QuantLib::Period > &optionTenors, const std::vector< QuantLib::Period > &tenors, const std::vector< std::vector< QuantLib::Handle< QuantLib::Quote > > > &vols, const QuantLib::DayCounter &dayCounter, bool permanent)
std::vector< std::vector< ObjectHandler::property_t > > getDenseSabrParameters()
Definition: swaptionvolstructure.hpp:76
Definition: swaptionvolstructure.hpp:41
std::vector< std::vector< ObjectHandler::property_t > > getSparseSabrParameters()
SmileSectionByCube(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const boost::shared_ptr< QuantLib::SwaptionVolatilityCube > &cube, const QuantLib::Period &optionTenors, const QuantLib::Period &swapTenors, bool permanent)
Definition: swaptionvolstructure.hpp:62
Definition: abcd.hpp:38
std::vector< std::vector< ObjectHandler::property_t > > getVolCube(QuantLib::Matrix volCube)
Definition: abcd.hpp:30
std::vector< std::vector< ObjectHandler::property_t > > getSabrParameters(QuantLib::Matrix sabrParameters)
ConstantSwaptionVolatility(const boost::shared_ptr< ObjectHandler::ValueObject > &, QuantLib::Natural settlementDays, const QuantLib::Calendar &cal, QuantLib::BusinessDayConvention bdc, const QuantLib::Handle< QuantLib::Quote > &vol, const QuantLib::DayCounter &dayCounter, bool permanent)
SwaptionVolCube1(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Handle< QuantLib::SwaptionVolatilityStructure > &atmVol, const std::vector< QuantLib::Period > &optionTenors, const std::vector< QuantLib::Period > &swapTenors, const std::vector< QuantLib::Spread > &strikeSpreads, const std::vector< std::vector< QuantLib::Handle< QuantLib::Quote > > > &volSpreads, const boost::shared_ptr< QuantLib::SwapIndex > &swapIndexBase, const boost::shared_ptr< QuantLib::SwapIndex > &shortSwapIndexBase, bool vegaWeightedSmileFit, const std::vector< std::vector< QuantLib::Handle< QuantLib::Quote > > > &parametersGuess, const std::vector< bool > &isParameterFixed, bool isAtmCalibrated, const boost::shared_ptr< QuantLib::EndCriteria > &endCriteria, QuantLib::Real maxErrorTolerance, const boost::shared_ptr< QuantLib::OptimizationMethod > &optMethod, bool permanent)
std::vector< long > locate(const QuantLib::Date &d, const QuantLib::Period &p)
std::vector< std::vector< ObjectHandler::property_t > > getMarketVolCube()
Definition: swaptionvolstructure.hpp:53
Definition: swaptionvolstructure.hpp:96
SwaptionVolCube2(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Handle< QuantLib::SwaptionVolatilityStructure > &atmVol, const std::vector< QuantLib::Period > &optionTenors, const std::vector< QuantLib::Period > &swapTenors, const std::vector< QuantLib::Spread > &strikeSpreads, const std::vector< std::vector< QuantLib::Handle< QuantLib::Quote > > > &volSpreads, const boost::shared_ptr< QuantLib::SwapIndex > &swapIndexBase, const boost::shared_ptr< QuantLib::SwapIndex > &shortSwapIndexBase, bool vegaWeightedSmileFit, bool permanent)