31 for (
auto const n : c) {
48 QL_REQUIRE(!
identifier_.empty(),
"BondPositionData::populateFromBondBasketReferenceData(): no identifier given");
50 DLOG(
"could not get BondBasketReferenceDatum for '" <<
identifier_ <<
"' leave data in trade unchanged");
53 auto r = QuantLib::ext::dynamic_pointer_cast<BondBasketReferenceDatum>(
55 QL_REQUIRE(r,
"BondPositionData::populateFromBondBasketReferenceData(): internal error, could not cast "
56 "reference datum to expected type.");
63 DLOG(
"BondPosition::build() called for " <<
id());
80 QL_REQUIRE(!
data_.
underlyings().empty(),
"BondPosition::build(): no underlyings given");
85 bonds_.push_back(BondFactory::instance().
build(engineFactory, engineFactory->referenceData(), u.name()));
86 }
catch (
const std::exception& e) {
87 QL_FAIL(
"Build failed for underlying " << u.type() <<
" (" << u.name() <<
"): " << e.what());
98 for (
auto const& b :
bonds_) {
106 std::vector<QuantLib::ext::shared_ptr<QuantLib::Bond>> qlbonds;
107 std::transform(
bonds_.begin(),
bonds_.end(), std::back_inserter(qlbonds),
121 QuantLib::ext::static_pointer_cast<BondPositionInstrumentWrapper>(
instrument_)->setNpvCurrencyConversion(conversion);
136std::map<AssetClass, std::set<std::string>>
138 std::map<AssetClass, std::set<std::string>> result;
147 const Real quantity,
const std::vector<QuantLib::ext::shared_ptr<QuantLib::Bond>>& bonds,
const std::vector<Real>& weights,
148 const std::vector<Real>& bidAskAdjustments,
const std::vector<Handle<Quote>>& fxConversion)
149 : quantity_(quantity), bonds_(bonds), weights_(weights), bidAskAdjustments_(bidAskAdjustments),
150 fxConversion_(fxConversion) {
151 QL_REQUIRE(
bonds_.size() ==
weights_.size(),
"BondPositionInstrumentWrapper: bonds size ("
152 <<
bonds_.size() <<
") must match weights size ("
155 "BondPositionInstrumentWrapper: bonds size (" <<
bonds_.size() <<
") must match bidAskAdjustment size ("
158 "BondPositionInstrumentWrapper: fxConversion size ("
168 for (Size i = 0; i <
bonds_.size(); ++i) {
184 static std::map<std::string, boost::any> emptyMap;
Bond Position trade data model and serialization.
static constexpr const char * TYPE
std::vector< BondUnderlying > underlyings_
void populateFromBondBasketReferenceData(const QuantLib::ext::shared_ptr< ReferenceDataManager > &ref)
const std::vector< BondUnderlying > & underlyings() const
void fromXML(XMLNode *node) override
XMLNode * toXML(XMLDocument &doc) const override
BondPositionData originalData_
std::map< AssetClass, std::set< std::string > > underlyingIndices(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager=nullptr) const override
const BondPositionData & data() const
void fromXML(XMLNode *node) override
std::vector< Handle< Quote > > fxConversion_
void setNpvCurrencyConversion(const std::string &ccy, const Handle< Quote > &conversion)
XMLNode * toXML(XMLDocument &doc) const override
std::vector< Real > weights_
void build(const QuantLib::ext::shared_ptr< ore::data::EngineFactory > &) override
std::vector< Real > bidAskAdjustments_
std::vector< BondBuilder::Result > bonds_
BondPositionInstrumentWrapper(const Real quantity, const std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > &bonds, const std::vector< Real > &weights, const std::vector< Real > &bidAskAdjstments, const std::vector< Handle< Quote > > &fxConversion={})
QuantLib::Real NPV() const override
Return the NPV of this instrument.
const std::map< std::string, boost::any > & additionalResults() const override
Return the additional results of this instrument.
std::vector< Handle< Quote > > fxConversion_
std::vector< Real > weights_
std::vector< Real > bidAskAdjustments_
Handle< Quote > npvCcyConversion_
std::vector< QuantLib::ext::shared_ptr< QuantLib::Bond > > bonds_
void setNpvCurrencyConversion(const Handle< Quote > &npvCcyConversion)
virtual void fromXML(XMLNode *node) override
void setSensitivityTemplate(const EngineBuilder &builder)
virtual XMLNode * toXML(XMLDocument &doc) const override
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Small XML Document wrapper class.
XMLNode * allocNode(const string &nodeName)
util functions that wrap rapidxml
static void checkNode(XMLNode *n, const string &expectedName)
static vector< XMLNode * > getChildrenNodes(XMLNode *node, const string &name)
Returns all the children with a given name.
static Real getChildValueAsDouble(XMLNode *node, const string &name, bool mandatory=false, double defaultValue=0.0)
static string getChildValue(XMLNode *node, const string &name, bool mandatory=false, const string &defaultValue=string())
static XMLNode * getChildNode(XMLNode *n, const string &name="")
static XMLNode * addChild(XMLDocument &doc, XMLNode *n, const string &name)
static void appendNode(XMLNode *parent, XMLNode *child)
#define DLOG(text)
Logging Macro (Level = Debug)
Serializable Credit Default Swap.
Reference data model and serialization.