Skip to content

Commit cc265cd

Browse files
pcaspersjenkins
authored andcommitted
QPR-11659 write out factor names
1 parent f8cc24a commit cc265cd

2 files changed

Lines changed: 16 additions & 4 deletions

File tree

OREAnalytics/orea/app/reportwriter.cpp

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1143,14 +1143,25 @@ void ReportWriter::writeSensitivityReport(Report& report, const boost::shared_pt
11431143

11441144
void ReportWriter::writeSensitivityConfigReport(ore::data::Report& report,
11451145
const std::map<RiskFactorKey, QuantLib::Real>& shiftSizes,
1146-
const std::map<RiskFactorKey, QuantLib::Real>& baseValues) {
1146+
const std::map<RiskFactorKey, QuantLib::Real>& baseValues,
1147+
const std::map<RiskFactorKey, std::string>& keyToFactor) {
11471148
LOG("Writing Sensitivity Config report");
11481149

1149-
report.addColumn("Key", string()).addColumn("BaseValue", double(), 8).addColumn("ShiftSize", double(), 8);
1150+
report.addColumn("Key", string())
1151+
.addColumn("Factor", string())
1152+
.addColumn("BaseValue", double(), 8)
1153+
.addColumn("ShiftSize", double(), 8);
11501154

11511155
for (auto const& [key, shift] : shiftSizes) {
11521156
report.next();
1153-
report.add(ore::data::to_string(key)).add(baseValues.at(key)).add(shift);
1157+
std::string keyStr = "na", factorStr = "na";
1158+
Real baseValue = Null<Real>();
1159+
keyStr = ore::data::to_string(key);
1160+
if (auto it = keyToFactor.find(key); it != keyToFactor.end())
1161+
factorStr = it->second;
1162+
if (auto it = baseValues.find(key); it != baseValues.end())
1163+
baseValue = it->second;
1164+
report.add(keyStr).add(factorStr).add(baseValue).add(shift);
11541165
}
11551166

11561167
report.end();

OREAnalytics/orea/app/reportwriter.hpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,7 +106,8 @@ class ReportWriter {
106106

107107
virtual void writeSensitivityConfigReport(ore::data::Report& report,
108108
const std::map<RiskFactorKey, QuantLib::Real>& shiftSizes,
109-
const std::map<RiskFactorKey, QuantLib::Real>& baseValues);
109+
const std::map<RiskFactorKey, QuantLib::Real>& baseValues,
110+
const std::map<RiskFactorKey, std::string>& keyToFactor);
110111

111112
virtual void writeAdditionalResultsReport(ore::data::Report& report, boost::shared_ptr<ore::data::Portfolio> portfolio,
112113
boost::shared_ptr<Market> market, const std::string& baseCurrency);

0 commit comments

Comments
 (0)