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

#include <ored/portfolio/convertiblebond.hpp>

+ Inheritance diagram for ConvertibleBondBuilder:
+ Collaboration diagram for ConvertibleBondBuilder:

Public Member Functions

BondBuilder::Result build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData, const std::string &securityId) const override
 
- Public Member Functions inherited from BondBuilder
virtual ~BondBuilder ()
 
virtual Result build (const QuantLib::ext::shared_ptr< EngineFactory > &engineFactory, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData, const std::string &securityId) const =0
 

Detailed Description

Definition at line 77 of file convertiblebond.hpp.

Member Function Documentation

◆ build()

BondBuilder::Result build ( const QuantLib::ext::shared_ptr< EngineFactory > &  engineFactory,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceData,
const std::string &  securityId 
) const
overridevirtual

Implements BondBuilder.

Definition at line 670 of file convertiblebond.cpp.

672 {
673 static long id = 0;
674 ConvertibleBondData data(BondData(securityId, 1.0));
675 data.populateFromBondReferenceData(referenceData);
676 ConvertibleBond bond(Envelope(), data);
677 bond.id() = "ConvertibleBondBuilder_" + securityId + "_" + std::to_string(id++);
678 bond.build(engineFactory);
679
680 QL_REQUIRE(bond.instrument(), "ConvertibleBondBuilder: constructed bond is null, this is unexpected");
681 auto qlBond = QuantLib::ext::dynamic_pointer_cast<QuantLib::Bond>(bond.instrument()->qlInstrument());
682
683 QL_REQUIRE(
684 bond.instrument() && bond.instrument()->qlInstrument(),
685 "ConvertibleBondBuilder: constructed bond trade does not provide a valid ql instrument, this is unexpected "
686 "(either the instrument wrapper or the ql instrument is null)");
687
688 BondBuilder::Result res;
689 res.bond = qlBond;
690 res.hasCreditRisk = data.bondData().hasCreditRisk() && !data.bondData().creditCurveId().empty();
691 res.currency = data.bondData().currency();
692 res.creditCurveId = data.bondData().creditCurveId();
693 res.securityId = data.bondData().securityId();
694 res.creditGroup = data.bondData().creditGroup();
695 res.priceQuoteMethod = data.bondData().priceQuoteMethod();
696 res.priceQuoteBaseValue = data.bondData().priceQuoteBaseValue();
697
698 auto builders = engineFactory->modelBuilders();
699 auto b = std::find_if(builders.begin(), builders.end(),
700 [&bond](const std::pair<const std::string&, const QuantLib::ext::shared_ptr<ModelBuilder>>& p) {
701 return bond.id() == p.first;
702 });
703 QL_REQUIRE(b != builders.end(), "ConvertibleBondBuilder: could not get model builder for bond '"
704 << bond.id() << "' from engine factory - this is an internal error.");
705 res.modelBuilder = b->second;
706
707 return res;
708}
@ data
Definition: log.hpp:77