Build QuantLib/QuantExt instrument, link pricing engine. If build() is called multiple times, reset() should be called between these calls.
36 {
37 DLOG(
"CBO::build() called for trade " <<
id());
38
39
40
45
47
48 const QuantLib::ext::shared_ptr<Market> market = engineFactory->market();
49 QuantLib::ext::shared_ptr<EngineBuilder> builder = engineFactory->builder("CBO");
50
53
55
58
59 vector<QuantExt::Tranche> tranches;
60 size_t investCount = 0;
61 size_t idx = 0;
64
66
71
78
79 auto legBuilder = engineFactory->legBuilder(trancheData_[i]->concreteLegData()->legType());
81 auto configuration = builder->configuration(MarketContext::pricing);
82 Leg leg = legBuilder->buildLeg(legdata, engineFactory, requiredFixingsLeg, configuration);
84
86 tranches.push_back(tranche);
87
88
90 idx = i;
92 if(multiplier_ > 1.0)
93 ALOG(
"Ratio bigger than 1 : investment=" << investedNotional_ <<
" vs. faceAmount=" << tranche.
faceAmount);
94 investCount++;
95 }
96 }
97
98 QL_REQUIRE(investCount == 1,
"Could not assign CBOInvestment TrancheName " <<
investedTrancheName_ <<
" to Names of CBOTranches.");
99
100
101 Date longestBondDate = Settings::instance().evaluationDate();
103 Date bondMat = bond.second->maturityDate();
104 if (bondMat > longestBondDate)
105 longestBondDate = bondMat;
106 }
107 QL_REQUIRE(schedule.endDate() > longestBondDate, " Tranche Maturity should be after Bond Maturity: Bond "
108 << longestBondDate << " vs. Tranche " << schedule.endDate());
109
110
111 QuantLib::ext::shared_ptr<QuantExt::CBO> cbo =
115
116 QuantLib::ext::shared_ptr<CboMCEngineBuilder> cboBuilder = QuantLib::ext::dynamic_pointer_cast<CboMCEngineBuilder>(builder);
117 QL_REQUIRE(cboBuilder, "No Builder found for CBO: " << id());
118 cbo->setPricingEngine(cboBuilder->engine(
bondbasket_->pool()));
121
125 legs_ = vector<QuantLib::Leg>(1, tranches[idx].leg);
128
129
132 bond->bondData().creditCurveId()));
133 cbo->registerWith(bond->instrument()->qlInstrument());
134
135
136 Leg bondleg = bond->legs().front();
137 for (auto const& c : bondleg)
138 cbo->registerWith(c);
139 }
140
141 std::map<string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>> fxIndexMap =
bondbasket_->fxIndexMap();
142 std::map<string, QuantLib::ext::shared_ptr<QuantExt::FxIndex>>::iterator it;
143 for (it = fxIndexMap.begin(); it != fxIndexMap.end(); ++it)
144 cbo->registerWith(it->second);
145}
std::string investedTrancheName_
DayCounter feeDayCounter_
QuantLib::ext::shared_ptr< QuantExt::BondBasket > bondbasket_
const BondBasket & bondBasketData()
ScheduleData scheduleData_
void populateFromCboReferenceData(const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceDataManager)
std::vector< QuantLib::ext::shared_ptr< TrancheData > > trancheData_
std::string paymentConvention_
Serializable object holding leg data.
const string & paymentConvention() const
const ScheduleData & schedule() const
const string & dayCounter() const
QuantLib::ext::shared_ptr< LegAdditionalData > concreteLegData() const
const vector< double > & notionals() const
void addData(const RequiredFixings &requiredFixings)
std::vector< bool > legPayers_
std::vector< string > legCurrencies_
std::vector< QuantLib::Leg > legs_
void setSensitivityTemplate(const EngineBuilder &builder)
RequiredFixings requiredFixings_
QuantLib::ext::shared_ptr< InstrumentWrapper > instrument_
std::map< std::string, boost::any > additionalData_
Vanilla Instrument Wrapper.
Currency parseCurrency(const string &s)
Convert text to QuantLib::Currency.
Real parseReal(const string &s)
Convert text to Real.
DayCounter parseDayCounter(const string &s)
Convert text to QuantLib::DayCounter.
#define DLOG(text)
Logging Macro (Level = Debug)
#define ALOG(text)
Logging Macro (Level = Alert)
QuantLib::Handle< QuantExt::CreditCurve > securitySpecificCreditCurve(const QuantLib::ext::shared_ptr< Market > &market, const std::string &securityId, const std::string &creditCurveId, const std::string &configuration)
Schedule makeSchedule(const ScheduleDates &data)