19#include <ql/pricingengines/swap/discountingswapengine.hpp>
20#include <ql/time/calendars/weekendsonly.hpp>
27 const Period& onTenor, Rate fixedRate,
const Period& fixedTenor,
28 const DayCounter& fixedDayCounter,
const Period& spotLagTenor,
29 const Period& forwardStart)
30 : swapTenor_(swapTenor), overnightIndex_(overnightIndex), onTenor_(onTenor), fixedRate_(fixedRate),
31 fixedTenor_(fixedTenor), fixedDayCounter_(fixedDayCounter), spotLagTenor_(spotLagTenor),
32 forwardStart_(forwardStart), type_(
AverageOIS::Receiver), nominal_(1.0), effectiveDate_(Date()),
33 spotLagCalendar_(overnightIndex->fixingCalendar()), fixedCalendar_(WeekendsOnly()), fixedConvention_(Unadjusted),
34 fixedTerminationDateConvention_(Unadjusted), fixedRule_(DateGeneration::Backward), fixedEndOfMonth_(false),
35 fixedFirstDate_(Date()), fixedNextToLastDate_(Date()),
36 fixedPaymentAdjustment_(overnightIndex->businessDayConvention()),
37 fixedPaymentCalendar_(overnightIndex->fixingCalendar()), onCalendar_(overnightIndex->fixingCalendar()),
38 onConvention_(overnightIndex->businessDayConvention()),
39 onTerminationDateConvention_(overnightIndex->businessDayConvention()), onRule_(DateGeneration::Backward),
40 onEndOfMonth_(false), onFirstDate_(Date()), onNextToLastDate_(Date()), rateCutoff_(0), onSpread_(0.0),
41 onGearing_(1.0), onDayCounter_(overnightIndex->dayCounter()),
42 onPaymentAdjustment_(overnightIndex->businessDayConvention()),
43 onPaymentCalendar_(overnightIndex->fixingCalendar()), telescopicValueDates_(false),
47 QuantLib::ext::shared_ptr<AverageOIS> swap = *
this;
51MakeAverageOIS::operator QuantLib::ext::shared_ptr<AverageOIS>()
const {
55 if (effectiveDate_ != Date()) {
56 effectiveDate = effectiveDate_;
58 Date valuationDate = Settings::instance().evaluationDate();
61 valuationDate = spotLagCalendar_.adjust(valuationDate);
62 Date spotDate = spotLagCalendar_.advance(valuationDate, spotLagTenor_);
63 effectiveDate = spotDate + forwardStart_;
68 if (terminationDate_ != Date()) {
69 terminationDate = terminationDate_;
71 terminationDate = effectiveDate + swapTenor_;
74 Schedule fixedSchedule(effectiveDate, terminationDate, fixedTenor_, fixedCalendar_, fixedConvention_,
75 fixedTerminationDateConvention_, fixedRule_, fixedEndOfMonth_, fixedFirstDate_,
76 fixedNextToLastDate_);
78 Schedule onSchedule(effectiveDate, terminationDate, onTenor_, onCalendar_, onConvention_,
79 onTerminationDateConvention_, onRule_, onEndOfMonth_, onFirstDate_, onNextToLastDate_);
81 QuantLib::ext::shared_ptr<AverageOIS> swap(
82 new AverageOIS(type_, nominal_, fixedSchedule, fixedRate_, fixedDayCounter_, fixedPaymentAdjustment_,
83 fixedPaymentCalendar_, onSchedule, overnightIndex_, onPaymentAdjustment_, onPaymentCalendar_,
84 rateCutoff_, onSpread_, onGearing_, onDayCounter_, onCouponPricer_, telescopicValueDates_));
86 swap->setPricingEngine(
engine_);
250 bool includeSettlementDateFlows =
false;
251 engine_ = QuantLib::ext::shared_ptr<PricingEngine>(
new DiscountingSwapEngine(discountCurve, includeSettlementDateFlows));
QuantLib::ext::shared_ptr< PricingEngine > engine_
Average overnight index swap.
Type
Receiver (Payer) means receive (pay) fixed.
Pricer for average overnight indexed coupons.
BusinessDayConvention fixedConvention_
MakeAverageOIS & withONCalendar(const Calendar &onCalendar)
bool telescopicValueDates_
Date fixedNextToLastDate_
MakeAverageOIS & withFixedConvention(BusinessDayConvention fixedConvention)
BusinessDayConvention fixedPaymentAdjustment_
MakeAverageOIS & withFixedPaymentCalendar(const Calendar &fixedPaymentCalendar)
MakeAverageOIS & withTelescopicValueDates(bool telescopicValueDates)
MakeAverageOIS & withONRule(DateGeneration::Rule onRule)
MakeAverageOIS & withONNextToLastDate(const Date &onNextToLastDate)
Calendar spotLagCalendar_
MakeAverageOIS & receiveFixed(bool receiveFixed=true)
MakeAverageOIS & withRateCutoff(Natural rateCutoff)
MakeAverageOIS & withRule(DateGeneration::Rule rule)
BusinessDayConvention onPaymentAdjustment_
MakeAverageOIS & withONGearing(Real onGearing)
MakeAverageOIS & withONSpread(Spread onSpread)
MakeAverageOIS & withONFirstDate(const Date &onFirstDate)
MakeAverageOIS & withType(AverageOIS::Type type)
QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > onCouponPricer_
MakeAverageOIS & withFixedRule(DateGeneration::Rule fixedRule)
QuantLib::ext::shared_ptr< PricingEngine > engine_
MakeAverageOIS & withFixedPaymentAdjustment(BusinessDayConvention fixedPaymentAdjustment)
BusinessDayConvention onTerminationDateConvention_
MakeAverageOIS & withONDayCounter(const DayCounter &onDayCounter)
Calendar onPaymentCalendar_
MakeAverageOIS & withFixedFirstDate(const Date &fixedFirstDate)
MakeAverageOIS & withONEndOfMonth(bool onEndOfMonth=false)
DateGeneration::Rule fixedRule_
DateGeneration::Rule onRule_
BusinessDayConvention onConvention_
MakeAverageOIS & withEffectiveDate(const Date &effectiveDate)
MakeAverageOIS & withONConvention(BusinessDayConvention onConvention)
MakeAverageOIS & withONPaymentAdjustment(BusinessDayConvention onPaymentAdjustment)
Calendar fixedPaymentCalendar_
MakeAverageOIS & withFixedNextToLastDate(const Date &fixedNextToLastDate)
MakeAverageOIS & withFixedEndOfMonth(bool fixedEndOfMonth=false)
BusinessDayConvention fixedTerminationDateConvention_
MakeAverageOIS & withPricingEngine(const QuantLib::ext::shared_ptr< PricingEngine > &engine)
MakeAverageOIS(const Period &swapTenor, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, const Period &onTenor, Rate fixedRate, const Period &fixedTenor, const DayCounter &fixedDayCounter, const Period &spotLagTenor=2 *Days, const Period &forwardStart=0 *Days)
MakeAverageOIS & withONCouponPricer(const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer)
MakeAverageOIS & withNominal(Real nominal)
MakeAverageOIS & withTerminationDate(const Date &terminationDate)
MakeAverageOIS & withDiscountingTermStructure(const Handle< YieldTermStructure > &discountCurve)
MakeAverageOIS & withFixedTerminationDateConvention(BusinessDayConvention fixedTerminationDateConvention)
MakeAverageOIS & withSpotLagCalendar(const Calendar &spotLagCalendar)
MakeAverageOIS & withONPaymentCalendar(const Calendar &onPaymentCalendar)
MakeAverageOIS & withONTerminationDateConvention(BusinessDayConvention onTerminationDateConvention)
MakeAverageOIS & withFixedCalendar(const Calendar &fixedCalendar)
Helper class to instantiate standard average ON indexed swaps.