/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2006 Ferdinando Ametrano This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email . The license is also available online at . This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /*! \file swaptionvolcube.hpp \brief Swaption volatility cube */ #ifndef quantlib_swaption_volatility_cube_h #define quantlib_swaption_volatility_cube_h #include #include #include #include namespace QuantLib { //! swaption-volatility cube /*! \warning this class is not finalized and its interface might change in subsequent releases. */ class SwaptionVolatilityCube : public SwaptionVolatilityDiscrete, public LazyObject { public: SwaptionVolatilityCube( const Handle& atmVolStructure, const std::vector& optionTenors, const std::vector& swapTenors, const std::vector& strikeSpreads, const std::vector > >& volSpreads, const boost::shared_ptr& swapIndexBase, bool vegaWeightedSmileFit); //! \name TermStructure interface //@{ DayCounter dayCounter() const { return atmVol_->dayCounter(); } Date maxDate() const { return atmVol_->maxDate(); } Time maxTime() const { return atmVol_->maxTime(); } const Date& referenceDate() const { return atmVol_->referenceDate();} Calendar calendar() const { return atmVol_->calendar(); } //@} //! \name LazyObject interface //@{ void update() { TermStructure::update(); LazyObject::update(); }; //@} //! \name SwaptionVolatilityStructure interface //@{ const Period& maxSwapTenor() const { return atmVol_->maxSwapTenor(); } Time maxSwapLength() const { return atmVol_->maxSwapLength(); } Rate minStrike() const { return 0.0; } Rate maxStrike() const { return 1.0; } //@} //! \name Other inspectors //@{ //virtual boost::shared_ptr smileSectionImpl( // Time optionTime, // Time swapLength) const = 0; Rate atmStrike(const Date& optionDate, const Period& swapTenor) const; Rate atmStrike(const Period& optionTenor, const Period& swapTenor) const { Date optionDate = optionDateFromTenor(optionTenor); return atmStrike(optionDate, swapTenor); } //@} protected: //! \name SwaptionVolatilityStructure interface //@{ std::pair convertDates(const Date& optionDate, const Period& swapTenor) const { return atmVol_->convertDates(optionDate, swapTenor); } void registerWithVolatilitySpread(); Volatility volatilityImpl(Time optionTime, Time swapLength, Rate strike) const; Volatility volatilityImpl(const Date& optionDate, const Period& swapTenor, Rate strike) const; Volatility volatilityImpl(const Period& optionTenor, const Period& swapTenor, Rate strike) const; //@} Handle atmVol_; Size nStrikes_; std::vector strikeSpreads_; mutable std::vector localStrikes_; mutable std::vector localSmile_; std::vector > > volSpreads_; boost::shared_ptr swapIndexBase_; bool vegaWeightedSmileFit_; }; // inline inline Volatility SwaptionVolatilityCube::volatilityImpl( Time optionTime, Time swapLength, Rate strike) const { return smileSectionImpl(optionTime, swapLength)->volatility(strike); } inline Volatility SwaptionVolatilityCube::volatilityImpl( const Date& optionDate, const Period& swapTenor, Rate strike) const { return smileSection(optionDate, swapTenor)->volatility(strike); } inline Volatility SwaptionVolatilityCube::volatilityImpl( const Period& optionTenor, const Period& swapTenor, Rate strike) const { return smileSection(optionTenor, swapTenor)->volatility(strike); } } #endif