29 const ext::shared_ptr<IborIndex>& iborIndex,
31 const Period& forwardStart)
32 : capFloorType_(capFloorType),
strike_(strike), firstCapletExcluded_(forwardStart == 0 *
Days),
37 .withFixedLegTenor(1 *
Years)
41 ext::shared_ptr<CapFloor> capfloor = *
this;
45 MakeCapFloor::operator ext::shared_ptr<CapFloor>()
const {
50 if (firstCapletExcluded_)
51 leg.erase(leg.begin());
54 if (asOptionlet_ && leg.size() > 1) {
56 leg.erase(leg.begin(), --end);
59 std::vector<Rate> strikeVector(1,
strike_);
64 ext::shared_ptr<BlackCapFloorEngine> temp =
65 ext::dynamic_pointer_cast<BlackCapFloorEngine>(
engine_);
67 "cannot calculate ATM without a BlackCapFloorEngine");
72 discountCurve->referenceDate());
75 ext::shared_ptr<CapFloor> capFloor(
new
76 CapFloor(capFloorType_, leg, strikeVector));
77 capFloor->setPricingEngine(
engine_);
87 bool firstCapletExcluded) {
150 const ext::shared_ptr<PricingEngine>& engine) {
Black-formula cap/floor engine.
Cash-flow analysis functions.
ext::shared_ptr< PricingEngine > engine_
Actual/365 (Fixed) day count convention.
Base class for cap-like instruments.
static Rate atmRate(const Leg &leg, const YieldTermStructure &discountCurve, bool includeSettlementDateFlows, Date settlementDate=Date(), Date npvDate=Date(), Real npv=Null< Real >())
At-the-money rate of the cash flows.
Shared handle to an observable.
MakeCapFloor & withTenor(const Period &t)
MakeCapFloor & withEffectiveDate(const Date &effectiveDate, bool firstCapletExcluded)
MakeCapFloor & withNominal(Real n)
MakeCapFloor & withCalendar(const Calendar &cal)
bool firstCapletExcluded_
MakeCapFloor & withDayCount(const DayCounter &dc)
MakeCapFloor & asOptionlet(bool b=true)
only get last coupon
MakeVanillaSwap makeVanillaSwap_
MakeCapFloor & withFirstDate(const Date &d)
MakeCapFloor & withEndOfMonth(bool flag=true)
ext::shared_ptr< PricingEngine > engine_
MakeCapFloor & withPricingEngine(const ext::shared_ptr< PricingEngine > &engine)
MakeCapFloor(CapFloor::Type capFloorType, const Period &capFloorTenor, const ext::shared_ptr< IborIndex > &iborIndex, Rate strike=Null< Rate >(), const Period &forwardStart=0 *Days)
MakeCapFloor & withRule(DateGeneration::Rule r)
MakeCapFloor & withConvention(BusinessDayConvention bdc)
MakeCapFloor & withTerminationDateConvention(BusinessDayConvention bdc)
MakeCapFloor & withNextToLastDate(const Date &d)
MakeVanillaSwap & withEffectiveDate(const Date &)
MakeVanillaSwap & withFloatingLegFirstDate(const Date &d)
MakeVanillaSwap & withFloatingLegTerminationDateConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFloatingLegDayCount(const DayCounter &dc)
MakeVanillaSwap & withNominal(Real n)
MakeVanillaSwap & withFloatingLegCalendar(const Calendar &cal)
MakeVanillaSwap & withFloatingLegRule(DateGeneration::Rule r)
MakeVanillaSwap & withFloatingLegTenor(const Period &t)
MakeVanillaSwap & withFloatingLegNextToLastDate(const Date &d)
MakeVanillaSwap & withFloatingLegEndOfMonth(bool flag=true)
MakeVanillaSwap & withFloatingLegConvention(BusinessDayConvention bdc)
template class providing a null value for a given type.
Plain-vanilla swap: fix vs ibor leg.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
BusinessDayConvention
Business Day conventions.
Helper class to instantiate standard market cap/floor.
void swap(Array &v, Array &w) noexcept
std::vector< ext::shared_ptr< CashFlow > > Leg
Sequence of cash-flows.
ext::shared_ptr< YieldTermStructure > r