21#include <ql/cashflows/cashflows.hpp>
26 const Period& rateComputationPeriod, Rate strike,
27 const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve)
28 : type_(type), tenor_(tenor), index_(index), rateComputationPeriod_(rateComputationPeriod), strike_(strike),
29 nominal_(1.0), settlementDays_(2), calendar_(index->fixingCalendar()), convention_(ModifiedFollowing),
30 rule_(DateGeneration::Backward), dayCounter_(index->dayCounter()), telescopicValueDates_(false),
31 discountCurve_(discountCurve) {}
33MakeOISCapFloor::operator Leg()
const {
34 Calendar calendar = index_->fixingCalendar();
37 if (effectiveDate_ != Date()) {
38 startDate = effectiveDate_;
40 Date refDate = Settings::instance().evaluationDate();
41 startDate = calendar.advance(calendar.adjust(refDate), settlementDays_ * Days);
44 Date endDate = calendar.adjust(startDate + tenor_, ModifiedFollowing);
46 Schedule schedule(startDate, endDate, rateComputationPeriod_, calendar, ModifiedFollowing, ModifiedFollowing,
47 DateGeneration::Backward,
false);
50 Real effectiveStrike = strike_;
51 if (effectiveStrike == Null<Real>()) {
58 CashFlows::atmRate(leg, discountCurve_.empty() ? **index_->forwardingTermStructure() : **discountCurve_,
59 false, index_->forwardingTermStructure()->referenceDate());
62 Real cap = Null<Real>(), floor = Null<Real>();
63 if (type_ == CapFloor::Cap)
64 cap = effectiveStrike;
65 else if (type_ == CapFloor::Floor)
66 floor = effectiveStrike;
68 QL_FAIL(
"MakeOISCapFloor: expected type Cap or Floor");
82 auto f = QuantLib::ext::dynamic_pointer_cast<FloatingRateCoupon>(c);
140 for (
auto const& c : oisCapFloor) {
141 auto cfon = QuantLib::ext::dynamic_pointer_cast<CappedFlooredOvernightIndexedCoupon>(c);
142 QL_REQUIRE(cfon,
"getOisCapFloorUnderlying(): expected CappedFlooredOvernightIndexedCoupon");
143 underlying.push_back(cfon->underlying());
149 std::vector<std::pair<Real, Real>> result;
150 for (
auto const& c : oisCapFloor) {
151 auto cfon = QuantLib::ext::dynamic_pointer_cast<CappedFlooredOvernightIndexedCoupon>(c);
152 QL_REQUIRE(cfon,
"getOisCapFloorUnderlying(): expected CappedFlooredOvernightIndexedCoupon");
153 result.push_back(std::make_pair(cfon->cap(), cfon->floor()));
ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > pricer_
bool telescopicValueDates_
MakeOISCapFloor & withEffectiveDate(const Date &effectiveDate)
MakeOISCapFloor & withSettlementDays(Natural settlementDays)
MakeOISCapFloor & withDayCount(const DayCounter &dc)
MakeOISCapFloor & withCouponPricer(const ext::shared_ptr< CappedFlooredOvernightIndexedCouponPricer > &pricer)
MakeOISCapFloor & withRule(DateGeneration::Rule r)
MakeOISCapFloor & withTelescopicValueDates(bool telescopicValueDates)
MakeOISCapFloor(CapFloor::Type type, const Period &tenor, const ext::shared_ptr< OvernightIndex > &index, const Period &rateComputationPeriod, Rate strike, const QuantLib::Handle< QuantLib::YieldTermStructure > &discountCurve=Handle< YieldTermStructure >())
BusinessDayConvention convention_
DateGeneration::Rule rule_
MakeOISCapFloor & withCalendar(const Calendar &cal)
MakeOISCapFloor & withConvention(BusinessDayConvention bdc)
MakeOISCapFloor & withNominal(Real n)
helper class building a sequence of overnight coupons
OvernightLeg & withFloors(Rate floor)
OvernightLeg & withTelescopicValueDates(bool telescopicValueDates)
OvernightLeg & withPaymentAdjustment(BusinessDayConvention)
OvernightLeg & withNakedOption(const bool nakedOption)
OvernightLeg & withNotionals(Real notional)
OvernightLeg & withCaps(Rate cap)
OvernightLeg & withPaymentDayCounter(const DayCounter &)
const QuantLib::ext::shared_ptr< FloatingRateCouponPricer > pricer_
helper class to instantiate standard market OIS cap / floors
Leg getOisCapFloorUnderlying(const Leg &oisCapFloor)
get the underlying ON coupons from an OIS cf
std::vector< std::pair< Real, Real > > getOisCapFloorStrikes(const Leg &oisCapFloor)
get the (cap, floor) - strikes from an OIS cf