23#include <ql/instruments/makeois.hpp>
24#include <ql/pricingengines/swap/discountingswapengine.hpp>
25#include <ql/indexes/iborindex.hpp>
26#include <ql/time/schedule.hpp>
31 const ext::shared_ptr<OvernightIndex>& overnightIndex,
33 const Period& forwardStart)
34 : swapTenor_(swapTenor), overnightIndex_(overnightIndex), fixedRate_(fixedRate),
35 forwardStart_(forwardStart),
37 calendar_(overnightIndex->fixingCalendar()),
39 fixedDayCount_(overnightIndex->dayCounter()) {}
42 ext::shared_ptr<OvernightIndexedSwap> ois = *
this;
46 MakeOIS::operator ext::shared_ptr<OvernightIndexedSwap>()
const {
49 if (effectiveDate_ !=
Date())
50 startDate = effectiveDate_;
55 refDate = calendar_.adjust(refDate);
57 settlementDays_*
Days);
58 startDate = spotDate+forwardStart_;
59 if (forwardStart_.length()<0)
60 startDate = calendar_.adjust(startDate,
Preceding);
62 startDate = calendar_.adjust(startDate,
Following);
67 isDefaultEOM_ ? calendar_.
isEndOfMonth(startDate) : endOfMonth_;
69 Date endDate = terminationDate_;
70 if (endDate ==
Date()) {
72 endDate = calendar_.
advance(startDate,
77 endDate = startDate + swapTenor_;
80 Schedule schedule(startDate, endDate,
88 Rate usedFixedRate = fixedRate_;
94 overnightIndex_, overnightSpread_,
95 paymentLag_, paymentAdjustment_,
96 paymentCalendar_, telescopicValueDates_);
97 if (engine_ ==
nullptr) {
99 overnightIndex_->forwardingTermStructure();
100 QL_REQUIRE(!disc.
empty(),
101 "null term structure set to this instance of " <<
102 overnightIndex_->name());
103 bool includeSettlementDateFlows =
false;
104 ext::shared_ptr<PricingEngine> engine(
new
113 ext::shared_ptr<OvernightIndexedSwap> ois(
new
116 usedFixedRate, fixedDayCount_,
117 overnightIndex_, overnightSpread_,
118 paymentLag_, paymentAdjustment_,
119 paymentCalendar_, telescopicValueDates_,
122 if (engine_ ==
nullptr) {
124 overnightIndex_->forwardingTermStructure();
125 bool includeSettlementDateFlows =
false;
126 ext::shared_ptr<PricingEngine> engine(
new
128 ois->setPricingEngine(engine);
130 ois->setPricingEngine(engine_);
198 bool includeSettlementDateFlows =
false;
199 engine_ = ext::shared_ptr<PricingEngine>(
new
205 const ext::shared_ptr<PricingEngine>& engine) {
static bool isEndOfMonth(const Date &d)
whether a date is the last day of its month
static Date advance(const Date &d, Integer units, TimeUnit)
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.
BusinessDayConvention paymentAdjustment_
bool telescopicValueDates_
MakeOIS & withPaymentAdjustment(BusinessDayConvention convention)
MakeOIS & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountingTermStructure)
MakeOIS & withType(Swap::Type type)
MakeOIS(const Period &swapTenor, const ext::shared_ptr< OvernightIndex > &overnightIndex, Rate fixedRate=Null< Rate >(), const Period &fwdStart=0 *Days)
MakeOIS & withSettlementDays(Natural settlementDays)
Calendar paymentCalendar_
DayCounter fixedDayCount_
MakeOIS & receiveFixed(bool flag=true)
MakeOIS & withPaymentFrequency(Frequency f)
MakeOIS & withFixedLegDayCount(const DayCounter &dc)
MakeOIS & withRule(DateGeneration::Rule r)
MakeOIS & withPaymentLag(Natural lag)
MakeOIS & withPricingEngine(const ext::shared_ptr< PricingEngine > &engine)
DateGeneration::Rule rule_
RateAveraging::Type averagingMethod_
MakeOIS & withPaymentCalendar(const Calendar &cal)
MakeOIS & withTerminationDate(const Date &)
MakeOIS & withEffectiveDate(const Date &)
MakeOIS & withOvernightLegSpread(Spread sp)
ext::shared_ptr< PricingEngine > engine_
MakeOIS & withEndOfMonth(bool flag=true)
MakeOIS & withNominal(Real n)
MakeOIS & withAveragingMethod(RateAveraging::Type averagingMethod)
MakeOIS & withTelescopicValueDates(bool telescopicValueDates)
Frequency paymentFrequency_
template class providing a null value for a given type.
Overnight indexed swap: fix vs compounded overnight rate.
DateProxy & evaluationDate()
the date at which pricing is to be performed.
static Settings & instance()
access to the unique instance
Frequency
Frequency of events.
BusinessDayConvention
Business Day conventions.
@ Once
only once, e.g., a zero-coupon
unsigned QL_INTEGER Natural
positive integer
Real Spread
spreads on interest rates