Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Classes | Public Member Functions | Private Attributes | Friends | List of all members
RequiredFixings Class Reference

#include <ored/portfolio/fixingdates.hpp>

+ Collaboration diagram for RequiredFixings:

Classes

class  FixingDates
 
struct  FixingEntry
 
struct  InflationFixingEntry
 
struct  ZeroInflationFixingEntry
 

Public Member Functions

std::map< std::string, FixingDatesfixingDatesIndices (const QuantLib::Date &settlementDate=QuantLib::Date()) const
 
void addFixingDate (const QuantLib::Date &fixingDate, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
 
void addFixingDate (const FixingEntry &fixingEntry)
 
void addFixingDates (const std::vector< std::pair< QuantLib::Date, bool > > &fixingDates, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false)
 
void addFixingDates (const std::vector< QuantLib::Date > &fixingDates, const std::string &indexName, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatory=true)
 
void addZeroInflationFixingDate (const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const CPI::InterpolationType coupopnInterpolation, const Frequency couponFrequency, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
 
void addZeroInflationFixingDate (const ZeroInflationFixingEntry &fixingEntry)
 
void addYoYInflationFixingDate (const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
 
void addYoYInflationFixingDate (const InflationFixingEntry &fixingEntry)
 
void clear ()
 
void addData (const RequiredFixings &requiredFixings)
 
void unsetPayDates ()
 
RequiredFixings makeCopyWithMandatoryOverride (bool mandatory)
 
RequiredFixings filteredFixingDates (const QuantLib::Date &settlementDate=QuantLib::Date())
 

Private Attributes

std::set< FixingEntryfixingDates_
 
std::set< ZeroInflationFixingEntryzeroInflationFixingDates_
 
std::set< InflationFixingEntryyoyInflationFixingDates_
 

Friends

std::ostream & operator<< (std::ostream &, const RequiredFixings &)
 

Detailed Description

Class holding the information on the fixings required to price a trade (or a portfolio of trades).

Definition at line 81 of file fixingdates.hpp.

Member Function Documentation

◆ fixingDatesIndices()

std::map< std::string, RequiredFixings::FixingDates > fixingDatesIndices ( const QuantLib::Date &  settlementDate = QuantLib::Date()) const

Gives back the dates for which fixings will be required to price the trade assuming a given settlementDate. If the settlementDate is not provided or is set equal to QuantLib::Date(), the settlement date in the implementation is assumed to be the Settings::instance().evaluationDate().

If a cashflow payment is deemed to have already occurred relative to the settlement date, then no fixing is needed. The determination of whether a cashflow has or has not occurred will in general rely on a call to CashFlow::hasOccurred which is important in cases where the cash flow payment date falls on the settlement date.

Another important case is where a cash flow fixing date occurs on the settlement date. In this case, we should always add the fixing date to the set of fixing dates regardless of Settings::instance().enforcesTodaysHistoricFixings().

Definition at line 290 of file fixingdates.cpp.

290 {
291
292 // If settlement date is an empty date, update to evaluation date.
293 Date d = settlementDate == Date() ? Settings::instance().evaluationDate() : settlementDate;
294
295 std::map<std::string, FixingDates> result;
296
297 // handle the general case
298 for (auto const& f : fixingDates_) {
299 // get the data
300 std::string indexName = f.indexName;
301 Date fixingDate = f.fixingDate;
302 Date payDate = f.payDate;
303 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
304 // add to result
305 if (fixingDate > d)
306 continue;
307 SimpleCashFlow dummyCf(0.0, payDate);
308 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
309 result[indexName].addDate(fixingDate, f.mandatory);
310 }
311 }
312
313 // handle zero inflation index based coupons
314 for (auto const& f : zeroInflationFixingDates_) {
315 // get the data
316 std::string indexName = f.indexName;
317 Date fixingDate = f.fixingDate;
318 Date payDate = f.payDate;
319 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
320 bool indexInterpolated = f.indexInterpolated;
321 Frequency indexFrequency = f.indexFreq;
322 Period indexAvailabilityLag = f.availabilityLeg;
323 CPI::InterpolationType couponInterpolation = f.couponInterpolation;
324 Frequency couponFrequency = f.couponFrequency;
325 // add to result
326 SimpleCashFlow dummyCf(0.0, payDate);
327 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
328 RequiredFixings::FixingDates tmp;
329 addZeroInflationDates(tmp, fixingDate, d, indexInterpolated, indexFrequency, indexAvailabilityLag,
330 couponInterpolation, couponFrequency, f.mandatory);
331 if (!tmp.empty())
332 result[indexName].addDates(tmp);
333 }
334 }
335
336 // handle yoy inflation index based coupons
337 for (auto const& f : yoyInflationFixingDates_) {
338 // get the data
339 std::string indexName = f.indexName;
340 Date fixingDate = f.fixingDate;
341 Date payDate = f.payDate;
342 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
343 bool indexInterpolated = f.indexInterpolated;
344 Frequency indexFrequency = f.indexFreq;
345 Period indexAvailabilityLag = f.availabilityLeg;
346 // add to result
347 SimpleCashFlow dummyCf(0.0, payDate);
348 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
349 auto fixingDates =
350 needsForecast(fixingDate, d, indexInterpolated, indexFrequency, indexAvailabilityLag, f.mandatory);
351 if (!fixingDates.empty())
352 result[indexName].addDates(fixingDates);
353 // Add the previous year's date(s) also if any.
354 for (const auto& [d, mandatory] : fixingDates) {
355 Date previousYear = d - 1 * Years;
356 result[indexName].addDate(previousYear, mandatory);
357 }
358 }
359 }
360
361 return result;
362}
std::set< ZeroInflationFixingEntry > zeroInflationFixingDates_
std::set< InflationFixingEntry > yoyInflationFixingDates_
std::set< FixingEntry > fixingDates_
QuantLib::Date fixingDate(const QuantLib::Date &d, const QuantLib::Period obsLag, const QuantLib::Frequency freq, bool interpolated)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addFixingDate() [1/2]

void addFixingDate ( const QuantLib::Date &  fixingDate,
const std::string &  indexName,
const QuantLib::Date &  payDate = Date::maxDate(),
const bool  alwaysAddIfPaysOnSettlement = false,
const bool  mandatoryFixing = true 
)

Adds a single fixing date fixingDate for an index given by its ORE index name indexName arising from a coupon with payment date payDate. If alwaysAddIfPaysOnSettlement is true the fixing date will be added if the coupon pays on the settlement date even if the cashflow returns hasOccured(settlementDate) as true. This is conservative and necessary in some cases since some pricing engines in QL (e.g. CapFloor) do not respect hasOccured() and ask for the fixing regardless. If the payDate is not given, it defaults to Date::maxDate() meaning that the added fixing is relevant unconditional on a pay date

Definition at line 364 of file fixingdates.cpp.

366 {
367 fixingDates_.insert(
368 {indexName, fixingDate, payDate, payDate == Date::maxDate() || alwaysAddIfPaysOnSettlement, mandatory});
369}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addFixingDate() [2/2]

void addFixingDate ( const FixingEntry fixingEntry)

Definition at line 371 of file fixingdates.cpp.

371{ fixingDates_.insert(fixingEntry); }

◆ addFixingDates() [1/2]

void addFixingDates ( const std::vector< std::pair< QuantLib::Date, bool > > &  fixingDates,
const std::string &  indexName,
const QuantLib::Date &  payDate = Date::maxDate(),
const bool  alwaysAddIfPaysOnSettlement = false 
)

adds a vector of fixings dates fixingDates and mandatory flags for an index given by is ORE index name indexName arising from a coupon with payment date payDate

Definition at line 373 of file fixingdates.cpp.

375 {
376 for (auto const& [date, mandatory] : fixingDates) {
377 fixingDates_.insert({indexName, date, payDate, alwaysAddIfPaysOnSettlement, mandatory});
378 }
379}
+ Here is the caller graph for this function:

◆ addFixingDates() [2/2]

void addFixingDates ( const std::vector< QuantLib::Date > &  fixingDates,
const std::string &  indexName,
const QuantLib::Date &  payDate = Date::maxDate(),
const bool  alwaysAddIfPaysOnSettlement = false,
const bool  mandatory = true 
)

adds a vector of fixings dates fixingDates for an index given by is ORE index name indexName arising from a coupon with payment date payDate

Definition at line 381 of file fixingdates.cpp.

383 {
384 for (auto const& date : fixingDates) {
385 fixingDates_.insert({indexName, date, payDate, alwaysAddIfPaysOnSettlement, mandatory});
386 }
387}

◆ addZeroInflationFixingDate() [1/2]

void addZeroInflationFixingDate ( const QuantLib::Date &  fixingDate,
const std::string &  indexName,
const bool  indexInterpolated,
const Frequency  indexFrequency,
const Period &  indexAvailabilityLag,
const CPI::InterpolationType  coupopnInterpolation,
const Frequency  couponFrequency,
const QuantLib::Date &  payDate = Date::maxDate(),
const bool  alwaysAddIfPaysOnSettlement = false,
const bool  mandatoryFixing = true 
)

add a single fixing date fixingDate for a coupon based on a zero inflation index given by its ORE index name indexName with payment date payDate

Definition at line 389 of file fixingdates.cpp.

394 {
395 ZeroInflationFixingEntry entry;
396 entry.indexName = indexName;
397 entry.fixingDate = fixingDate;
398 entry.payDate = payDate;
399 entry.alwaysAddIfPaysOnSettlement = alwaysAddIfPaysOnSettlement;
400 entry.mandatory = mandatory;
401 entry.indexInterpolated = indexInterpolated;
402 entry.indexFreq = indexFrequency;
403 entry.availabilityLeg = indexAvailabilityLag;
404 entry.couponFrequency = couponFrequency;
405 entry.couponInterpolation = couponInterpolation;
407}
void addZeroInflationFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const CPI::InterpolationType coupopnInterpolation, const Frequency couponFrequency, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addZeroInflationFixingDate() [2/2]

void addZeroInflationFixingDate ( const ZeroInflationFixingEntry fixingEntry)

Definition at line 409 of file fixingdates.cpp.

409 {
410 zeroInflationFixingDates_.insert(fixingEntry);
411}

◆ addYoYInflationFixingDate() [1/2]

void addYoYInflationFixingDate ( const QuantLib::Date &  fixingDate,
const std::string &  indexName,
const bool  indexInterpolated,
const Frequency  indexFrequency,
const Period &  indexAvailabilityLag,
const QuantLib::Date &  payDate = Date::maxDate(),
const bool  alwaysAddIfPaysOnSettlement = false,
const bool  mandatoryFixing = true 
)

add a single fixing date fixingDate for a coupon based on a yoy inflation index given by its ORE index name indexName with payment date payDate

Definition at line 413 of file fixingdates.cpp.

416 {
417 InflationFixingEntry entry;
418 entry.indexName = indexName;
419 entry.fixingDate = fixingDate;
420 entry.payDate = payDate;
421 entry.alwaysAddIfPaysOnSettlement = alwaysAddIfPaysOnSettlement;
422 entry.mandatory = mandatory;
423 entry.indexInterpolated = indexInterpolated;
424 entry.indexFreq = indexFrequency;
425 entry.availabilityLeg = indexAvailabilityLag;
427}
void addYoYInflationFixingDate(const QuantLib::Date &fixingDate, const std::string &indexName, const bool indexInterpolated, const Frequency indexFrequency, const Period &indexAvailabilityLag, const QuantLib::Date &payDate=Date::maxDate(), const bool alwaysAddIfPaysOnSettlement=false, const bool mandatoryFixing=true)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ addYoYInflationFixingDate() [2/2]

void addYoYInflationFixingDate ( const InflationFixingEntry fixingEntry)

Definition at line 429 of file fixingdates.cpp.

429 {
430 yoyInflationFixingDates_.insert(fixingEntry);
431}

◆ clear()

void clear ( )

clear all data

Definition at line 172 of file fixingdates.cpp.

172 {
173 fixingDates_.clear();
176}
+ Here is the caller graph for this function:

◆ addData()

void addData ( const RequiredFixings requiredFixings)

add data from another RequiredFixings instance

Definition at line 178 of file fixingdates.cpp.

178 {
179 fixingDates_.insert(requiredFixings.fixingDates_.begin(), requiredFixings.fixingDates_.end());
180 zeroInflationFixingDates_.insert(requiredFixings.zeroInflationFixingDates_.begin(),
181 requiredFixings.zeroInflationFixingDates_.end());
182 yoyInflationFixingDates_.insert(requiredFixings.yoyInflationFixingDates_.begin(),
183 requiredFixings.yoyInflationFixingDates_.end());
184}
+ Here is the caller graph for this function:

◆ unsetPayDates()

void unsetPayDates ( )

Set all pay dates to Date::maxDate(), fixingDatesIndices() will then not filter the required fixings by the given settlement date any more. Needed by total return swaps on bonds for example, where a cashflow in a bond with past payment date can still be relevant for the payment of the current return period.

Definition at line 186 of file fixingdates.cpp.

186 {
187 // we can't modify the elements of a set directly, need to make a copy and reassign
188 std::set<FixingEntry> newFixingDates;
189 std::set<ZeroInflationFixingEntry> newZeroInflationFixingDates;
190 std::set<InflationFixingEntry> newYoYInflationFixingDates;
191 for (auto f : fixingDates_) {
192 f.payDate = Date::maxDate();
193 f.alwaysAddIfPaysOnSettlement = true;
194 newFixingDates.insert(f);
195 }
196 for (auto f : zeroInflationFixingDates_) {
197 f.payDate = Date::maxDate();
198 f.alwaysAddIfPaysOnSettlement = true;
199 newZeroInflationFixingDates.insert(f);
200 }
201 for (auto f : yoyInflationFixingDates_) {
202 f.payDate = Date::maxDate();
203 f.alwaysAddIfPaysOnSettlement = true;
204 newYoYInflationFixingDates.insert(f);
205 }
206 fixingDates_ = newFixingDates;
207 zeroInflationFixingDates_ = newZeroInflationFixingDates;
208 yoyInflationFixingDates_ = newYoYInflationFixingDates;
209}
+ Here is the caller graph for this function:

◆ makeCopyWithMandatoryOverride()

RequiredFixings makeCopyWithMandatoryOverride ( bool  mandatory)

Create a copy and set mandatory flag to mandatory for all fixing entries

Definition at line 211 of file fixingdates.cpp.

211 {
212 RequiredFixings result(*this);
213 // we can't modify the elements of a set directly, need to make a copy and reassign
214 std::set<FixingEntry> newFixingDates;
215 std::set<ZeroInflationFixingEntry> newZeroInflationFixingDates;
216 std::set<InflationFixingEntry> newYoYInflationFixingDates;
217 for (auto f : result.fixingDates_) {
218 f.mandatory = mandatory;
219 newFixingDates.insert(f);
220 }
221 for (auto f : result.zeroInflationFixingDates_) {
222 f.mandatory = mandatory;
223 newZeroInflationFixingDates.insert(f);
224 }
225 for (auto f : yoyInflationFixingDates_) {
226 f.mandatory = mandatory;
227 newYoYInflationFixingDates.insert(f);
228 }
229 result.fixingDates_ = newFixingDates;
230 result.zeroInflationFixingDates_ = newZeroInflationFixingDates;
231 result.yoyInflationFixingDates_ = newYoYInflationFixingDates;
232 return result;
233}
+ Here is the caller graph for this function:

◆ filteredFixingDates()

RequiredFixings filteredFixingDates ( const QuantLib::Date &  settlementDate = QuantLib::Date())

Definition at line 235 of file fixingdates.cpp.

235 {
236 RequiredFixings rf;
237 // If settlement date is an empty date, update to evaluation date.
238 Date d = settlementDate == Date() ? Settings::instance().evaluationDate() : settlementDate;
239 // handle the general case
240 for (auto f : fixingDates_) {
241 // get the data
242 std::string indexName = f.indexName;
243 Date fixingDate = f.fixingDate;
244 Date payDate = f.payDate;
245 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
246 // add to result
247 if (fixingDate > d)
248 continue;
249 SimpleCashFlow dummyCf(0.0, payDate);
250 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
251 f.payDate = Date::maxDate();
252 f.alwaysAddIfPaysOnSettlement = true;
253 rf.addFixingDate(f);
254 }
255 }
256
257 // handle zero inflation index based coupons
258 for (auto f : zeroInflationFixingDates_) {
259 // get the data
260 std::string indexName = f.indexName;
261 Date payDate = f.payDate;
262 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
263 // add to result
264 SimpleCashFlow dummyCf(0.0, payDate);
265 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
266 f.payDate = Date::maxDate();
267 f.alwaysAddIfPaysOnSettlement = true;
268 rf.addZeroInflationFixingDate(f);
269 }
270 }
271
272 // handle yoy inflation index based coupons
273 for (auto f : yoyInflationFixingDates_) {
274 // get the data
275 std::string indexName = f.indexName;
276 Date payDate = f.payDate;
277 bool alwaysAddIfPaysOnSettlement = f.alwaysAddIfPaysOnSettlement;
278 // add to result
279 SimpleCashFlow dummyCf(0.0, payDate);
280 if (!dummyCf.hasOccurred(d) || (alwaysAddIfPaysOnSettlement && dummyCf.date() == d)) {
281 f.payDate = Date::maxDate();
282 f.alwaysAddIfPaysOnSettlement = true;
283 rf.addYoYInflationFixingDate(f);
284 }
285 }
286 return rf;
287}
+ Here is the call graph for this function:

Friends And Related Function Documentation

◆ operator<<

std::ostream & operator<< ( std::ostream &  ,
const RequiredFixings  
)
friend

allow output of required fixings data via streams

Definition at line 467 of file fixingdates.cpp.

467 {
468 out << "IndexName FixingDate PayDate AlwaysAddIfPaysOnSettlement\n";
469 out << requiredFixings.fixingDates_;
470 out << requiredFixings.zeroInflationFixingDates_;
471 out << requiredFixings.yoyInflationFixingDates_;
472 return out;
473}

Member Data Documentation

◆ fixingDates_

std::set<FixingEntry> fixingDates_
private

Definition at line 241 of file fixingdates.hpp.

◆ zeroInflationFixingDates_

std::set<ZeroInflationFixingEntry> zeroInflationFixingDates_
private

Definition at line 243 of file fixingdates.hpp.

◆ yoyInflationFixingDates_

std::set<InflationFixingEntry> yoyInflationFixingDates_
private

Definition at line 245 of file fixingdates.hpp.