/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ /* Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb 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 #include #include #include namespace QuantLib { SwaptionHelper::SwaptionHelper( const Period& maturity, const Period& length, const Handle& volatility, const boost::shared_ptr& index, const Period& fixedLegTenor, const DayCounter& fixedLegDayCounter, const DayCounter& floatingLegDayCounter, const Handle& termStructure, bool calibrateVolatility) : CalibrationHelper(volatility,termStructure, calibrateVolatility) { Calendar calendar = index->fixingCalendar(); Period indexTenor = index->tenor(); Natural fixingDays = index->fixingDays(); Date exerciseDate = calendar.advance(termStructure->referenceDate(), maturity, index->businessDayConvention()); Date startDate = calendar.advance(exerciseDate, fixingDays, Days, index->businessDayConvention()); Date endDate = calendar.advance(startDate, length, index->businessDayConvention()); Schedule fixedSchedule(startDate, endDate, fixedLegTenor, calendar, index->businessDayConvention(), index->businessDayConvention(), false, false); Schedule floatSchedule(startDate, endDate, index->tenor(), calendar, index->businessDayConvention(), index->businessDayConvention(), false, false); exerciseRate_ = VanillaSwap(VanillaSwap::Receiver, 1.0, fixedSchedule, 0.0, fixedLegDayCounter, floatSchedule, index, 0.0, floatingLegDayCounter, termStructure).fairRate(); swap_ = boost::shared_ptr(new VanillaSwap(VanillaSwap::Receiver, 1.0, fixedSchedule, exerciseRate_, fixedLegDayCounter, floatSchedule, index, 0.0, floatingLegDayCounter, termStructure)); engine_ = boost::shared_ptr(); boost::shared_ptr exercise(new EuropeanExercise(exerciseDate)); swaption_ = boost::shared_ptr(new Swaption(swap_, exercise, termStructure, engine_)); marketValue_ = blackPrice(volatility_->value()); } void SwaptionHelper::addTimesTo(std::list