19#include <ql/indexes/iborindex.hpp>
20#include <ql/instruments/makecapfloor.hpp>
21#include <ql/pricingengines/capfloor/blackcapfloorengine.hpp>
31 const ext::shared_ptr<IborIndex>& index,
32 const Handle<YieldTermStructure>& discount,
const VolatilityType type,
33 const Real displacement,
const Period& rateComputationPeriod,
34 const Size onCapSettlementDays)
35 : termVolSurface_(termVolSurface), index_(index), discount_(discount), nStrikes_(termVolSurface->
strikes().size()),
36 volatilityType_(type), displacement_(displacement),
37 rateComputationPeriod_(rateComputationPeriod == 0 * Days ? index->tenor() : rateComputationPeriod),
38 onCapSettlementDays_(onCapSettlementDays) {
40 bool isOis = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(
index_) !=
nullptr;
43 "OptionletStripper: For an OIS index the rateComputationPeriod must be given");
45 "OptionletStripper: For an Ibor index the Ibor tenor ("
47 <<
") if the latter is given.");
50 QL_REQUIRE(
displacement_ == 0.0,
"non-null displacement is not allowed with Normal model");
56 registerWith(Settings::instance().evaluationDate());
58 QL_REQUIRE(
termVolSurface->optionTenors().size() > 0,
"OptionletStripper: No OptionTenors provided.");
65 "too short (" << maxCapFloorTenor <<
") capfloor term vol termVolSurface");
67 while (nextCapFloorLength <= maxCapFloorTenor) {
89 "index (" << i <<
") must be less than optionletStrikes size (" <<
optionletStrikes_.size() <<
")");
95 QL_REQUIRE(i <
optionletVolatilities_.size(),
"index (" << i <<
") must be less than optionletVolatilities size ("
151 bool isOis = QuantLib::ext::dynamic_pointer_cast<OvernightIndex>(
index_) !=
nullptr;
155 QuantLib::ext::shared_ptr<BlackCapFloorEngine> dummyEngine =
156 QuantLib::ext::make_shared<BlackCapFloorEngine>(
index_->forwardingTermStructure(), 0.20, dc);
165 auto lastCoupon = QuantLib::ext::dynamic_pointer_cast<CappedFlooredOvernightIndexedCoupon>(dummyCap.back());
166 QL_REQUIRE(lastCoupon,
"OptionletStripper::populateDates(): expected CappedFlooredOvernightIndexedCoupon");
167 optionletDates_[i] = std::max(referenceDate + 1, lastCoupon->underlying()->fixingDates().front());
175 QuantLib::ext::shared_ptr<FloatingRateCoupon> lastCoupon = dummyCap.lastFloatingRateCoupon();
176 optionletDates_[i] = std::max(referenceDate + 1, lastCoupon->fixingDate());
183 "OptionletStripper::populateDates(): got non-increasing optionletDates "
MakeOISCapFloor & withSettlementDays(Natural settlementDays)
MakeOISCapFloor & withTelescopicValueDates(bool telescopicValueDates)
const Size onCapSettlementDays_
Calendar calendar() const override
const Period & rateComputationPeriod() const
std::vector< Rate > atmOptionletRate_
const Period rateComputationPeriod_
std::vector< std::vector< Volatility > > optionletVolatilities_
const std::vector< Date > & optionletFixingDates() const override
std::vector< Period > capFloorLengths_
ext::shared_ptr< CapFloorTermVolSurface > termVolSurface() const
Handle< YieldTermStructure > discount_
const std::vector< Rate > & optionletStrikes(Size i) const override
std::vector< Date > optionletPaymentDates_
std::vector< Time > optionletAccrualPeriods_
const std::vector< Time > & optionletFixingTimes() const override
const std::vector< Date > & optionletPaymentDates() const
const std::vector< Volatility > & optionletVolatilities(Size i) const override
const std::vector< Rate > & atmOptionletRates() const override
std::vector< Period > optionletTenors_
VolatilityType volatilityType() const override
std::vector< Time > optionletTimes_
std::vector< Date > optionletDates_
Natural settlementDays() const override
DayCounter dayCounter() const override
const std::vector< Period > & optionletFixingTenors() const
const VolatilityType volatilityType_
OptionletStripper(const ext::shared_ptr< QuantExt::CapFloorTermVolSurface > &, const ext::shared_ptr< IborIndex > &index, const Handle< YieldTermStructure > &discount=Handle< YieldTermStructure >(), const VolatilityType type=ShiftedLognormal, const Real displacement=0.0, const Period &rateComputationPeriod=0 *Days, const Size onCapSettlementDays=0)
BusinessDayConvention businessDayConvention() const override
std::vector< std::vector< Rate > > optionletStrikes_
Real displacement() const override
virtual void populateDates() const
Method to populate the dates, times and accruals that can be overridden in derived classes.
ext::shared_ptr< IborIndex > index() const
ext::shared_ptr< CapFloorTermVolSurface > termVolSurface_
const std::vector< Time > & optionletAccrualPeriods() const
Size optionletMaturities() const override
ext::shared_ptr< IborIndex > index_
helper class to instantiate standard market OIS cap / floors
optionlet (caplet/floorlet) volatility stripper