1818
1919#include < qle/instruments/brlcdiswap.hpp>
2020
21- #include < boost/assign/list_of.hpp>
2221#include < ql/cashflows/overnightindexedcoupon.hpp>
2322#include < ql/cashflows/simplecashflow.hpp>
2423#include < ql/time/daycounters/business252.hpp>
2726#include < qle/cashflows/couponpricer.hpp>
2827
2928using namespace QuantLib ;
30- using boost::assign::list_of;
3129using std::pow;
3230using std::vector;
3331
3432namespace QuantExt {
3533
36- // Reason for use of convert_to_container:
37- // https://stackoverflow.com/a/17805923/1771882
3834BRLCdiSwap::BRLCdiSwap (Type type, Real nominal, const Date& startDate, const Date& endDate, Rate fixedRate,
3935 const boost::shared_ptr<BRLCdi>& overnightIndex, Spread spread, bool telescopicValueDates)
4036 : OvernightIndexedSwap(type, nominal,
41- Schedule (list_of( startDate)(endDate).convert_to_container<vector<Date> >() , NullCalendar(),
37+ Schedule ({ startDate, endDate} , NullCalendar(),
4238 QuantLib::Unadjusted, QuantLib::Unadjusted, 100 * Years),
4339 fixedRate, overnightIndex->dayCounter(), overnightIndex, spread, 0, ModifiedFollowing,
4440 overnightIndex->fixingCalendar(), telescopicValueDates),
@@ -68,9 +64,9 @@ Real BRLCdiSwap::fixedLegBPS() const {
6864
6965 calculate ();
7066
71- static Spread basisPoint = 1.0e-4 ;
67+ const Spread basisPoint = 1.0e-4 ;
7268 if (!close (endDiscounts_[0 ], 0.0 ) && endDiscounts_[0 ] != Null<DiscountFactor>()) {
73- DiscountFactor df = endDiscounts_[0 ];
69+ DiscountFactor df = payer_[ 0 ] * endDiscounts_[0 ];
7470 Time dcf = index_->dayCounter ().yearFraction (startDate_, endDate_);
7571 legBPS_[0 ] = df * nominal () * (pow (1.0 + fixedRate () + basisPoint, dcf) - pow (1.0 + fixedRate (), dcf));
7672 return legBPS_[0 ];
@@ -84,7 +80,7 @@ Real BRLCdiSwap::fairRate() const {
8480 calculate ();
8581
8682 if (!close (endDiscounts_[0 ], 0.0 ) && endDiscounts_[0 ] != Null<DiscountFactor>()) {
87- DiscountFactor df = endDiscounts_[0 ];
83+ DiscountFactor df = -payer_[ 0 ] * endDiscounts_[0 ];
8884 Time dcf = index_->dayCounter ().yearFraction (startDate_, endDate_);
8985 return pow (overnightLegNPV () / (nominal () * df) + 1.0 , 1.0 / dcf) - 1.0 ;
9086 }
0 commit comments