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

#include <ored/portfolio/trsunderlyingbuilder.hpp>

+ Inheritance diagram for BondTrsUnderlyingBuilder:
+ Collaboration diagram for BondTrsUnderlyingBuilder:

Public Member Functions

void build (const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const override
 
- Public Member Functions inherited from TrsUnderlyingBuilder
virtual ~TrsUnderlyingBuilder ()
 
virtual void build (const std::string &parentId, const QuantLib::ext::shared_ptr< Trade > &underlying, const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const std::string &fundingCurrency, const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, QuantLib::ext::shared_ptr< QuantLib::Index > &underlyingIndex, Real &underlyingMultiplier, std::map< std::string, double > &indexQuantities, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices, Real &initialPrice, std::string &assetCurrency, std::string &creditRiskCurrency, std::map< std::string, SimmCreditQualifierMapping > &creditQualifierMapping, Date &maturity, const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &getFxIndex, const std::string &underlyingDerivativeId, RequiredFixings &fixings, std::vector< Leg > &returnLegs) const =0
 
virtual void updateUnderlying (const QuantLib::ext::shared_ptr< ReferenceDataManager > &refData, QuantLib::ext::shared_ptr< Trade > &underlying, const std::string &parentId) const
 

Detailed Description

Definition at line 65 of file trsunderlyingbuilder.hpp.

Member Function Documentation

◆ build()

void build ( const std::string &  parentId,
const QuantLib::ext::shared_ptr< Trade > &  underlying,
const std::vector< Date > &  valuationDates,
const std::vector< Date > &  paymentDates,
const std::string &  fundingCurrency,
const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
QuantLib::ext::shared_ptr< QuantLib::Index > &  underlyingIndex,
Real &  underlyingMultiplier,
std::map< std::string, double > &  indexQuantities,
std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &  fxIndices,
Real &  initialPrice,
std::string &  assetCurrency,
std::string &  creditRiskCurrency,
std::map< std::string, SimmCreditQualifierMapping > &  creditQualifierMapping,
Date &  maturity,
const std::function< QuantLib::ext::shared_ptr< QuantExt::FxIndex >(const QuantLib::ext::shared_ptr< Market > market, const std::string &configuration, const std::string &domestic, const std::string &foreign, std::map< std::string, QuantLib::ext::shared_ptr< QuantExt::FxIndex > > &fxIndices)> &  getFxIndex,
const std::string &  underlyingDerivativeId,
RequiredFixings fixings,
std::vector< Leg > &  returnLegs 
) const
overridevirtual

Implements TrsUnderlyingBuilder.

Definition at line 78 of file trsunderlyingbuilder.cpp.

90 {
91 auto t = QuantLib::ext::dynamic_pointer_cast<ore::data::Bond>(underlying);
92 QL_REQUIRE(t, "could not cast to ore::data::Bond, this is unexpected");
93 auto qlBond = QuantLib::ext::dynamic_pointer_cast<QuantLib::Bond>(underlying->instrument()->qlInstrument());
94 QL_REQUIRE(qlBond, "expected QuantLib::Bond, could not cast");
95 BondIndexBuilder bondIndexBuilder(*t, true, false, NullCalendar(), true, engineFactory);
96 underlyingIndex = bondIndexBuilder.bondIndex();
97
98 underlyingMultiplier = t->bondData().bondNotional();
99 indexQuantities[underlyingIndex->name()] = underlyingMultiplier;
100
101 if (initialPrice != Null<Real>())
102 initialPrice = qlBond->notional(valuationDates.front()) * bondIndexBuilder.priceAdjustment(initialPrice);
103
104 assetCurrency = t->bondData().currency();
105
106 auto fxIndex = getFxIndex(engineFactory->market(), engineFactory->configuration(MarketContext::pricing), assetCurrency,
107 fundingCurrency, fxIndices);
108
109 auto leg = QuantExt::BondTRSLeg(valuationDates, paymentDates, bondIndexBuilder.bond().bondData().bondNotional(),
110 bondIndexBuilder.bondIndex(), fxIndex)
111 .withInitialPrice(initialPrice);
112
113 // add required bond and fx fixings for bondIndex
114 returnLegs.push_back(leg);
115 bondIndexBuilder.addRequiredFixings(fixings, leg);
116
117 if (!t->bondData().creditCurveId().empty())
118 creditRiskCurrency = t->bondData().currency();
119 creditQualifierMapping[securitySpecificCreditCurveName(t->bondData().securityId(), t->bondData().creditCurveId())] =
120 SimmCreditQualifierMapping(t->bondData().securityId(), t->bondData().creditGroup());
121 creditQualifierMapping[t->bondData().creditCurveId()] =
122 SimmCreditQualifierMapping(t->bondData().securityId(), t->bondData().creditGroup());
123 // FIXME shouldn't we leave that empty and let TRS determine the maturity date based on valuation / funding dates?
124 maturity = qlBond->maturityDate();
125}
BondTRSLeg & withInitialPrice(Real)
Time maturity
Definition: utilities.cpp:66
std::string securitySpecificCreditCurveName(const std::string &securityId, const std::string &creditCurveId)
Definition: marketdata.cpp:79
+ Here is the call graph for this function: