Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | List of all members
DiscountRatioModifiedCurve Class Reference

#include <qle/termstructures/discountratiomodifiedcurve.hpp>

+ Inheritance diagram for DiscountRatioModifiedCurve:
+ Collaboration diagram for DiscountRatioModifiedCurve:

Public Member Functions

 DiscountRatioModifiedCurve (const QuantLib::Handle< QuantLib::YieldTermStructure > &baseCurve, const QuantLib::Handle< QuantLib::YieldTermStructure > &numCurve, const QuantLib::Handle< QuantLib::YieldTermStructure > &denCurve)
 Constructor providing the three underlying yield curves. More...
 
Inspectors
const QuantLib::Handle< QuantLib::YieldTermStructure > & baseCurve () const
 Return the base curve. More...
 
const QuantLib::Handle< QuantLib::YieldTermStructure > & numeratorCurve () const
 Return the numerator curve. More...
 
const QuantLib::Handle< QuantLib::YieldTermStructure > & denominatorCurve () const
 Return the denominator curve. More...
 
Observer interface
void update () override
 

YieldTermStructure interface

QuantLib::Handle< YieldTermStructure > baseCurve_
 
QuantLib::Handle< YieldTermStructure > numCurve_
 
QuantLib::Handle< YieldTermStructure > denCurve_
 
QuantLib::DayCounter dayCounter () const override
 Returns the day counter from the base curve. More...
 
QuantLib::Calendar calendar () const override
 Returns the calendar from the base curve. More...
 
QuantLib::Natural settlementDays () const override
 Returns the settlement days from the base curve. More...
 
const QuantLib::Date & referenceDate () const override
 Returns the reference date from the base curve. More...
 
QuantLib::Date maxDate () const override
 All range checks happen in the underlying curves. More...
 
QuantLib::DiscountFactor discountImpl (QuantLib::Time t) const override
 Perform the discount factor calculation using the three yield curves. More...
 
void check () const
 Check that none of the underlying term structures are empty. More...
 

Detailed Description

The DiscountRatioModifiedCurve depends on three other yield curves. The dependency is via the discount factor. In particular, the discount factor \(P(0, t)\) at time \(t\) is given by:

\[ P(0, t) = P_b(0, t) \frac{P_n(0, t)}{P_d(0, t)} \]

where \(P_b(0, t)\) is the base curve discount factor, \(P_n(0, t)\) is the numerator curve discount factor and \(P_d(0, t)\) is the denominator curve discount factor.

A use case for this type of discount curve is where we need to discount cashflows denominated in a currency, call it currency 1, and collateralised in a different currency, call it currency 2. Let \(P_{1, 2}(0, t)\) denote the discount factor on this curve at time \(t\). Assume that we have curves for discounting cashflows denominated in currency 1 and currency 2 and collaterised in a common reference currency. Let \(P_{1, ref}(0, t)\) and \(P_{2, ref}(0, t)\) denote the discount factors on these two curves respectively. Assume also that we have a curve for discounting cashflows denominated and collateralised in currency 2. Let \(P_{2, 2}(0, t)\) denote the discount factor on this curve at time \(t\). Then, by using DiscountRatioModifiedCurve we can set up the following relation:

\[ P_{1, 2}(0, t) = P_{2, 2}(0, t) \frac{P_{1, ref}(0, t)}{P_{2, ref}(0, t)} \]

The assumption here is that forward FX rates remain the same if the FX forward's collateral currency is switched from the reference currency to currency 2.

Warning:
One must be careful about mixing floating reference date and fixed reference date curves together as the underlying curves in this yield curve and then moving Settings::instance().evaluationDate(). This is alluded to in the corresponding unit tests. If the moving_ member variable of TermStructure had an inspector method, then we could enforce that all underlying curves here are either floating or fixed reference date curves.

Definition at line 58 of file discountratiomodifiedcurve.hpp.

Constructor & Destructor Documentation

◆ DiscountRatioModifiedCurve()

DiscountRatioModifiedCurve ( const QuantLib::Handle< QuantLib::YieldTermStructure > &  baseCurve,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  numCurve,
const QuantLib::Handle< QuantLib::YieldTermStructure > &  denCurve 
)

Constructor providing the three underlying yield curves.

Definition at line 32 of file discountratiomodifiedcurve.cpp.

35 : baseCurve_(baseCurve), numCurve_(numCurve), denCurve_(denCurve) {
36
37 // Cannot construct with empty curves
38 check();
39
40 // All range checks will happen in underlying curves
41 enableExtrapolation(true);
42
43 // Observe the underlying curves
44 registerWith(baseCurve_);
45 registerWith(numCurve_);
46 registerWith(denCurve_);
47}
const QuantLib::Handle< QuantLib::YieldTermStructure > & baseCurve() const
Return the base curve.
void check() const
Check that none of the underlying term structures are empty.
QuantLib::Handle< YieldTermStructure > numCurve_
QuantLib::Handle< YieldTermStructure > baseCurve_
QuantLib::Handle< YieldTermStructure > denCurve_
+ Here is the call graph for this function:

Member Function Documentation

◆ baseCurve()

const QuantLib::Handle< QuantLib::YieldTermStructure > & baseCurve ( ) const

Return the base curve.

Definition at line 68 of file discountratiomodifiedcurve.hpp.

68{ return baseCurve_; }

◆ numeratorCurve()

const QuantLib::Handle< QuantLib::YieldTermStructure > & numeratorCurve ( ) const

Return the numerator curve.

Definition at line 70 of file discountratiomodifiedcurve.hpp.

70{ return numCurve_; }

◆ denominatorCurve()

const QuantLib::Handle< QuantLib::YieldTermStructure > & denominatorCurve ( ) const

Return the denominator curve.

Definition at line 72 of file discountratiomodifiedcurve.hpp.

72{ return denCurve_; }

◆ dayCounter()

DayCounter dayCounter ( ) const
override

Returns the day counter from the base curve.

Definition at line 49 of file discountratiomodifiedcurve.cpp.

49{ return baseCurve_->dayCounter(); }

◆ calendar()

Calendar calendar ( ) const
override

Returns the calendar from the base curve.

Definition at line 51 of file discountratiomodifiedcurve.cpp.

51{ return baseCurve_->calendar(); }

◆ settlementDays()

Natural settlementDays ( ) const
override

Returns the settlement days from the base curve.

Definition at line 53 of file discountratiomodifiedcurve.cpp.

53{ return baseCurve_->settlementDays(); }

◆ referenceDate()

const Date & referenceDate ( ) const
override

Returns the reference date from the base curve.

Definition at line 55 of file discountratiomodifiedcurve.cpp.

55{ return baseCurve_->referenceDate(); }
+ Here is the caller graph for this function:

◆ maxDate()

QuantLib::Date maxDate ( ) const
override

All range checks happen in the underlying curves.

Definition at line 86 of file discountratiomodifiedcurve.hpp.

86{ return QuantLib::Date::maxDate(); }
+ Here is the caller graph for this function:

◆ update()

void update ( )
override

Definition at line 57 of file discountratiomodifiedcurve.cpp.

57 {
58 // Make sure that any change to underlying curves leaves them valid
59 check();
60
61 YieldTermStructure::update();
62}
+ Here is the call graph for this function:

◆ discountImpl()

DiscountFactor discountImpl ( QuantLib::Time  t) const
overrideprotected

Perform the discount factor calculation using the three yield curves.

Definition at line 64 of file discountratiomodifiedcurve.cpp.

64 {
65 return baseCurve_->discount(t) * numCurve_->discount(t) / denCurve_->discount(t);
66}

◆ check()

void check ( ) const
private

Check that none of the underlying term structures are empty.

Definition at line 68 of file discountratiomodifiedcurve.cpp.

68 {
69 QL_REQUIRE(!baseCurve_.empty(), "DiscountRatioModifiedCurve: base curve should not be empty");
70 QL_REQUIRE(!numCurve_.empty(), "DiscountRatioModifiedCurve: numerator curve should not be empty");
71 QL_REQUIRE(!denCurve_.empty(), "DiscountRatioModifiedCurve: denominator curve should not be empty");
72}
+ Here is the caller graph for this function:

Member Data Documentation

◆ baseCurve_

QuantLib::Handle<YieldTermStructure> baseCurve_
private

Definition at line 102 of file discountratiomodifiedcurve.hpp.

◆ numCurve_

QuantLib::Handle<YieldTermStructure> numCurve_
private

Definition at line 103 of file discountratiomodifiedcurve.hpp.

◆ denCurve_

QuantLib::Handle<YieldTermStructure> denCurve_
private

Definition at line 104 of file discountratiomodifiedcurve.hpp.