27 std::string& issuerId, std::string& settlementDays, std::string&
calendar,
28 std::string& issueDate, std::string& priceQuoteMethod,
string& priceQuoteBaseValue,
29 std::string& creditCurveId, std::string& creditGroup, std::string& referenceCurveId,
30 std::string& incomeCurveId, std::string& volatilityCurveId,
31 std::vector<LegData>& coupons,
const std::string&
name,
32 const QuantLib::ext::shared_ptr<BondReferenceDatum>& bondRefData,
33 const std::string& startDate,
const std::string& endDate) {
34 DLOG(
"populating data bond from reference data");
35 QL_REQUIRE(bondRefData,
"populateFromBondReferenceData(): empty bond reference datum given");
36 if (subType.empty()) {
37 subType = bondRefData->bondData().subType;
38 TLOG(
"overwrite subType with '" << subType <<
"'");
40 if (issuerId.empty()) {
41 issuerId = bondRefData->bondData().issuerId;
42 TLOG(
"overwrite issuerId with '" << issuerId <<
"'");
44 if (settlementDays.empty()) {
45 settlementDays = bondRefData->bondData().settlementDays;
46 TLOG(
"overwrite settlementDays with '" << settlementDays <<
"'");
49 calendar = bondRefData->bondData().calendar;
52 if (issueDate.empty()) {
53 issueDate = bondRefData->bondData().issueDate;
54 TLOG(
"overwrite issueDate with '" << issueDate <<
"'");
56 if (priceQuoteMethod.empty()) {
57 priceQuoteMethod = bondRefData->bondData().priceQuoteMethod;
58 TLOG(
"overwrite priceQuoteMethod with '" << priceQuoteMethod <<
"'");
60 if (priceQuoteBaseValue.empty()) {
61 priceQuoteBaseValue = bondRefData->bondData().priceQuoteBaseValue;
62 TLOG(
"overwrite priceQuoteBaseValue with '" << priceQuoteBaseValue <<
"'");
64 if (creditCurveId.empty()) {
65 creditCurveId = bondRefData->bondData().creditCurveId;
66 TLOG(
"overwrite creditCurveId with '" << creditCurveId <<
"'");
68 if (creditGroup.empty()) {
69 creditGroup = bondRefData->bondData().creditGroup;
70 TLOG(
"overwrite creditGroup with '" << creditGroup <<
"'");
72 if (referenceCurveId.empty()) {
73 referenceCurveId = bondRefData->bondData().referenceCurveId;
74 TLOG(
"overwrite referenceCurveId with '" << referenceCurveId <<
"'");
76 if (incomeCurveId.empty()) {
77 incomeCurveId = bondRefData->bondData().incomeCurveId;
78 TLOG(
"overwrite incomeCurveId with '" << incomeCurveId <<
"'");
80 if (volatilityCurveId.empty()) {
81 volatilityCurveId = bondRefData->bondData().volatilityCurveId;
82 TLOG(
"overwrite volatilityCurveId with '" << volatilityCurveId <<
"'");
84 if (coupons.empty()) {
85 coupons = bondRefData->bondData().legData;
86 TLOG(
"overwrite coupons with " << coupons.size() <<
" LegData nodes");
88 if (!startDate.empty()) {
89 if (coupons.size() == 1 && coupons.front().schedule().rules().size() == 1 && coupons.front().schedule().dates().size() == 0) {
90 string oldStart = coupons.front().schedule().rules().front().startDate();
91 coupons.front().schedule().modifyRules().front().modifyStartDate() = startDate;
92 string newStart = coupons.front().schedule().rules().front().startDate();
93 DLOG(
"Modified start date " << oldStart <<
" -> " << newStart);
97 "modifified start date cannot be applied to multiple legs/schedules")
101 if (!endDate.empty()) {
102 if (coupons.size() == 1 && coupons.front().schedule().rules().size() == 1 && coupons.front().schedule().dates().size() == 0) {
103 string oldEnd = coupons.front().schedule().rules().front().endDate();
104 coupons.front().schedule().modifyRules().front().modifyEndDate() = endDate;
105 string newEnd = coupons.front().schedule().rules().front().endDate();
106 DLOG(
"Modified end date " << oldEnd <<
" -> " << newEnd);
110 "modifified end date cannot be applied to multiple legs/schedules")
115 DLOG(
"populating bond data from reference data done.");
119 if (replacementPeriodStr.empty())
120 return QuantLib::Null<QuantLib::Date>();
121 Date today = Settings::instance().evaluationDate();
122 Date result = Date::maxDate() - 365;
128 DLOG(
"Compute open end date replacement as "
129 << QuantLib::io::iso_date(result) <<
" (today = " << QuantLib::io::iso_date(today)
130 <<
", OpenEndDateReplacement from pricing engine config = " << replacementPeriodStr <<
")");
void log() const
generate Boost log record to pass to corresponding sinks
Utility class for Structured Trade errors, contains the Trade ID and Type.
Period parsePeriod(const string &s)
Convert text to QuantLib::Period.
Classes and functions for log message handling.
#define DLOG(text)
Logging Macro (Level = Debug)
#define TLOG(text)
Logging Macro (Level = Data)
Date getOpenEndDateReplacement(const std::string &replacementPeriodStr, const Calendar &calendar)
void populateFromBondReferenceData(std::string &subType, std::string &issuerId, std::string &settlementDays, std::string &calendar, std::string &issueDate, std::string &priceQuoteMethod, string &priceQuoteBaseValue, std::string &creditCurveId, std::string &creditGroup, std::string &referenceCurveId, std::string &incomeCurveId, std::string &volatilityCurveId, std::vector< LegData > &coupons, const std::string &name, const QuantLib::ext::shared_ptr< BondReferenceDatum > &bondRefData, const std::string &startDate, const std::string &endDate)
Populate bond data from name and ReferenceDataManager.
Serializable Credit Default Swap.
Structured Trade Error class.