| 1 | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
|---|---|
| 2 | |
| 3 | /* |
| 4 | Copyright (C) 2007 Ferdinando Ametrano |
| 5 | Copyright (C) 2007 Giorgio Facchinetti |
| 6 | Copyright (C) 2015 Peter Caspers |
| 7 | |
| 8 | This file is part of QuantLib, a free-software/open-source library |
| 9 | for financial quantitative analysts and developers - http://quantlib.org/ |
| 10 | |
| 11 | QuantLib is free software: you can redistribute it and/or modify it |
| 12 | under the terms of the QuantLib license. You should have received a |
| 13 | copy of the license along with this program; if not, please email |
| 14 | <quantlib-dev@lists.sf.net>. The license is also available online at |
| 15 | <http://quantlib.org/license.shtml>. |
| 16 | |
| 17 | This program is distributed in the hope that it will be useful, but WITHOUT |
| 18 | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
| 19 | FOR A PARTICULAR PURPOSE. See the license for more details. |
| 20 | */ |
| 21 | |
| 22 | /*! \file optionletstripper.hpp |
| 23 | \brief optionlet (caplet/floorlet) volatility stripper |
| 24 | */ |
| 25 | |
| 26 | #ifndef quantlib_optionletstripper_hpp |
| 27 | #define quantlib_optionletstripper_hpp |
| 28 | |
| 29 | #include <ql/termstructures/volatility/optionlet/strippedoptionletbase.hpp> |
| 30 | #include <ql/termstructures/volatility/capfloor/capfloortermvolsurface.hpp> |
| 31 | #include <ql/termstructures/volatility/volatilitytype.hpp> |
| 32 | #include <ql/termstructures/yieldtermstructure.hpp> |
| 33 | |
| 34 | namespace QuantLib { |
| 35 | |
| 36 | class IborIndex; |
| 37 | |
| 38 | /*! StrippedOptionletBase specialization. It's up to derived |
| 39 | classes to implement LazyObject::performCalculations |
| 40 | */ |
| 41 | class OptionletStripper : public StrippedOptionletBase { |
| 42 | public: |
| 43 | //! \name StrippedOptionletBase interface |
| 44 | //@{ |
| 45 | const std::vector<Rate>& optionletStrikes(Size i) const override; |
| 46 | const std::vector<Volatility>& optionletVolatilities(Size i) const override; |
| 47 | |
| 48 | const std::vector<Date>& optionletFixingDates() const override; |
| 49 | const std::vector<Time>& optionletFixingTimes() const override; |
| 50 | Size optionletMaturities() const override; |
| 51 | |
| 52 | const std::vector<Rate>& atmOptionletRates() const override; |
| 53 | |
| 54 | DayCounter dayCounter() const override; |
| 55 | Calendar calendar() const override; |
| 56 | Natural settlementDays() const override; |
| 57 | BusinessDayConvention businessDayConvention() const override; |
| 58 | //@} |
| 59 | |
| 60 | const std::vector<Period>& optionletFixingTenors() const; |
| 61 | const std::vector<Date>& optionletPaymentDates() const; |
| 62 | const std::vector<Time>& optionletAccrualPeriods() const; |
| 63 | ext::shared_ptr<CapFloorTermVolSurface> termVolSurface() const; |
| 64 | ext::shared_ptr<IborIndex> iborIndex() const; |
| 65 | Real displacement() const override; |
| 66 | VolatilityType volatilityType() const override; |
| 67 | |
| 68 | protected: |
| 69 | OptionletStripper(const ext::shared_ptr<CapFloorTermVolSurface>&, |
| 70 | ext::shared_ptr<IborIndex> iborIndex_, |
| 71 | Handle<YieldTermStructure> discount = {}, |
| 72 | VolatilityType type = ShiftedLognormal, |
| 73 | Real displacement = 0.0); |
| 74 | ext::shared_ptr<CapFloorTermVolSurface> termVolSurface_; |
| 75 | ext::shared_ptr<IborIndex> iborIndex_; |
| 76 | Handle<YieldTermStructure> discount_; |
| 77 | Size nStrikes_; |
| 78 | Size nOptionletTenors_; |
| 79 | |
| 80 | mutable std::vector<std::vector<Rate> > optionletStrikes_; |
| 81 | mutable std::vector<std::vector<Volatility> > optionletVolatilities_; |
| 82 | |
| 83 | mutable std::vector<Time> optionletTimes_; |
| 84 | mutable std::vector<Date> optionletDates_; |
| 85 | std::vector<Period> optionletTenors_; |
| 86 | mutable std::vector<Rate> atmOptionletRate_; |
| 87 | mutable std::vector<Date> optionletPaymentDates_; |
| 88 | mutable std::vector<Time> optionletAccrualPeriods_; |
| 89 | |
| 90 | std::vector<Period> capFloorLengths_; |
| 91 | const VolatilityType volatilityType_; |
| 92 | const Real displacement_; |
| 93 | }; |
| 94 | |
| 95 | } |
| 96 | |
| 97 | #endif |
| 98 |
