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

#include <ored/portfolio/convertiblebond.hpp>

+ Inheritance diagram for ConvertibleBondTrsUnderlyingBuilder:
+ Collaboration diagram for ConvertibleBondTrsUnderlyingBuilder:

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
 
void updateUnderlying (const QuantLib::ext::shared_ptr< ReferenceDataManager > &refData, QuantLib::ext::shared_ptr< Trade > &underlying, const std::string &parentId) 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 59 of file convertiblebond.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 601 of file convertiblebond.cpp.

613 {
614 auto t = QuantLib::ext::dynamic_pointer_cast<ore::data::ConvertibleBond>(underlying);
615 QL_REQUIRE(t, "could not cast to ore::data::Bond, this is unexpected");
616 auto qlBond = QuantLib::ext::dynamic_pointer_cast<QuantLib::Bond>(underlying->instrument()->qlInstrument());
617 QL_REQUIRE(qlBond, "expected QuantLib::Bond, could not cast");
618
619 BondIndexBuilder bondIndexBuilder(t->bondData(), true, false, NullCalendar(), true, engineFactory);
620 underlyingIndex = bondIndexBuilder.bondIndex();
621
622 underlyingIndex = bondIndexBuilder.bondIndex();
623 underlyingMultiplier = t->data().bondData().bondNotional();
624
625 indexQuantities[underlyingIndex->name()] = underlyingMultiplier;
626 if (initialPrice != Null<Real>())
627 initialPrice = qlBond->notional(valuationDates.front()) * bondIndexBuilder.priceAdjustment(initialPrice);
628
629 assetCurrency = t->data().bondData().currency();
630 auto fxIndex = getFxIndex(engineFactory->market(), engineFactory->configuration(MarketContext::pricing),
631 assetCurrency, fundingCurrency, fxIndices);
632 auto returnLeg =
633 makeBondTRSLeg(valuationDates, paymentDates, bondIndexBuilder, initialPrice, fxIndex);
634
635 // add required bond and fx fixings for bondIndex
636 returnLegs.push_back(returnLeg);
637 bondIndexBuilder.addRequiredFixings(fixings, returnLeg);
638
639 creditRiskCurrency = t->data().bondData().currency();
640 creditQualifierMapping[securitySpecificCreditCurveName(t->bondData().securityId(), t->bondData().creditCurveId())] =
641 SimmCreditQualifierMapping(t->data().bondData().securityId(), t->data().bondData().creditGroup());
642 creditQualifierMapping[t->bondData().creditCurveId()] =
643 SimmCreditQualifierMapping(t->data().bondData().securityId(), t->data().bondData().creditGroup());
644 // FIXME shouldn't we leave that empty and let TRS determine the maturity date based on valuation / funding dates?
645 maturity = qlBond->maturityDate();
646}
Time maturity
Definition: utilities.cpp:66
std::string securitySpecificCreditCurveName(const std::string &securityId, const std::string &creditCurveId)
Definition: marketdata.cpp:79
Leg makeBondTRSLeg(const std::vector< Date > &valuationDates, const std::vector< Date > &paymentDates, const BondIndexBuilder &bondIndexBuilder, Real initialPrice, QuantLib::ext::shared_ptr< QuantExt::FxIndex > fxIndex)
+ Here is the call graph for this function:

◆ updateUnderlying()

void updateUnderlying ( const QuantLib::ext::shared_ptr< ReferenceDataManager > &  refData,
QuantLib::ext::shared_ptr< Trade > &  underlying,
const std::string &  parentId 
) const
overridevirtual

Reimplemented from TrsUnderlyingBuilder.

Definition at line 648 of file convertiblebond.cpp.

650 {
651
652 /* If the underlying is a bond, but the security id is actually pointing to reference data of a non-vanilla bond
653 flavour like a convertible bond, callable bond, etc., we change the underlying to that non-vanilla bond flavour
654 here on the fly. This way we can reference a bond from a TRS without knowing its flavour. */
655
656 if (underlying->tradeType() == "Bond") {
657 auto bond = QuantLib::ext::dynamic_pointer_cast<ore::data::Bond>(underlying);
658 QL_REQUIRE(bond, "TRS::build(): internal error, could not cast underlying trade to bond");
659 if (refData != nullptr &&
660 refData->hasData(ConvertibleBondReferenceDatum::TYPE, bond->bondData().securityId())) {
661 DLOG("Underlying trade type is bond, but security id '"
662 << bond->bondData().securityId()
663 << "' points to convertible bond in ref data, so we change the underlying trade type accordingly.");
664 underlying = QuantLib::ext::make_shared<ConvertibleBond>(Envelope(), ConvertibleBondData(bond->bondData()));
665 underlying->id() = parentId + "_underlying";
666 }
667 }
668}
#define DLOG(text)
Logging Macro (Level = Debug)
Definition: log.hpp:554