Example #1
0
 // fixed reference date, floating market data
 SwaptionVolatilityMatrix::SwaptionVolatilityMatrix(
                 const Date& refDate,
                 const Calendar& cal,
                 BusinessDayConvention bdc,
                 const std::vector<Period>& optionT,
                 const std::vector<Period>& swapT,
                 const std::vector<std::vector<Handle<Quote> > >& vols,
                 const DayCounter& dc,
                 const bool flatExtrapolation,
                 const std::vector<std::vector<Real> >& shifts)
 : SwaptionVolatilityDiscrete(optionT, swapT, refDate, cal, bdc, dc),
   volHandles_(vols), shiftValues_(shifts),
   volatilities_(vols.size(), vols.front().size()),
   shifts_(vols.size(), vols.front().size(), 0.0) {
     checkInputs(volatilities_.rows(), volatilities_.columns(),
                 shifts.size(), shifts.size() == 0 ? 0 : shifts.front().size());
     registerWithMarketData();
     if (flatExtrapolation) {
         interpolation_ =
             FlatExtrapolator2D(boost::make_shared<BilinearInterpolation>(
                 swapLengths_.begin(), swapLengths_.end(),
                 optionTimes_.begin(), optionTimes_.end(), volatilities_));
         interpolationShifts_ =
             FlatExtrapolator2D(boost::make_shared<BilinearInterpolation>(
                 swapLengths_.begin(), swapLengths_.end(),
                 optionTimes_.begin(), optionTimes_.end(), shifts_));
     } else {
         interpolation_ = BilinearInterpolation(
             swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(),
             optionTimes_.end(), volatilities_);
         interpolationShifts_ = BilinearInterpolation(
             swapLengths_.begin(), swapLengths_.end(), optionTimes_.begin(),
             optionTimes_.end(), shifts_);
     }
 }
Example #2
0
 // floating reference date, floating market data
 AbcdAtmVolCurve::AbcdAtmVolCurve(
         Natural settlDays,
         const Calendar& cal,
         const std::vector<Period>& optionTenors,
         const std::vector<Handle<Quote> >& volsHandles,
         const std::vector<bool> inclusionInInterpolationFlag,
         BusinessDayConvention bdc,
         const DayCounter& dc)
 : BlackAtmVolCurve(settlDays, cal, bdc, dc),
   nOptionTenors_(optionTenors.size()),
   optionTenors_(optionTenors),
   optionDates_(nOptionTenors_),
   optionTimes_(nOptionTenors_),
   actualOptionTimes_(nOptionTenors_),
   volHandles_(volsHandles),
   vols_(volsHandles.size()),
   actualVols_(volsHandles.size()),
   inclusionInInterpolation_(inclusionInInterpolationFlag),
   interpolation_(boost::shared_ptr<AbcdInterpolation>()) // do not initialize with nOptionTenors_
 {
     checkInputs();
     initializeOptionDatesAndTimes();
     initializeVolatilities();
     registerWithMarketData();
     for (Size i=0; i<vols_.size(); ++i)
         vols_[i] = volHandles_[i]->value();
     interpolate();
 }
 // fixed reference date, floating market data
 CapFloorTermVolSurface::CapFloorTermVolSurface(
                     const Date& settlementDate,
                     const Calendar& calendar,
                     BusinessDayConvention bdc,
                     const std::vector<Period>& optionTenors,
                     const std::vector<Rate>& strikes,
                     const std::vector<std::vector<Handle<Quote> > >& vols,
                     const DayCounter& dc)
 : CapFloorTermVolatilityStructure(settlementDate, calendar, bdc, dc),
   nOptionTenors_(optionTenors.size()),
   optionTenors_(optionTenors),
   optionDates_(nOptionTenors_),
   optionTimes_(nOptionTenors_),
   nStrikes_(strikes.size()),
   strikes_(strikes),
   volHandles_(vols),
   vols_(vols.size(), vols[0].size())
 {
     checkInputs();
     initializeOptionDatesAndTimes();
     for (Size i=0; i<nOptionTenors_; ++i)
         QL_REQUIRE(volHandles_[i].size()==nStrikes_,
                    io::ordinal(i+1) << " row of vol handles has size " <<
                    volHandles_[i].size() << " instead of " << nStrikes_);
     registerWithMarketData();
     for (Size i=0; i<vols_.rows(); ++i)
         for (Size j=0; j<vols_.columns(); ++j)
             vols_[i][j] = volHandles_[i][j]->value();
     interpolate();
 }
Example #4
0
  // floating reference date, floating market data
  SwaptionVolatilityMatrix::SwaptionVolatilityMatrix(
                  const Calendar& cal,
                  BusinessDayConvention bdc,
                  const std::vector<Period>& optionT,
                  const std::vector<Period>& swapT,
                  const std::vector<std::vector<Handle<Quote> > >& vols,
                  const DayCounter& dc)
  : SwaptionVolatilityDiscrete(optionT, swapT, 0, cal, bdc, dc),
    volHandles_(vols),
    volatilities_(vols.size(), vols.front().size()) {
      checkInputs(volatilities_.rows(), volatilities_.columns());
      registerWithMarketData();
      interpolation_ =
          BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(),
                                optionTimes_.begin(), optionTimes_.end(),
                                volatilities_);
 }
Example #5
0
    SabrVolSurface::SabrVolSurface(
        const boost::shared_ptr<InterestRateIndex>& index,
        const Handle<BlackAtmVolCurve>& atmCurve,
        const std::vector<Period>& optionTenors,
        const std::vector<Spread>& atmRateSpreads,
        const std::vector<std::vector<Handle<Quote> > >& volSpreads)
    : InterestRateVolSurface(index),
      atmCurve_(atmCurve),
      optionTenors_(optionTenors),
      optionTimes_(optionTenors.size()),
      optionDates_(optionTenors.size()),
      atmRateSpreads_(atmRateSpreads),
      volSpreads_(volSpreads) {

        checkInputs();

        // Creation of reference smile sections

        // Hard coded
        isAlphaFixed_ = false;
        isBetaFixed_ = false;
        isNuFixed_ = false;
        isRhoFixed_ = false;
        vegaWeighted_ = true;

        sabrGuesses_.resize(optionTenors_.size());

        for (Size i=0; i<optionTenors_.size(); ++i) {

            optionDates_[i] = optionDateFromTenor(optionTenors_[i]);
            optionTimes_[i] = timeFromReference(optionDates_[i]);

            // Hard coded
            sabrGuesses_[i][0] = 0.025; // alpha
            sabrGuesses_[i][1] = 0.5;   // beta
            sabrGuesses_[i][2] = 0.3;   // rho
            sabrGuesses_[i][3] = 0.0;   // nu
        }
        registerWithMarketData();
    }
    // floating reference date, floating market data
    SwaptionVolatilityHullWhite::SwaptionVolatilityHullWhite(const Real reversion, const Handle<YieldTermStructure>& yts, const boost::shared_ptr<SwapIndex> indexBase,
                    const Calendar& cal,
                    BusinessDayConvention bdc,
                    const std::vector<Period>& optionT,
                    const std::vector<Period>& swapT,
                    const std::vector<std::vector<Handle<Quote> > >& vols,
                    const DayCounter& dc)
    : reversion_(reversion),yts_(yts),indexBase_(indexBase),SwaptionVolatilityDiscrete(optionT, swapT, 0, cal, bdc, dc),
      volHandles_(vols),
	  hwsigmas_(vols.size(), vols.front().size()),
      volatilities_(vols.size(), vols.front().size()) {
        checkInputs(volatilities_.rows(), volatilities_.columns());
        registerWithMarketData();
        interpolation_ =
            BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(),
                                  optionTimes_.begin(), optionTimes_.end(),
                                  volatilities_);
		interpolationSigma_ =
			BilinearInterpolation(swapLengths_.begin(), swapLengths_.end(),
                                  optionTimes_.begin(), optionTimes_.end(),
                                  hwsigmas_);
   }