Skip to content

Commit 2bc9509

Browse files
damienbarkerjenkins
authored andcommitted
Merge branch 'QPR-13371' into 'master'
QPR-13371: update rate helpers constructors in ore-swig Closes QPR-13371 See merge request qs/oreplus!2751
1 parent b77a710 commit 2bc9509

3 files changed

Lines changed: 69 additions & 31 deletions

File tree

ORE-SWIG/QuantExt-SWIG/SWIG/qle_averageoisratehelper.i

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,20 @@ using QuantExt::AverageOISRateHelper;
3434
class AverageOISRateHelper : public RateHelper {
3535
public:
3636
AverageOISRateHelper(const QuantLib::Handle<QuantLib::Quote>& fixedRate,
37-
const QuantLib::Period& spotLagTenor,
38-
const QuantLib::Period& swapTenor,
39-
const QuantLib::Period& fixedTenor,
40-
const QuantLib::DayCounter& fixedDayCounter,
41-
const QuantLib::Calendar& fixedCalendar,
42-
QuantLib::BusinessDayConvention fixedConvention,
43-
QuantLib::BusinessDayConvention fixedPaymentAdjustment,
44-
ext::shared_ptr<OvernightIndex>& overnightIndex,
45-
const QuantLib::Period& onTenor,
46-
const QuantLib::Handle<QuantLib::Quote>& onSpread,
47-
QuantLib::Natural rateCutoff,
48-
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve = QuantLib::Handle<QuantLib::YieldTermStructure>());
37+
const QuantLib::Period& spotLagTenor,
38+
const QuantLib::Period& swapTenor,
39+
const QuantLib::Period& fixedTenor,
40+
const QuantLib::DayCounter& fixedDayCounter,
41+
const QuantLib::Calendar& fixedCalendar,
42+
QuantLib::BusinessDayConvention fixedConvention,
43+
QuantLib::BusinessDayConvention fixedPaymentAdjustment,
44+
const ext::shared_ptr<OvernightIndex>& overnightIndex, const bool onIndexGiven,
45+
const QuantLib::Period& onTenor,
46+
const QuantLib::Handle<QuantLib::Quote>& onSpread,
47+
QuantLib::Natural rateCutoff,
48+
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve
49+
= QuantLib::Handle<QuantLib::YieldTermStructure>(),
50+
const bool discountCurveGiven = false, const bool telescopicValueDates = false);
4951
QuantLib::Real onSpread() const;
5052
ext::shared_ptr<AverageOIS> averageOIS() const;
5153
};

ORE-SWIG/QuantExt-SWIG/SWIG/qle_ratehelpers.i

Lines changed: 20 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,10 @@ class CrossCcyBasisMtMResetSwapHelper : public RateHelper {
5050
const ext::shared_ptr<IborIndex>& domesticCcyIndex,
5151
const Handle<YieldTermStructure>& foreignCcyDiscountCurve,
5252
const Handle<YieldTermStructure>& domesticCcyDiscountCurve,
53+
const bool foreignIndexGiven,
54+
const bool domesticIndexGiven,
55+
const bool foreignDiscountCurveGiven,
56+
const bool domesticDiscountCurveGiven,
5357
const Handle<YieldTermStructure>& foreignCcyFxFwdRateCurve
5458
= Handle<YieldTermStructure>(),
5559
const Handle<YieldTermStructure>& domesticCcyFxFwdRateCurve
@@ -74,6 +78,9 @@ class CrossCcyBasisSwapHelper : public RateHelper {
7478
const ext::shared_ptr<IborIndex>& spreadIndex,
7579
const Handle<YieldTermStructure>& flatDiscountCurve,
7680
const Handle<YieldTermStructure>& spreadDiscountCurve,
81+
const bool flatIndexGiven, const bool spreadIndexGiven,
82+
const bool flatDiscountCurveGiven,
83+
const bool spreadDiscountCurveGiven,
7784
bool eom = false,
7885
bool flatIsDomestic = true);
7986
ext::shared_ptr<CrossCcyBasisSwap> swap();
@@ -82,18 +89,14 @@ class CrossCcyBasisSwapHelper : public RateHelper {
8289
%shared_ptr(TenorBasisSwapHelper)
8390
class TenorBasisSwapHelper : public RateHelper {
8491
public:
85-
TenorBasisSwapHelper(QuantLib::Handle<QuantLib::Quote> spread,
86-
const QuantLib::Period& swapTenor,
87-
const ext::shared_ptr<IborIndex> payIndex,
88-
const ext::shared_ptr<IborIndex> receiveIndex,
89-
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountingCurve
90-
= QuantLib::Handle<QuantLib::YieldTermStructure>(),
91-
bool spreadOnRec = true,
92-
bool includeSpread = false,
93-
const QuantLib::Period& payFrequency = QuantLib::Period(),
94-
const QuantLib::Period& recFrequency = QuantLib::Period(),
95-
const bool telescopicValueDates = false,
96-
QuantExt::SubPeriodsCoupon1::Type type = QuantExt::SubPeriodsCoupon1::Compounding);
92+
TenorBasisSwapHelper(QuantLib::Handle<QuantLib::Quote> spread, const QuantLib::Period& swapTenor,
93+
const ext::shared_ptr<IborIndex>& payIndex,
94+
const ext::shared_ptr<IborIndex>& receiveIndex,
95+
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountingCurve, const bool payIndexGiven,
96+
const bool receiveIndexGiven, const bool discountingGiven, const bool spreadOnRec = true,
97+
const bool includeSpread = false, const QuantLib::Period& payFrequency = QuantLib::Period(),
98+
const QuantLib::Period& recFrequency = QuantLib::Period(), const bool telescopicValueDates = false,
99+
const QuantExt::SubPeriodsCoupon1::Type type = QuantExt::SubPeriodsCoupon1::Compounding);
97100
ext::shared_ptr<TenorBasisSwap> swap();
98101
};
99102

@@ -125,13 +128,15 @@ class BasisTwoSwapHelper : public RateHelper {
125128
QuantLib::BusinessDayConvention longFixedConvention,
126129
const QuantLib::DayCounter& longFixedDayCount,
127130
const ext::shared_ptr<IborIndex>& longIndex,
131+
bool longIndexGiven,
128132
QuantLib::Frequency shortFixedFrequency,
129133
QuantLib::BusinessDayConvention shortFixedConvention,
130134
const QuantLib::DayCounter& shortFixedDayCount,
131135
const ext::shared_ptr<IborIndex>& shortIndex,
132-
bool longMinusShort = true,
133-
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountingCurve
134-
= QuantLib::Handle<QuantLib::YieldTermStructure>());
136+
bool longMinusShort, bool shortIndexGiven,
137+
const QuantLib::Handle<QuantLib::YieldTermStructure>& discountingCurve
138+
= QuantLib::Handle<QuantLib::YieldTermStructure>(),
139+
bool discountCurveGiven = false);
135140
ext::shared_ptr<VanillaSwap> longSwap();
136141
ext::shared_ptr<VanillaSwap> shortSwap();
137142
};

ORE-SWIG/test/test_ratehelpers.py

Lines changed: 35 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,11 @@ def setUp(self):
3232
self.rateCutoff=1
3333
self.flat_forward=FlatForward(self.todays_date, 0.03, self.fixedDayCounter)
3434
self.termStructureOIS=RelinkableYieldTermStructureHandle(self.flat_forward)
35-
self.averageOisRateHelper=AverageOISRateHelper(self.fixedRate,self.spotLagTenor,self.swapTenor,self.fixedTenor,self.fixedDayCounter,self.fixedCalendar,self.fixedConvention,self.fixedPaymentAdjustment,self.overnightIndex,self.onTenor,self.onSpread,self.rateCutoff,self.termStructureOIS)
35+
self.onIndexGiven=True
36+
self.averageOisRateHelper=AverageOISRateHelper(self.fixedRate,self.spotLagTenor,self.swapTenor,self.fixedTenor,
37+
self.fixedDayCounter,self.fixedCalendar,self.fixedConvention,
38+
self.fixedPaymentAdjustment,self.overnightIndex, self.onIndexGiven,
39+
self.onTenor, self.onSpread,self.rateCutoff,self.termStructureOIS)
3640

3741

3842
def testSimpleInspectors(self):
@@ -59,9 +63,18 @@ def setUp(self):
5963
self.flat_forward=FlatForward(self.todays_date, 0.03, self.fixedDayCounter)
6064
self.flatDiscountCurve=RelinkableYieldTermStructureHandle(self.flat_forward)
6165
self.spreadDiscountCurve=RelinkableYieldTermStructureHandle(self.flat_forward)
66+
self.flatIndexGiven=True
67+
self.spreadIndexGiven=True
68+
self.flatDiscountCurveGiven=True
69+
self.spreadDiscountCurveGiven=False
6270
self.eom=False
6371
self.flatIsDomestic=True
64-
self.ratehelper = CrossCcyBasisSwapHelper(self.spreadQuote, self.spotFX, self.settlementDays, self.settlementCalendar, self.swapTenor, self.rollConvention, self.flatIbor, self.spreadIbor, self.flatDiscountCurve, self.spreadDiscountCurve, self.eom, self.flatIsDomestic)
72+
self.ratehelper = CrossCcyBasisSwapHelper(self.spreadQuote, self.spotFX, self.settlementDays,
73+
self.settlementCalendar, self.swapTenor, self.rollConvention,
74+
self.flatIbor, self.spreadIbor, self.flatDiscountCurve,
75+
self.spreadDiscountCurve, self.flatIndexGiven, self.spreadIndexGiven,
76+
self.flatDiscountCurveGiven, self.spreadDiscountCurveGiven,
77+
self.eom, self.flatIsDomestic)
6578

6679
def testSimpleInspectors(self):
6780
""" Test Cross Curency Basis Swap Helper simple inspector. """
@@ -86,11 +99,20 @@ def setUp(self):
8699
self.fixedDayCounter=Actual360()
87100
self.flat_forward=FlatForward(self.todays_date, 0.03, self.fixedDayCounter)
88101
self.discountingCurve=RelinkableYieldTermStructureHandle(self.flat_forward)
102+
self.payIndexGiven=True
103+
self.receiveIndexGiven=True
104+
self.discountingCurveGiven=False
89105
self.spreadOnShort = True
90106
self.includeSpread = False
91107
self.telescopicValueDates = False
92108
self.type = SubPeriodsCoupon1.Compounding
93-
self.tenorbasisswaphelper=self.tenorbasisswaphelper=TenorBasisSwapHelper(self.spread,self.swapTenor,self.longIbor,self.shortIbor,self.discountingCurve,self.spreadOnShort,self.includeSpread,self.longPayTenor,self.shortPayTenor,self.telescopicValueDates,self.type)
109+
self.tenorbasisswaphelper=self.tenorbasisswaphelper=TenorBasisSwapHelper(self.spread,self.swapTenor,self.longIbor,
110+
self.shortIbor,self.discountingCurve,
111+
self.payIndexGiven, self.receiveIndexGiven,
112+
self.discountingCurveGiven,
113+
self.spreadOnShort,self.includeSpread,
114+
self.longPayTenor,self.shortPayTenor,
115+
self.telescopicValueDates,self.type)
94116

95117

96118
def testSimpleInspectors(self):
@@ -133,15 +155,24 @@ def setUp(self):
133155
self.longFixedConvention=Following
134156
self.longFixedDayCount=Actual360()
135157
self.longFloat=Eonia()
158+
self.longIndexGiven=True
136159
self.shortFixedFrequency=Annual
137160
self.shortFixedConvention=Following
138161
self.shortFixedDayCount=Actual360()
139162
self.flat_forward=FlatForward(self.todays_date, 0.03, Actual360())
140163
self.ffcurve=RelinkableYieldTermStructureHandle(self.flat_forward)
141164
self.shortFloat=FedFunds(self.ffcurve)
142165
self.longMinusShort=True
166+
self.shortIndexGiven=True
143167
self.discountingCurve=RelinkableYieldTermStructureHandle(self.flat_forward)
144-
self.basistwoswaphelper=BasisTwoSwapHelper(self.spread,self.swapTenor,self.calendar,self.longFixedFrequency,self.longFixedConvention,self.longFixedDayCount,self.longFloat,self.shortFixedFrequency,self.shortFixedConvention,self.shortFixedDayCount,self.shortFloat,self.longMinusShort,self.discountingCurve)
168+
self.discountCurveGiven=False
169+
self.basistwoswaphelper=BasisTwoSwapHelper(self.spread,self.swapTenor,self.calendar,
170+
self.longFixedFrequency,self.longFixedConvention,
171+
self.longFixedDayCount,self.longFloat,
172+
self.longIndexGiven, self.shortFixedFrequency,
173+
self.shortFixedConvention,self.shortFixedDayCount,
174+
self.shortFloat,self.longMinusShort,self.shortIndexGiven,
175+
self.discountingCurve, self.discountCurveGiven)
145176

146177

147178
def testSimpleInspectors(self):

0 commit comments

Comments
 (0)