Skip to content

Commit 8b32e85

Browse files
committed
QPR-13647 add market calibration reports to restore
1 parent aa4e08c commit 8b32e85

5 files changed

Lines changed: 30 additions & 19 deletions

File tree

OREAnalytics/orea/app/analytic.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -279,9 +279,9 @@ void Analytic::buildMarket(const QuantLib::ext::shared_ptr<ore::data::InMemoryLo
279279
LOG("Market Build time " << setprecision(2) << mTimer->format(default_places, "%w") << " sec");
280280
}
281281

282-
void Analytic::marketCalibration(const QuantLib::ext::shared_ptr<MarketCalibrationReportBase>& mcr) {
283-
if (mcr)
284-
mcr->populateReport(market_, configurations().todaysMarketParams);
282+
void Analytic::marketCalibration(const std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>& mcr) {
283+
for (auto r : mcr)
284+
r->populateReport(market_, configurations().todaysMarketParams);
285285
}
286286

287287
void Analytic::buildPortfolio(const bool emitStructuredError) {

OREAnalytics/orea/app/analytic.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -113,7 +113,7 @@ class Analytic {
113113
virtual void buildMarket(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
114114
const bool marketRequired = true);
115115
virtual void buildPortfolio(const bool emitStructuredError = true);
116-
virtual void marketCalibration(const QuantLib::ext::shared_ptr<MarketCalibrationReportBase>& mcr = nullptr);
116+
virtual void marketCalibration(const std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>& mcr = {});
117117
virtual void modifyPortfolio() {}
118118
virtual void replaceTrades() {}
119119
virtual void enrichIndexFixings(const QuantLib::ext::shared_ptr<ore::data::Portfolio>& portfolio);

OREAnalytics/orea/app/analyticsmanager.cpp

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,13 @@ std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>> Analyt
9393

9494
void AnalyticsManager::runAnalytics(
9595
const QuantLib::ext::shared_ptr<MarketCalibrationReportBase>& marketCalibrationReport) {
96+
runAnalytics(marketCalibrationReport == nullptr
97+
? std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>()
98+
: std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>{marketCalibrationReport});
99+
}
100+
101+
void AnalyticsManager::runAnalytics(
102+
const std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>& marketCalibrationReport) {
96103
QL_REQUIRE(initialised_, "AnalyticsManager has not been initialised");
97104
if (analytics_.size() == 0)
98105
return;
@@ -150,8 +157,7 @@ void AnalyticsManager::runAnalytics(
150157
a.second->stopTimer("Run " + a.second->label() + "Analytic");
151158
LOG("run analytic with label '" << a.first << "' finished.");
152159
// then populate the market calibration report if required
153-
if (marketCalibrationReport)
154-
a.second->marketCalibration(marketCalibrationReport);
160+
a.second->marketCalibration(marketCalibrationReport);
155161
}
156162

157163
if (inputs_->portfolio()) {
@@ -173,13 +179,16 @@ void AnalyticsManager::runAnalytics(
173179
reports_["STATS"]["runtimes"] = runTimesReport;
174180
}
175181

176-
if (marketCalibrationReport) {
177-
if (auto rpt =
178-
QuantLib::ext::dynamic_pointer_cast<InMemoryReport>(marketCalibrationReport->outputCalibrationReport()))
179-
reports_["MARKET"]["todaysmarketcalibration"] = rpt;
180-
if (auto rpt =
181-
QuantLib::ext::dynamic_pointer_cast<InMemoryReport>(marketCalibrationReport->outputCashflowReport()))
182-
reports_["MARKET"]["todaysmarketcalibration_cashflows"] = rpt;
182+
Size noa = 0, nob = 0;
183+
for (auto r : marketCalibrationReport) {
184+
if (auto rpt = QuantLib::ext::dynamic_pointer_cast<InMemoryReport>(r->outputCalibrationReport())) {
185+
std::string suffix = noa++ == 0 ? std::string() : "_" + std::to_string(noa);
186+
reports_["MARKET"]["todaysmarketcalibration" + suffix] = rpt;
187+
}
188+
if (auto rpt = QuantLib::ext::dynamic_pointer_cast<InMemoryReport>(r->outputCashflowReport())) {
189+
std::string suffix = nob++ == 0 ? std::string() : "_" + std::to_string(nob);
190+
reports_["MARKET"]["todaysmarketcalibration_cashflows" + suffix] = rpt;
191+
}
183192
}
184193

185194
inputs_->writeOutParameters();

OREAnalytics/orea/app/analyticsmanager.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,8 @@ class AnalyticsManager : public QuantLib::ext::enable_shared_from_this<Analytics
5454
const QuantLib::ext::shared_ptr<InputParameters>& inputs() { return inputs_; }
5555
std::vector<QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters>> todaysMarketParams();
5656
void runAnalytics(const QuantLib::ext::shared_ptr<MarketCalibrationReportBase>& marketCalibrationReport = nullptr);
57+
void
58+
runAnalytics(const std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>>& marketCalibrationReport);
5759
void addAnalytic(const std::string& label, const QuantLib::ext::shared_ptr<Analytic>& analytic);
5860

5961
std::vector<std::string> failedAnalytics() { return failedAnalytics_; }

OREAnalytics/orea/app/oreapp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -262,12 +262,12 @@ void OREApp::analytics() {
262262
CONSOLE(to_string(inputs_->analytics()));
263263
LOG("Requested analytics: " << to_string(inputs_->analytics()));
264264

265-
QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
265+
std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>> mcr;
266266
if (inputs_->outputTodaysMarketCalibration()) {
267-
mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(
267+
mcr.push_back(QuantLib::ext::make_shared<MarketCalibrationReport>(
268268
string(), QuantLib::ext::make_shared<ore::data::InMemoryReport>(inputs_->reportBufferSize()),
269269
QuantLib::ext::make_shared<ore::data::InMemoryReport>(inputs_->reportBufferSize()),
270-
inputs_->todaysMarketCalibrationPrecision());
270+
inputs_->todaysMarketCalibrationPrecision()));
271271
}
272272

273273
// Run the requested analytics
@@ -539,12 +539,12 @@ void OREApp::run(const QuantLib::ext::shared_ptr<MarketDataLoader> loader) {
539539
CONSOLE(to_string(inputs_->analytics()));
540540
LOG("Requested analytics: " << to_string(inputs_->analytics()));
541541

542-
QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
542+
std::vector<QuantLib::ext::shared_ptr<MarketCalibrationReportBase>> mcr;
543543
if (inputs_->outputTodaysMarketCalibration()) {
544-
mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(
544+
mcr.push_back(QuantLib::ext::make_shared<MarketCalibrationReport>(
545545
string(), QuantLib::ext::make_shared<ore::data::InMemoryReport>(inputs_->reportBufferSize()),
546546
QuantLib::ext::make_shared<ore::data::InMemoryReport>(inputs_->reportBufferSize()),
547-
inputs_->todaysMarketCalibrationPrecision());
547+
inputs_->todaysMarketCalibrationPrecision()));
548548
}
549549

550550
// Run the requested analytics

0 commit comments

Comments
 (0)