Skip to content

Commit 3c1eefa

Browse files
committed
Fix fixedLegBPS and fairRate for BRLCdiSwap
* fixedLegBPS sign was wrong * fairRate has to be the same for Payer and Receiver swaps
1 parent ce3294f commit 3c1eefa

1 file changed

Lines changed: 4 additions & 8 deletions

File tree

QuantExt/qle/instruments/brlcdiswap.cpp

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@
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>
@@ -27,18 +26,15 @@
2726
#include <qle/cashflows/couponpricer.hpp>
2827

2928
using namespace QuantLib;
30-
using boost::assign::list_of;
3129
using std::pow;
3230
using std::vector;
3331

3432
namespace QuantExt {
3533

36-
// Reason for use of convert_to_container:
37-
// https://stackoverflow.com/a/17805923/1771882
3834
BRLCdiSwap::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

Comments
 (0)