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

TRS Instrument Wrapper. More...

#include <ored/portfolio/trswrapper.hpp>

+ Inheritance diagram for TRSWrapper:
+ Collaboration diagram for TRSWrapper:

Classes

class  arguments
 
class  engine
 
class  results
 

Public Member Functions

 TRSWrapper (const std::vector< QuantLib::ext::shared_ptr< ore::data::Trade > > &underlying, const std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > &underlyingIndex, const std::vector< QuantLib::Real > underlyingMultiplier, const bool includeUnderlyingCashflowsInReturn, const QuantLib::Real initialPrice, const QuantLib::Currency &initialPriceCurrency, const std::vector< QuantLib::Currency > &assetCurrency, const QuantLib::Currency &returnCurrency, const std::vector< QuantLib::Date > &valuationSchedule, const std::vector< QuantLib::Date > &paymentSchedule, const std::vector< QuantLib::Leg > &fundingLegs, const std::vector< TRS::FundingData::NotionalType > &fundingNotionalTypes, const QuantLib::Currency &fundingCurrency, const QuantLib::Size fundingResetGracePeriod, const bool paysAsset, const bool paysFunding, const QuantLib::Leg &additionalCashflowLeg, const bool additionalCashflowLegPayer, const QuantLib::Currency &additionalCashflowCurrency, const std::vector< QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndexAsset, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndexReturn, const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &fxIndexAdditionalCashflows, const std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &addFxindices)
 

Instrument interface

std::vector< QuantLib::ext::shared_ptr< ore::data::Trade > > underlying_
 
std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > underlyingIndex_
 
std::vector< QuantLib::Real > underlyingMultiplier_
 
bool includeUnderlyingCashflowsInReturn_
 
QuantLib::Real initialPrice_
 
const QuantLib::Currency initialPriceCurrency_
 
const std::vector< QuantLib::Currency > assetCurrency_
 
const QuantLib::Currency returnCurrency_
 
std::vector< QuantLib::Date > valuationSchedule_
 
std::vector< QuantLib::Date > paymentSchedule_
 
std::vector< QuantLib::Leg > fundingLegs_
 
std::vector< TRS::FundingData::NotionalTypefundingNotionalTypes_
 
const QuantLib::Currency fundingCurrency_
 
const QuantLib::Size fundingResetGracePeriod_
 
bool paysAsset_
 
bool paysFunding_
 
QuantLib::Leg additionalCashflowLeg_
 
bool additionalCashflowLegPayer_
 
const QuantLib::Currency additionalCashflowCurrency_
 
std::vector< QuantLib::ext::shared_ptr< QuantExt::FxIndex > > fxIndexAsset_
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndexReturn_
 
QuantLib::ext::shared_ptr< QuantExt::FxIndexfxIndexAdditionalCashflows_
 
std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > addFxIndices_
 
Date lastDate_
 
bool isExpired () const override
 
void setupArguments (QuantLib::PricingEngine::arguments *) const override
 
void fetchResults (const QuantLib::PricingEngine::results *) const override
 

Detailed Description

TRS Instrument Wrapper.

Definition at line 35 of file trswrapper.hpp.

Constructor & Destructor Documentation

◆ TRSWrapper()

TRSWrapper ( const std::vector< QuantLib::ext::shared_ptr< ore::data::Trade > > &  underlying,
const std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > &  underlyingIndex,
const std::vector< QuantLib::Real >  underlyingMultiplier,
const bool  includeUnderlyingCashflowsInReturn,
const QuantLib::Real  initialPrice,
const QuantLib::Currency &  initialPriceCurrency,
const std::vector< QuantLib::Currency > &  assetCurrency,
const QuantLib::Currency &  returnCurrency,
const std::vector< QuantLib::Date > &  valuationSchedule,
const std::vector< QuantLib::Date > &  paymentSchedule,
const std::vector< QuantLib::Leg > &  fundingLegs,
const std::vector< TRS::FundingData::NotionalType > &  fundingNotionalTypes,
const QuantLib::Currency &  fundingCurrency,
const QuantLib::Size  fundingResetGracePeriod,
const bool  paysAsset,
const bool  paysFunding,
const QuantLib::Leg &  additionalCashflowLeg,
const bool  additionalCashflowLegPayer,
const QuantLib::Currency &  additionalCashflowCurrency,
const std::vector< QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &  fxIndexAsset,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndexReturn,
const QuantLib::ext::shared_ptr< QuantExt::FxIndex > &  fxIndexAdditionalCashflows,
const std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &  addFxindices 
)

Definition at line 37 of file trswrapper.cpp.

49 : underlying_(underlying), underlyingIndex_(underlyingIndex), underlyingMultiplier_(underlyingMultiplier),
50 includeUnderlyingCashflowsInReturn_(includeUnderlyingCashflowsInReturn), initialPrice_(initialPrice),
51 initialPriceCurrency_(initialPriceCurrency), assetCurrency_(assetCurrency), returnCurrency_(returnCurrency),
52 valuationSchedule_(valuationSchedule), paymentSchedule_(paymentSchedule), fundingLegs_(fundingLegs),
53 fundingNotionalTypes_(fundingNotionalTypes), fundingCurrency_(fundingCurrency),
54 fundingResetGracePeriod_(fundingResetGracePeriod), paysAsset_(paysAsset), paysFunding_(paysFunding),
55 additionalCashflowLeg_(additionalCashflowLeg), additionalCashflowLegPayer_(additionalCashflowLegPayer),
56 additionalCashflowCurrency_(additionalCashflowCurrency), fxIndexAsset_(fxIndexAsset),
57 fxIndexReturn_(fxIndexReturn), fxIndexAdditionalCashflows_(fxIndexAdditionalCashflows),
58 addFxIndices_(addFxIndices) {
59
60 QL_REQUIRE(!paymentSchedule_.empty(), "TRSWrapper::TRSWrapper(): payment schedule must not be empty()");
61
62 QL_REQUIRE(valuationSchedule_.size() == paymentSchedule_.size() + 1,
63 "TRSWrapper::TRSWrapper(): valuation schedule size ("
64 << valuationSchedule_.size() << ") must be payment schedule size (" << paymentSchedule_.size()
65 << ") plus one");
66
67 for (Size i = 0; i < valuationSchedule_.size() - 1; ++i) {
68 QL_REQUIRE(valuationSchedule_[i] < valuationSchedule_[i + 1],
69 "TRSWrapper::TRSWrapper(): valuation schedule dates must be monotonic, at "
70 << i << ": " << valuationSchedule_[i] << ", " << valuationSchedule_[i + 1]);
71 }
72
73 for (Size i = 0; i < paymentSchedule_.size() - 1; ++i) {
74 QL_REQUIRE(paymentSchedule_[i] < paymentSchedule_[i + 1],
75 "TRSWrapper::TRSWrapper(): payment schedule dates must be monotonic, at "
76 << i << ": " << paymentSchedule_[i] << ", " << paymentSchedule_[i + 1]);
77 }
78
79 for (Size i = 0; i < paymentSchedule_.size(); ++i) {
80 QL_REQUIRE(paymentSchedule_[i] >= valuationSchedule_[i + 1], "TRSWrapper::TRSWrapper(): payment date at "
81 << i << " (" << paymentSchedule_[i]
82 << ") must be >= valuation date ("
83 << valuationSchedule_[i + 1]);
84 }
85
86 QL_REQUIRE(fundingLegs_.size() == fundingNotionalTypes_.size(), "TRSWrapper::TRSWrapper(): number of funding legs ("
87 << fundingLegs_.size()
88 << ") must match funding notitional types ("
89 << fundingNotionalTypes_.size() << ")");
90
91 QL_REQUIRE(!underlying_.empty(), "TRSWrapper::TRSWrapper(): no underlying given, at least one is required");
92 QL_REQUIRE(underlying.size() == underlyingIndex.size(),
93 "TRSWrapper::TRSWrapper(): number of underlyings ("
94 << underlying.size() << ") does not match underlying index size (" << underlyingIndex.size() << ")");
95 QL_REQUIRE(underlying.size() == underlyingMultiplier.size(), "TRSWrapper::TRSWrapper(): number of underlyings ("
96 << underlying.size()
97 << ") does not match underlying index size ("
98 << underlyingMultiplier.size() << ")");
99 QL_REQUIRE(underlying.size() == assetCurrency.size(),
100 "TRSWrapper::TRSWrapper(): number of underlyings ("
101 << underlying.size() << ") does not match asset currency size (" << assetCurrency.size() << ")");
102 QL_REQUIRE(underlying.size() == fxIndexAsset.size(),
103 "TRSWrapper::TRSWrapper(): number of underlyings ("
104 << underlying.size() << ") does not match fx index asset size (" << fxIndexAsset.size() << ")");
105
106 for (Size i = 0; i < underlying_.size(); ++i) {
107 registerWith(underlying_[i]->instrument()->qlInstrument());
108 registerWith(underlyingIndex_[i]);
109 }
110
111 for (Size i = 0; i < fundingLegs_.size(); ++i) {
112 for (Size j = 0; j < fundingLegs_[i].size(); ++j) {
113 registerWith(fundingLegs_[i][j]);
114 }
115 }
116
117 for (auto const& f : fxIndexAsset)
118 registerWith(f);
119 registerWith(fxIndexReturn);
120 registerWith(fxIndexAdditionalCashflows);
121
122 // compute last payment date, after this date the TRS is considered expired
123
124 lastDate_ = Date::minDate();
125 for (auto const& d : paymentSchedule_)
126 lastDate_ = std::max(lastDate_, d);
127 for (auto const& l : fundingLegs_)
128 for (auto const& c : l)
129 lastDate_ = std::max(lastDate_, c->date());
130 for (auto const& c : additionalCashflowLeg_)
131 lastDate_ = std::max(lastDate_, c->date());
132}
const QuantLib::Currency additionalCashflowCurrency_
Definition: trswrapper.hpp:102
std::vector< TRS::FundingData::NotionalType > fundingNotionalTypes_
Definition: trswrapper.hpp:96
std::vector< QuantLib::Date > paymentSchedule_
Definition: trswrapper.hpp:94
std::vector< QuantLib::ext::shared_ptr< QuantLib::Index > > underlyingIndex_
Definition: trswrapper.hpp:87
const QuantLib::Currency fundingCurrency_
Definition: trswrapper.hpp:97
const QuantLib::Currency returnCurrency_
Definition: trswrapper.hpp:93
std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > addFxIndices_
Definition: trswrapper.hpp:105
std::vector< QuantLib::Date > valuationSchedule_
Definition: trswrapper.hpp:94
const QuantLib::Currency initialPriceCurrency_
Definition: trswrapper.hpp:91
QuantLib::Real initialPrice_
Definition: trswrapper.hpp:90
std::vector< QuantLib::Real > underlyingMultiplier_
Definition: trswrapper.hpp:88
std::vector< QuantLib::Leg > fundingLegs_
Definition: trswrapper.hpp:95
std::vector< QuantLib::ext::shared_ptr< ore::data::Trade > > underlying_
Definition: trswrapper.hpp:86
const QuantLib::Size fundingResetGracePeriod_
Definition: trswrapper.hpp:98
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndexReturn_
Definition: trswrapper.hpp:104
QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndexAdditionalCashflows_
Definition: trswrapper.hpp:104
QuantLib::Leg additionalCashflowLeg_
Definition: trswrapper.hpp:100
bool includeUnderlyingCashflowsInReturn_
Definition: trswrapper.hpp:89
std::vector< QuantLib::ext::shared_ptr< QuantExt::FxIndex > > fxIndexAsset_
Definition: trswrapper.hpp:103
const std::vector< QuantLib::Currency > assetCurrency_
Definition: trswrapper.hpp:92

Member Function Documentation

◆ isExpired()

bool isExpired ( ) const
override

Definition at line 134 of file trswrapper.cpp.

134{ return detail::simple_event(lastDate_).hasOccurred(); }

◆ setupArguments()

void setupArguments ( QuantLib::PricingEngine::arguments ) const
override

Definition at line 136 of file trswrapper.cpp.

136 {
137 TRSWrapper::arguments* a = dynamic_cast<TRSWrapper::arguments*>(args);
138 QL_REQUIRE(a != nullptr, "wrong argument type in TRSWrapper");
139 a->underlying_ = underlying_;
140 a->underlyingIndex_ = underlyingIndex_;
141 a->underlyingMultiplier_ = underlyingMultiplier_;
142 a->includeUnderlyingCashflowsInReturn_ = includeUnderlyingCashflowsInReturn_;
143 a->initialPrice_ = initialPrice_;
144 a->initialPriceCurrency_ = initialPriceCurrency_;
145 a->assetCurrency_ = assetCurrency_;
146 a->returnCurrency_ = returnCurrency_;
147 a->valuationSchedule_ = valuationSchedule_;
148 a->paymentSchedule_ = paymentSchedule_;
149 a->fundingLegs_ = fundingLegs_;
150 a->fundingNotionalTypes_ = fundingNotionalTypes_;
151 a->fundingCurrency_ = fundingCurrency_;
152 a->fundingResetGracePeriod_ = fundingResetGracePeriod_;
153 a->paysAsset_ = paysAsset_;
154 a->paysFunding_ = paysFunding_;
155 a->additionalCashflowLeg_ = additionalCashflowLeg_;
156 a->additionalCashflowLegPayer_ = additionalCashflowLegPayer_;
157 a->additionalCashflowCurrency_ = additionalCashflowCurrency_;
158 a->fxIndexAsset_ = fxIndexAsset_;
159 a->fxIndexReturn_ = fxIndexReturn_;
160 a->fxIndexAdditionalCashflows_ = fxIndexAdditionalCashflows_;
161 a->addFxIndices_ = addFxIndices_;
162}

◆ fetchResults()

void fetchResults ( const QuantLib::PricingEngine::results *  ) const
override

Definition at line 172 of file trswrapper.cpp.

172{ Instrument::fetchResults(r); }

Member Data Documentation

◆ underlying_

std::vector<QuantLib::ext::shared_ptr<ore::data::Trade> > underlying_
private

Definition at line 86 of file trswrapper.hpp.

◆ underlyingIndex_

std::vector<QuantLib::ext::shared_ptr<QuantLib::Index> > underlyingIndex_
private

Definition at line 87 of file trswrapper.hpp.

◆ underlyingMultiplier_

std::vector<QuantLib::Real> underlyingMultiplier_
private

Definition at line 88 of file trswrapper.hpp.

◆ includeUnderlyingCashflowsInReturn_

bool includeUnderlyingCashflowsInReturn_
private

Definition at line 89 of file trswrapper.hpp.

◆ initialPrice_

QuantLib::Real initialPrice_
private

Definition at line 90 of file trswrapper.hpp.

◆ initialPriceCurrency_

const QuantLib::Currency initialPriceCurrency_
private

Definition at line 91 of file trswrapper.hpp.

◆ assetCurrency_

const std::vector<QuantLib::Currency> assetCurrency_
private

Definition at line 92 of file trswrapper.hpp.

◆ returnCurrency_

const QuantLib::Currency returnCurrency_
private

Definition at line 93 of file trswrapper.hpp.

◆ valuationSchedule_

std::vector<QuantLib::Date> valuationSchedule_
private

Definition at line 94 of file trswrapper.hpp.

◆ paymentSchedule_

std::vector<QuantLib::Date> paymentSchedule_
private

Definition at line 94 of file trswrapper.hpp.

◆ fundingLegs_

std::vector<QuantLib::Leg> fundingLegs_
private

Definition at line 95 of file trswrapper.hpp.

◆ fundingNotionalTypes_

std::vector<TRS::FundingData::NotionalType> fundingNotionalTypes_
private

Definition at line 96 of file trswrapper.hpp.

◆ fundingCurrency_

const QuantLib::Currency fundingCurrency_
private

Definition at line 97 of file trswrapper.hpp.

◆ fundingResetGracePeriod_

const QuantLib::Size fundingResetGracePeriod_
private

Definition at line 98 of file trswrapper.hpp.

◆ paysAsset_

bool paysAsset_
private

Definition at line 99 of file trswrapper.hpp.

◆ paysFunding_

bool paysFunding_
private

Definition at line 99 of file trswrapper.hpp.

◆ additionalCashflowLeg_

QuantLib::Leg additionalCashflowLeg_
private

Definition at line 100 of file trswrapper.hpp.

◆ additionalCashflowLegPayer_

bool additionalCashflowLegPayer_
private

Definition at line 101 of file trswrapper.hpp.

◆ additionalCashflowCurrency_

const QuantLib::Currency additionalCashflowCurrency_
private

Definition at line 102 of file trswrapper.hpp.

◆ fxIndexAsset_

std::vector<QuantLib::ext::shared_ptr<QuantExt::FxIndex> > fxIndexAsset_
private

Definition at line 103 of file trswrapper.hpp.

◆ fxIndexReturn_

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

Definition at line 104 of file trswrapper.hpp.

◆ fxIndexAdditionalCashflows_

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

Definition at line 104 of file trswrapper.hpp.

◆ addFxIndices_

std::map<std::string, QuantLib::ext::shared_ptr<QuantExt::FxIndex> > addFxIndices_
private

Definition at line 105 of file trswrapper.hpp.

◆ lastDate_

Date lastDate_
private

Definition at line 107 of file trswrapper.hpp.