21#include <ql/cashflows/cashflows.hpp>
22#include <ql/exercise.hpp>
23#include <ql/indexes/swapindex.hpp>
24#include <ql/instruments/makeswaption.hpp>
25#include <ql/instruments/makevanillaswap.hpp>
26#include <ql/pricingengines/swap/discountingswapengine.hpp>
27#include <ql/optional.hpp>
28#include <ql/settings.hpp>
36 : swapIndex_(
std::move(swapIndex)), delivery_(
Settlement::Physical),
37 settlementMethod_(
Settlement::PhysicalOTC), optionTenor_(optionTenor),
39 underlyingType_(
Swap::Payer), nominal_(1.0) {}
42 const Date& fixingDate,
44 : swapIndex_(
std::move(swapIndex)), delivery_(
Settlement::Physical),
46 fixingDate_(fixingDate), strike_(strike), underlyingType_(
Swap::Payer) {}
49 ext::shared_ptr<Swaption> swaption = *
this;
53 MakeSwaption::operator ext::shared_ptr<Swaption>()
const {
55 const Calendar& fixingCalendar = swapIndex_->fixingCalendar();
59 refDate = fixingCalendar.
adjust(refDate);
61 fixingDate_ = fixingCalendar.
advance(refDate, optionTenor_,
64 exercise_ = ext::shared_ptr<Exercise>(
new
67 QL_REQUIRE(exerciseDate_ <= fixingDate_,
68 "exercise date (" << exerciseDate_ <<
") must be less "
69 "than or equal to fixing date (" << fixingDate_ <<
")");
70 exercise_ = ext::shared_ptr<Exercise>(
new
74 Rate usedStrike = strike_;
77 QL_REQUIRE(!swapIndex_->forwardingTermStructure().empty(),
78 "null term structure set to this instance of " <<
80 ext::shared_ptr<VanillaSwap> temp =
81 swapIndex_->underlyingSwap(fixingDate_);
82 temp->setPricingEngine(
84 swapIndex_->exogenousDiscount()
85 ? swapIndex_->discountingTermStructure()
86 : swapIndex_->forwardingTermStructure(),
88 usedStrike = temp->fairRate();
94 swapIndex_->iborIndex(), usedStrike)
105 ext::shared_ptr<Swaption> swaption(
new Swaption(
106 underlyingSwap_, exercise_, delivery_, settlementMethod_));
107 swaption->setPricingEngine(engine_);
139 const ext::shared_ptr<PricingEngine>& engine) {
Date adjust(const Date &, BusinessDayConvention convention=Following) const
Date advance(const Date &, Integer n, TimeUnit unit, BusinessDayConvention convention=Following, bool endOfMonth=false) const
BusinessDayConvention optionConvention_
MakeSwaption & withOptionConvention(BusinessDayConvention bdc)
MakeSwaption & withExerciseDate(const Date &)
ext::optional< bool > useIndexedCoupons_
MakeSwaption & withAtParCoupons(bool b=true)
MakeSwaption & withIndexedCoupons(const ext::optional< bool > &b=true)
MakeSwaption & withNominal(Real n)
Settlement::Type delivery_
ext::shared_ptr< PricingEngine > engine_
MakeSwaption & withSettlementMethod(Settlement::Method settlementMethod)
MakeSwaption & withPricingEngine(const ext::shared_ptr< PricingEngine > &engine)
Settlement::Method settlementMethod_
MakeSwaption & withSettlementType(Settlement::Type delivery)
Swap::Type underlyingType_
MakeSwaption(ext::shared_ptr< SwapIndex > swapIndex, const Period &optionTenor, Rate strike=Null< Rate >())
MakeSwaption & withUnderlyingType(Swap::Type type)
MakeVanillaSwap & withEffectiveDate(const Date &)
MakeVanillaSwap & withFixedLegConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFixedLegTerminationDateConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFixedLegCalendar(const Calendar &cal)
MakeVanillaSwap & withIndexedCoupons(const ext::optional< bool > &b=true)
MakeVanillaSwap & withFixedLegDayCount(const DayCounter &dc)
MakeVanillaSwap & withNominal(Real n)
MakeVanillaSwap & withType(Swap::Type type)
MakeVanillaSwap & withFixedLegTenor(const Period &t)
template class providing a null value for a given type.
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
BusinessDayConvention
Business Day conventions.