19#include <ql/cashflows/fixedratecoupon.hpp>
27 const DayCounter& fixedDCB, BusinessDayConvention fixedLegPaymentAdjustment,
28 const Calendar& fixedLegPaymentCalendar,
const Schedule& onLegSchedule,
29 const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex,
30 BusinessDayConvention onLegPaymentAdjustment,
const Calendar& onLegPaymentCalendar,
31 Natural rateCutoff, Spread onLegSpread, Real onLegGearing,
const DayCounter& onLegDCB,
32 const QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>& onLegCouponPricer,
33 const bool telescopicValueDates)
34 : Swap(2), type_(type), nominals_(std::vector<Real>(1, nominal)), fixedRates_(std::vector<Rate>(1, fixedRate)),
35 fixedDayCounter_(fixedDCB), fixedPaymentAdjustment_(fixedLegPaymentAdjustment),
36 fixedPaymentCalendar_(fixedLegPaymentCalendar), overnightIndex_(overnightIndex),
37 onPaymentAdjustment_(onLegPaymentAdjustment), onPaymentCalendar_(onLegPaymentCalendar), rateCutoff_(rateCutoff),
38 onSpreads_(std::vector<Spread>(1, onLegSpread)), onGearings_(std::vector<Real>(1, onLegGearing)),
39 onDayCounter_(onLegDCB), onCouponPricer_(onLegCouponPricer), telescopicValueDates_(telescopicValueDates) {
44 std::vector<Rate> fixedRates,
const DayCounter& fixedDCB,
45 BusinessDayConvention fixedLegPaymentAdjustment,
const Calendar& fixedLegPaymentCalendar,
46 const Schedule& onLegSchedule,
const QuantLib::ext::shared_ptr<OvernightIndex>& overnightIndex,
47 BusinessDayConvention onLegPaymentAdjustment,
const Calendar& onLegPaymentCalendar,
48 Natural rateCutoff, std::vector<Spread> onLegSpreads, std::vector<Real> onLegGearings,
49 const DayCounter& onLegDCB,
50 const QuantLib::ext::shared_ptr<AverageONIndexedCouponPricer>& onLegCouponPricer,
51 const bool telescopicValueDates)
52 : Swap(2), type_(type), nominals_(nominals), fixedRates_(fixedRates), fixedDayCounter_(fixedDCB),
53 fixedPaymentAdjustment_(fixedLegPaymentAdjustment), fixedPaymentCalendar_(fixedLegPaymentCalendar),
54 overnightIndex_(overnightIndex), onPaymentAdjustment_(onLegPaymentAdjustment),
55 onPaymentCalendar_(onLegPaymentCalendar), rateCutoff_(rateCutoff), onSpreads_(onLegSpreads),
56 onGearings_(onLegGearings), onDayCounter_(onLegDCB), onCouponPricer_(onLegCouponPricer),
57 telescopicValueDates_(telescopicValueDates) {
63 legs_[0] = FixedRateLeg(fixedLegSchedule)
84 legs_[1] = tempAverageONLeg;
97 QL_FAIL(
"Unknown average ON index swap type");
102 QL_REQUIRE(
nominals_.size() == 1,
"Swap has varying nominals");
107 QL_REQUIRE(
fixedRates_.size() == 1,
"Swap has varying fixed rates");
112 QL_REQUIRE(
onSpreads_.size() == 1,
"Swap has varying ON spreads");
117 QL_REQUIRE(
onGearings_.size() == 1,
"Swap has varying ON gearings");
123 QL_REQUIRE(legBPS_[0] != Null<Real>(),
"fixedLegBPS not available");
129 QL_REQUIRE(legNPV_[0] != Null<Real>(),
"fixedLegNPV not available");
134 static const Spread basisPoint = 1.0e-4;
141 QL_REQUIRE(legBPS_[1] != Null<Real>(),
"overnightLegBPS not available");
147 QL_REQUIRE(legNPV_[1] != Null<Real>(),
"overnightLegNPV not available");
152 QL_REQUIRE(
onSpreads_.size() == 1,
"fairSpread not implemented for varying spreads.");
153 static const Spread basisPoint = 1.0e-4;
Swap of arithmetic average overnight index against fixed.
QuantLib::ext::shared_ptr< OvernightIndex > overnightIndex_
bool telescopicValueDates_
Type
Receiver (Payer) means receive (pay) fixed.
DayCounter fixedDayCounter_
BusinessDayConvention fixedPaymentAdjustment_
Spread fairSpread() const
BusinessDayConvention onPaymentAdjustment_
void initialize(const Schedule &fixedLegSchedule, const Schedule &onLegSchedule)
std::vector< Rate > fixedRates_
QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > onCouponPricer_
std::vector< Spread > onSpreads_
Calendar onPaymentCalendar_
Calendar fixedPaymentCalendar_
void setONIndexedCouponPricer(const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer)
AverageOIS(Type type, Real nominal, const Schedule &fixedSchedule, Rate fixedRate, const DayCounter &fixedDayCounter, BusinessDayConvention fixedPaymentAdjustment, const Calendar &fixedPaymentCalendar, const Schedule &onSchedule, const QuantLib::ext::shared_ptr< OvernightIndex > &overnightIndex, BusinessDayConvention onPaymentAdjustment, const Calendar &onPaymentCalendar, Natural rateCutoff=0, Spread onSpread=0.0, Real onGearing=1.0, const DayCounter &onDayCounter=DayCounter(), const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &onCouponPricer=QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer >(), const bool telescopicValueDates=false)
Arithmetic average ON leg vs. fixed leg constructor.
Real overnightLegBPS() const
Real overnightLegNPV() const
std::vector< Real > onGearings_
std::vector< Real > nominals_
helper class building a sequence of overnight coupons
AverageONLeg & withPaymentDayCounter(const DayCounter &dayCounter)
AverageONLeg & withRateCutoff(Natural rateCutoff)
AverageONLeg & withPaymentCalendar(const Calendar &calendar)
AverageONLeg & withTelescopicValueDates(bool telescopicValueDates)
AverageONLeg & withPaymentAdjustment(BusinessDayConvention convention)
AverageONLeg & withNotionals(const std::vector< Real > ¬ionals)
AverageONLeg & withSpreads(const std::vector< Spread > &spreads)
AverageONLeg & withAverageONIndexedCouponPricer(const QuantLib::ext::shared_ptr< AverageONIndexedCouponPricer > &couponPricer)
AverageONLeg & withGearings(const std::vector< Real > &gearings)
Utility functions for setting coupon pricers on legs.
void setCouponPricer(const Leg &leg, const QuantLib::ext::shared_ptr< FloatingRateCouponPricer > &pricer)
Set Coupon Pricer.