/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2006 Ferdinando Ametrano Copyright (C) 2006 Katiuscia Manzoni 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. */ #include #include namespace QuantLib { SwaptionVolatilityCube::SwaptionVolatilityCube( const Handle& atmVol, const std::vector& optionTenors, const std::vector& swapTenors, const std::vector& strikeSpreads, const std::vector > >& volSpreads, const boost::shared_ptr& swapIndexBase, bool vegaWeightedSmileFit) : SwaptionVolatilityDiscrete(optionTenors, swapTenors, 0, atmVol->calendar(), atmVol->dayCounter(), atmVol->businessDayConvention()), atmVol_(atmVol), nStrikes_(strikeSpreads.size()), strikeSpreads_(strikeSpreads), localStrikes_(nStrikes_), localSmile_(nStrikes_), volSpreads_(volSpreads), swapIndexBase_(swapIndexBase), vegaWeightedSmileFit_(vegaWeightedSmileFit) { QL_REQUIRE(nStrikes_>1, "too few strikes (" << nStrikes_ << ")"); for (Size i=1; ienableExtrapolation(); // register with SwapIndexBase if (!swapIndexBase_) registerWith(swapIndexBase_); registerWithVolatilitySpread(); } void SwaptionVolatilityCube::registerWithVolatilitySpread() { for (Size i=0; ifamilyName(), swapTenor, swapIndexBase_->fixingDays(), swapIndexBase_->currency(), swapIndexBase_->fixingCalendar(), swapIndexBase_->fixedLegTenor(), swapIndexBase_->fixedLegConvention(), swapIndexBase_->dayCounter(), swapIndexBase_->iborIndex()).fixing(optionDate); } }