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

Bond TRS class. More...

#include <qle/instruments/bondtotalreturnswap.hpp>

+ Inheritance diagram for BondTRS:
+ Collaboration diagram for BondTRS:

Classes

class  arguments
 

Public Types

using engine = GenericEngine< BondTRS::arguments, BondTRS::results >
 
using results = BondTRS::results
 

Public Member Functions

 BondTRS (const QuantLib::ext::shared_ptr< QuantExt::BondIndex > &bondIndex, const Real bondNotional, const Real initialPrice, const std::vector< Leg > &fundingLeg, const bool payTotalReturnLeg, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndex=nullptr, bool payBondCashFlowsImmediately=false, const Currency &fundingCurrency=Currency(), const Currency &bondCurrency=Currency())
 Constructor. More...
 
Instrument interface
bool isExpired () const override
 
void setupArguments (PricingEngine::arguments *) const override
 

Inspectors

QuantLib::ext::shared_ptr< QuantExt::BondIndexbondIndex_
 
Real bondNotional_
 
Real initialPrice_
 
std::vector< Leg > fundingLeg_
 
bool payTotalReturnLeg_
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndex_
 
bool payBondCashFlowsImmediately_
 
Currency fundingCurrency_
 
Currency bondCurrency_
 
std::vector< Date > valuationDates_
 
std::vector< Date > paymentDates_
 
Leg returnLeg_
 
const QuantLib::ext::shared_ptr< QuantExt::BondIndex > & bondIndex () const
 
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > & fxIndex () const
 
Real bondNotional () const
 
const std::vector< Leg > & fundingLeg () const
 
Real initialPrice () const
 
bool payTotalReturnLeg () const
 
const Leg & returnLeg () const
 
bool payBondCashFlowsImmediately () const
 
const std::vector< Date > & valuationDates () const
 
const std::vector< Date > & paymentDates () const
 

Detailed Description

Bond TRS class.

Definition at line 37 of file bondtotalreturnswap.hpp.

Member Typedef Documentation

◆ engine

using engine = GenericEngine<BondTRS::arguments, BondTRS::results>

Definition at line 40 of file bondtotalreturnswap.hpp.

◆ results

Definition at line 41 of file bondtotalreturnswap.hpp.

Constructor & Destructor Documentation

◆ BondTRS()

BondTRS ( const QuantLib::ext::shared_ptr< QuantExt::BondIndex > &  bondIndex,
const Real  bondNotional,
const Real  initialPrice,
const std::vector< Leg > &  fundingLeg,
const bool  payTotalReturnLeg,
const std::vector< Date > &  valuationDates,
const std::vector< Date > &  paymentDates,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndex = nullptr,
bool  payBondCashFlowsImmediately = false,
const Currency &  fundingCurrency = Currency(),
const Currency &  bondCurrency = Currency() 
)

Constructor.

Definition at line 27 of file bondtotalreturnswap.cpp.

36
37 QL_REQUIRE(bondIndex, "BondTRS: no bond index given");
38 registerWith(bondIndex);
39
40 if (fxIndex_ != nullptr)
41 registerWith(fxIndex_);
42
43 if (!fundingCurrency_.empty() && !bondCurrency_.empty()) {
44 // do we require an fx index for conversion ...
45 QL_REQUIRE(fundingCurrency_ == bondCurrency_ || fxIndex_ != nullptr,
46 "BondTRS: fx index required if funding ccy ("
47 << fundingCurrency_.code() << ") not equal to bond ccy (" << bondCurrency_.code() << ")");
48 // ... and if yes, has it the right currencies?
49 if (fxIndex_ != nullptr) {
50 QL_REQUIRE(fxIndex_->sourceCurrency() == bondCurrency_ && fxIndex_->targetCurrency() == fundingCurrency_,
51 "BondTRS: fx index '" << fxIndex_->name() << "' currencies must match bond ccy / funding ccy ("
52 << bondCurrency_.code() << " / " << fundingCurrency_.code() << ")");
53 }
54 }
55
56 for (auto const& l : fundingLeg) {
57 for (auto const& c : l)
58 registerWith(c);
59 }
60 QL_REQUIRE(valuationDates.size() > 1, "valuation dates size > 1 required");
61
64}
const QuantLib::ext::shared_ptr< QuantExt::BondIndex > & bondIndex() const
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex_
std::vector< Leg > fundingLeg_
bool payBondCashFlowsImmediately() const
const std::vector< Date > & valuationDates() const
const std::vector< Leg > & fundingLeg() const
std::vector< Date > valuationDates_
const std::vector< Date > & paymentDates() const
bool payTotalReturnLeg() const
std::vector< Date > paymentDates_
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > & fxIndex() const
QuantLib::ext::shared_ptr< QuantExt::BondIndex > bondIndex_
+ Here is the call graph for this function:

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 66 of file bondtotalreturnswap.cpp.

66{ return detail::simple_event(valuationDates_.back()).hasOccurred(); }

◆ setupArguments()

void setupArguments ( PricingEngine::arguments *  args) const
override

Definition at line 68 of file bondtotalreturnswap.cpp.

68 {
69 BondTRS::arguments* arguments = dynamic_cast<BondTRS::arguments*>(args);
70 QL_REQUIRE(arguments, "BondTRS instrument: wrong argument type in bond total return swap");
71 arguments->bondIndex = bondIndex_;
72 arguments->fxIndex = fxIndex_;
73 arguments->bondNotional = bondNotional_;
74 arguments->fundingLeg = fundingLeg_;
75 arguments->returnLeg = returnLeg_;
76 arguments->payTotalReturnLeg = payTotalReturnLeg_;
77 arguments->payBondCashFlowsImmediately = payBondCashFlowsImmediately_;
78 arguments->fundingCurrency = fundingCurrency_;
79 arguments->bondCurrency = bondCurrency_;
80 arguments->valuationDates = valuationDates_;
81 arguments->paymentDates = paymentDates_;
82}

◆ bondIndex()

const QuantLib::ext::shared_ptr< QuantExt::BondIndex > & bondIndex ( ) const

Definition at line 57 of file bondtotalreturnswap.hpp.

57{ return bondIndex_; }
+ Here is the caller graph for this function:

◆ fxIndex()

const QuantLib::ext::shared_ptr< QuantExt::FxIndex > & fxIndex ( ) const

Definition at line 58 of file bondtotalreturnswap.hpp.

58{ return fxIndex_; }

◆ bondNotional()

Real bondNotional ( ) const

Definition at line 59 of file bondtotalreturnswap.hpp.

59{ return bondNotional_; }

◆ fundingLeg()

const std::vector< Leg > & fundingLeg ( ) const

Definition at line 60 of file bondtotalreturnswap.hpp.

60{ return fundingLeg_; }
+ Here is the caller graph for this function:

◆ initialPrice()

Real initialPrice ( ) const

Definition at line 61 of file bondtotalreturnswap.hpp.

61{ return initialPrice_; }

◆ payTotalReturnLeg()

bool payTotalReturnLeg ( ) const

Definition at line 62 of file bondtotalreturnswap.hpp.

62{ return payTotalReturnLeg_; }

◆ returnLeg()

const Leg & returnLeg ( ) const

Definition at line 63 of file bondtotalreturnswap.hpp.

63{ return returnLeg_; }

◆ payBondCashFlowsImmediately()

bool payBondCashFlowsImmediately ( ) const

Definition at line 64 of file bondtotalreturnswap.hpp.

◆ valuationDates()

const std::vector< Date > & valuationDates ( ) const

Definition at line 65 of file bondtotalreturnswap.hpp.

65{ return valuationDates_; }
+ Here is the caller graph for this function:

◆ paymentDates()

const std::vector< Date > & paymentDates ( ) const

Definition at line 66 of file bondtotalreturnswap.hpp.

66{ return paymentDates_; }

Member Data Documentation

◆ bondIndex_

QuantLib::ext::shared_ptr<QuantExt::BondIndex> bondIndex_
private

Definition at line 70 of file bondtotalreturnswap.hpp.

◆ bondNotional_

Real bondNotional_
private

Definition at line 71 of file bondtotalreturnswap.hpp.

◆ initialPrice_

Real initialPrice_
private

Definition at line 72 of file bondtotalreturnswap.hpp.

◆ fundingLeg_

std::vector<Leg> fundingLeg_
private

Definition at line 73 of file bondtotalreturnswap.hpp.

◆ payTotalReturnLeg_

bool payTotalReturnLeg_
private

Definition at line 74 of file bondtotalreturnswap.hpp.

◆ fxIndex_

QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex_
private

Definition at line 75 of file bondtotalreturnswap.hpp.

◆ payBondCashFlowsImmediately_

bool payBondCashFlowsImmediately_
private

Definition at line 76 of file bondtotalreturnswap.hpp.

◆ fundingCurrency_

Currency fundingCurrency_
private

Definition at line 77 of file bondtotalreturnswap.hpp.

◆ bondCurrency_

Currency bondCurrency_
private

Definition at line 77 of file bondtotalreturnswap.hpp.

◆ valuationDates_

std::vector<Date> valuationDates_
private

Definition at line 78 of file bondtotalreturnswap.hpp.

◆ paymentDates_

std::vector<Date> paymentDates_
private

Definition at line 79 of file bondtotalreturnswap.hpp.

◆ returnLeg_

Leg returnLeg_
private

Definition at line 81 of file bondtotalreturnswap.hpp.