41 const ext::shared_ptr<IborIndex>& index,
43 const Period& forwardStart)
44 : swapTenor_(swapTenor), iborIndex_(index), fixedRate_(fixedRate), forwardStart_(forwardStart),
45 settlementDays_(
Null<
Natural>()), fixedCalendar_(index->fixingCalendar()),
46 floatCalendar_(index->fixingCalendar()),
48 floatTenor_(index->tenor()),
50 floatConvention_(index->businessDayConvention()),
51 floatTerminationDateConvention_(index->businessDayConvention()),
53 floatDayCount_(index->dayCounter()) {}
56 ext::shared_ptr<VanillaSwap>
swap = *
this;
60 MakeVanillaSwap::operator ext::shared_ptr<VanillaSwap>()
const {
63 if (effectiveDate_ !=
Date())
64 startDate = effectiveDate_;
69 refDate = floatCalendar_.adjust(refDate);
74 spotDate = iborIndex_->valueDate(refDate);
76 spotDate = floatCalendar_.
advance(refDate, settlementDays_ *
Days);
77 startDate = spotDate+forwardStart_;
78 if (forwardStart_.length()<0)
79 startDate = floatCalendar_.adjust(startDate,
81 else if (forwardStart_.length()>0)
82 startDate = floatCalendar_.adjust(startDate,
87 Date endDate = terminationDate_;
88 if (endDate ==
Date()) {
90 endDate = floatCalendar_.
advance(startDate,
95 endDate = startDate + swapTenor_;
98 const Currency& curr = iborIndex_->currency();
100 if (fixedTenor_ !=
Period())
101 fixedTenor = fixedTenor_;
117 QL_FAIL(
"unknown fixed leg default tenor for " << curr);
120 Schedule fixedSchedule(startDate, endDate,
121 fixedTenor, fixedCalendar_,
123 fixedTerminationDateConvention_,
124 fixedRule_, fixedEndOfMonth_,
125 fixedFirstDate_, fixedNextToLastDate_);
127 Schedule floatSchedule(startDate, endDate,
128 floatTenor_, floatCalendar_,
130 floatTerminationDateConvention_,
131 floatRule_, floatEndOfMonth_,
132 floatFirstDate_, floatNextToLastDate_);
136 fixedDayCount = fixedDayCount_;
148 QL_FAIL(
"unknown fixed leg day counter for " << curr);
151 Rate usedFixedRate = fixedRate_;
155 fixedDayCount, floatSchedule, iborIndex_, floatSpread_, floatDayCount_,
156 paymentConvention_, useIndexedCoupons_);
159 iborIndex_->forwardingTermStructure();
161 "null term structure set to this instance of " <<
163 bool includeSettlementDateFlows =
false;
164 ext::shared_ptr<PricingEngine> engine(
new
174 type_, nominal_, fixedSchedule, usedFixedRate, fixedDayCount, floatSchedule, iborIndex_,
175 floatSpread_, floatDayCount_, paymentConvention_, useIndexedCoupons_));
179 iborIndex_->forwardingTermStructure();
180 bool includeSettlementDateFlows =
false;
181 ext::shared_ptr<PricingEngine> engine(
new
183 swap->setPricingEngine(engine);
237 bool includeSettlementDateFlows =
false;
238 engine_ = ext::shared_ptr<PricingEngine>(
new
244 const ext::shared_ptr<PricingEngine>& engine) {
Actual/365 (Fixed) day counter.
ext::shared_ptr< PricingEngine > engine_
Actual/360 day count convention.
Actual/365 (Fixed) day count convention.
static Date advance(const Date &d, Integer units, TimeUnit)
Discounting engine for swaps.
Shared handle to an observable.
bool empty() const
checks if the contained shared pointer points to anything
void setPricingEngine(const ext::shared_ptr< PricingEngine > &)
set the pricing engine to be used.
MakeVanillaSwap & receiveFixed(bool flag=true)
MakeVanillaSwap & withFixedLegFirstDate(const Date &d)
MakeVanillaSwap & withEffectiveDate(const Date &)
MakeVanillaSwap & withFixedLegConvention(BusinessDayConvention bdc)
BusinessDayConvention fixedConvention_
MakeVanillaSwap & withFixedLegTerminationDateConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFloatingLegFirstDate(const Date &d)
MakeVanillaSwap & withFixedLegCalendar(const Calendar &cal)
MakeVanillaSwap & withFloatingLegTerminationDateConvention(BusinessDayConvention bdc)
Date fixedNextToLastDate_
Date floatNextToLastDate_
MakeVanillaSwap & withTerminationDate(const Date &)
MakeVanillaSwap & withAtParCoupons(bool b=true)
MakeVanillaSwap & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountCurve)
DateGeneration::Rule floatRule_
DayCounter fixedDayCount_
MakeVanillaSwap & withIndexedCoupons(const ext::optional< bool > &b=true)
MakeVanillaSwap & withPricingEngine(const ext::shared_ptr< PricingEngine > &engine)
MakeVanillaSwap & withSettlementDays(Natural settlementDays)
MakeVanillaSwap(const Period &swapTenor, const ext::shared_ptr< IborIndex > &iborIndex, Rate fixedRate=Null< Rate >(), const Period &forwardStart=0 *Days)
MakeVanillaSwap & withFixedLegDayCount(const DayCounter &dc)
DayCounter floatDayCount_
MakeVanillaSwap & withFixedLegEndOfMonth(bool flag=true)
MakeVanillaSwap & withFloatingLegDayCount(const DayCounter &dc)
ext::optional< bool > useIndexedCoupons_
BusinessDayConvention floatTerminationDateConvention_
MakeVanillaSwap & withRule(DateGeneration::Rule r)
MakeVanillaSwap & withFloatingLegSpread(Spread sp)
MakeVanillaSwap & withNominal(Real n)
MakeVanillaSwap & withFloatingLegCalendar(const Calendar &cal)
DateGeneration::Rule fixedRule_
ext::shared_ptr< PricingEngine > engine_
ext::optional< BusinessDayConvention > paymentConvention_
BusinessDayConvention fixedTerminationDateConvention_
MakeVanillaSwap & withFloatingLegRule(DateGeneration::Rule r)
MakeVanillaSwap & withFloatingLegTenor(const Period &t)
MakeVanillaSwap & withFixedLegRule(DateGeneration::Rule r)
MakeVanillaSwap & withType(Swap::Type type)
MakeVanillaSwap & withFloatingLegNextToLastDate(const Date &d)
MakeVanillaSwap & withFloatingLegEndOfMonth(bool flag=true)
MakeVanillaSwap & withFloatingLegConvention(BusinessDayConvention bdc)
BusinessDayConvention floatConvention_
MakeVanillaSwap & withPaymentConvention(BusinessDayConvention bdc)
MakeVanillaSwap & withFixedLegNextToLastDate(const Date &d)
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
30/360 day count convention
Plain-vanilla swap: fix vs ibor leg.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
ext::function< Real(Real)> b
BusinessDayConvention
Business Day conventions.
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates
base class for Inter-Bank-Offered-Rate indexes
Helper class to instantiate standard market swaps.
void swap(Array &v, Array &w) noexcept
Maps optional to either the boost or std implementation.
ext::shared_ptr< YieldTermStructure > r