Skip to content

Commit 8e20c85

Browse files
committed
Merge branch 'feature/QPR-13466' into 'master'
QPR-13466: Added valuation dates to legs Closes QPR-13466 See merge request qs/oreplus!2852
2 parents 47a8dad + 8076606 commit 8e20c85

7 files changed

Lines changed: 191 additions & 25 deletions

File tree

OREData/ored/portfolio/legdata.cpp

Lines changed: 167 additions & 21 deletions
Large diffs are not rendered by default.

OREData/ored/portfolio/legdata.hpp

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,19 +223,20 @@ class FloatingLegData : public LegAdditionalData {
223223
QuantLib::Period lookback = 0 * Days, const Size rateCutoff = Null<Size>(),
224224
bool localCapFloor = false, const QuantLib::ext::optional<Period>& lastRecentPeriod = QuantLib::ext::nullopt,
225225
const std::string& lastRecentPeriodCalendar = std::string(), bool telescopicValueDates = false,
226-
const std::map<QuantLib::Date, double>& historicalFixings = {},
226+
const std::map<QuantLib::Date, double>& historicalFixings = {}, const ScheduleData& valuationSchedule = ScheduleData(),
227227
const string& frontStubShortIndex = std::string(), const string& frontStubLongIndex = std::string(),
228228
const string& frontStubRoundingType = std::string(), const string& frontStubRoundingPrecision = std::string(),
229229
const string& backStubShortIndex = std::string(), const string& backStubLongIndex = std::string(),
230230
const string& backStubRoundingType = std::string(), const string& backStubRoundingPrecision = std::string(),
231231
bool stubUseOriginalCurve = false)
232+
232233
: LegAdditionalData(LegType::Floating, true), index_(ore::data::internalIndexName(index)),
233234
fixingDays_(fixingDays), lookback_(lookback), rateCutoff_(rateCutoff), isInArrears_(isInArrears),
234235
isAveraged_(isAveraged), hasSubPeriods_(hasSubPeriods), includeSpread_(includeSpread), spreads_(spreads),
235236
spreadDates_(spreadDates), caps_(caps), capDates_(capDates), floors_(floors), floorDates_(floorDates),
236237
gearings_(gearings), gearingDates_(gearingDates), nakedOption_(nakedOption), localCapFloor_(localCapFloor),
237238
lastRecentPeriod_(lastRecentPeriod), lastRecentPeriodCalendar_(lastRecentPeriodCalendar),
238-
telescopicValueDates_(telescopicValueDates), historicalFixings_(historicalFixings),
239+
telescopicValueDates_(telescopicValueDates), historicalFixings_(historicalFixings), valuationSchedule_(valuationSchedule),
239240
frontStubShortIndex_(frontStubShortIndex), frontStubLongIndex_(frontStubLongIndex),
240241
frontStubRoundingType_(frontStubRoundingType), frontStubRoundingPrecision_(frontStubRoundingPrecision),
241242
backStubShortIndex_(backStubShortIndex), backStubLongIndex_(backStubLongIndex),
@@ -270,6 +271,7 @@ class FloatingLegData : public LegAdditionalData {
270271
ScheduleData fixingSchedule() const { return fixingSchedule_; }
271272
ScheduleData resetSchedule() const { return resetSchedule_; }
272273
const std::map<QuantLib::Date, double>& historicalFixings() const { return historicalFixings_; }
274+
ScheduleData valuationSchedule() const { return valuationSchedule_; }
273275
const string& frontStubShortIndex() const { return frontStubShortIndex_; }
274276
const string& frontStubLongIndex() const { return frontStubLongIndex_; }
275277
const string& frontStubRoundingType() const { return frontStubRoundingType_; }
@@ -322,6 +324,7 @@ class FloatingLegData : public LegAdditionalData {
322324
ScheduleData fixingSchedule_;
323325
ScheduleData resetSchedule_;
324326
std::map<QuantLib::Date, double> historicalFixings_;
327+
ScheduleData valuationSchedule_;
325328
string frontStubShortIndex_;
326329
string frontStubLongIndex_;
327330
string frontStubRoundingType_;
@@ -840,6 +843,7 @@ class EquityLegData : public LegAdditionalData {
840843
Real initialPrice() const { return initialPrice_; }
841844
Natural fixingDays() const { return fixingDays_; }
842845
ScheduleData valuationSchedule() const { return valuationSchedule_; }
846+
ScheduleData paymentSchedule() const { return paymentSchedule_; }
843847
const string& eqCurrency() const { return eqCurrency_; }
844848
const string& fxIndex() const { return fxIndex_; }
845849
bool notionalReset() const { return notionalReset_; }
@@ -860,6 +864,7 @@ class EquityLegData : public LegAdditionalData {
860864
bool notionalReset_ = false;
861865
Natural fixingDays_ = 0;
862866
ScheduleData valuationSchedule_;
867+
ScheduleData paymentSchedule_;
863868
string eqCurrency_ = "";
864869
string fxIndex_ = "";
865870
Real quantity_;
@@ -963,6 +968,7 @@ class LegData : public XMLSerializable {
963968
const ScheduleData& paymentSchedule() const { return paymentSchedule_; }
964969
bool strictNotionalDates() const { return strictNotionalDates_; }
965970
const bool isSimmPlainVanillaIrLeg() const { return concreteLegData_->isSimmPlainVanillaIrLeg(); };
971+
const ScheduleData& valuationSchedule() const { return valuationSchedule_; }
966972
const string& settlementFxIndex() const { return settlementFxIndex_; }
967973
const string& settlementFxFixingDate() const { return settlementFxFixingDate_; }
968974
//@}
@@ -1021,6 +1027,7 @@ class LegData : public XMLSerializable {
10211027
string lastPeriodDayCounter_;
10221028
ScheduleData paymentSchedule_;
10231029
bool strictNotionalDates_ = false;
1030+
ScheduleData valuationSchedule_;
10241031
string settlementFxIndex_;
10251032
string settlementFxFixingDate_;
10261033
};

QuantExt/qle/cashflows/cpicoupon.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -354,6 +354,11 @@ CPILeg& CPILeg::withSubtractInflationNominalAllCoupons(bool subtractInflationNom
354354
return *this;
355355
}
356356

357+
CPILeg& CPILeg::withPaymentDates(const std::vector<QuantLib::Date>& paymentDates){
358+
paymentDates_ = paymentDates;
359+
return *this;
360+
}
361+
357362
CPILeg::operator Leg() const {
358363

359364
QL_REQUIRE(!notionals_.empty(), "no notional given");

QuantExt/qle/cashflows/cpicoupon.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,6 +179,7 @@ class CPILeg {
179179
CPILeg& withObservationLag(const Period& observationLag);
180180
CPILeg& withSubtractInflationNominalAllCoupons(bool subtractInflationNominalAllCoupons);
181181
CPILeg& withBaseDate(const Date& baseDate);
182+
CPILeg& withPaymentDates(const std::vector<Date>& paymentDates);
182183
operator Leg() const;
183184

184185
private:
@@ -208,7 +209,7 @@ class CPILeg {
208209
Date startDate_;
209210
// Needed if baseCPI is not given
210211
Date baseDate_;
211-
212+
std::vector<Date> paymentDates_;
212213
};
213214

214215
} // namespace QuantExt

QuantExt/qle/cashflows/yoyinflationcoupon.cpp

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,11 @@ yoyInflationLeg& yoyInflationLeg::withInflationNotional(bool addInflationNotiona
205205
return *this;
206206
}
207207

208+
yoyInflationLeg& yoyInflationLeg::withPaymentDates(const std::vector<QuantLib::Date>& paymentDates) {
209+
paymentDates_ = paymentDates;
210+
return *this;
211+
}
212+
208213
yoyInflationLeg::operator Leg() const {
209214

210215
Size n = schedule_.size() - 1;

QuantExt/qle/cashflows/yoyinflationcoupon.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -129,6 +129,7 @@ class yoyInflationLeg {
129129
yoyInflationLeg& withFloors(const std::vector<Rate>& floors);
130130
yoyInflationLeg& withRateCurve(const Handle<YieldTermStructure>& rateCurve);
131131
yoyInflationLeg& withInflationNotional(bool addInflationNotional_);
132+
yoyInflationLeg& withPaymentDates(const std::vector<QuantLib::Date>& paymentDates);
132133
operator Leg() const;
133134

134135
private:
@@ -146,6 +147,7 @@ class yoyInflationLeg {
146147
std::vector<Rate> caps_, floors_;
147148
Handle<YieldTermStructure> rateCurve_;
148149
bool addInflationNotional_;
150+
std::vector<QuantLib::Date> paymentDates_;
149151
};
150152
} // namespace QuantExt
151153
#endif

0 commit comments

Comments
 (0)