Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
oreapp.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19
20#ifdef BOOST_MSVC
21// disable warning C4503: '__LINE__Var': decorated name length exceeded, name was truncated
22// This pragma statement needs to be at the top of the file - lower and it will not work:
23// http://stackoverflow.com/questions/9673504/is-it-possible-to-disable-compiler-warning-c4503
24// http://boost.2283326.n4.nabble.com/General-Warnings-and-pragmas-in-MSVC-td2587449.html
25#pragma warning(disable : 4503)
26#endif
27
31#include <orea/app/oreapp.hpp>
34#include <orea/cube/cube_io.hpp>
36
41
42#include <qle/version.hpp>
43
44
45#include <ql/cashflows/floatingratecoupon.hpp>
46#include <ql/time/calendars/all.hpp>
47#include <ql/time/daycounters/all.hpp>
48
49#include <boost/algorithm/string.hpp>
50#include <boost/filesystem.hpp>
51#include <boost/timer/timer.hpp>
52
53#include <mutex>
54
55using namespace std;
56using namespace ore::data;
57using namespace ore::analytics;
58using boost::timer::cpu_timer;
59using boost::timer::default_places;
60
61namespace ore {
62namespace analytics {
63
64std::set<std::string> OREApp::getAnalyticTypes() {
65 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
66 return analyticsManager_->requestedAnalytics();
67}
68
69std::set<std::string> OREApp::getSupportedAnalyticTypes() {
70 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
71 return analyticsManager_->validAnalytics();
72}
73
74const QuantLib::ext::shared_ptr<Analytic>& OREApp::getAnalytic(std::string type) {
75 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
76 return analyticsManager_->getAnalytic(type);
77}
78
79std::set<std::string> OREApp::getReportNames() {
80 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
81 std::set<std::string> names;
82 for (const auto& rep : analyticsManager_->reports()) {
83 for (auto b : rep.second) {
84 string reportName = b.first;
85 if (names.find(reportName) == names.end())
86 names.insert(reportName);
87 else {
88 ALOG("report name " << reportName
89 << " occurs more than once, will retrieve the first report with that only");
90 }
91 }
92 }
93 return names;
94}
95
96QuantLib::ext::shared_ptr<PlainInMemoryReport> OREApp::getReport(std::string reportName) {
97 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
98 for (const auto& rep : analyticsManager_->reports()) {
99 for (auto b : rep.second) {
100 if (reportName == b.first)
101 return QuantLib::ext::make_shared<PlainInMemoryReport>(b.second);
102 }
103 }
104 QL_FAIL("report " << reportName << " not found in results");
105}
106
107std::set<std::string> OREApp::getCubeNames() {
108 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
109 std::set<std::string> names;
110 for (const auto& c : analyticsManager_->npvCubes()) {
111 for (auto b : c.second) {
112 string cubeName = b.first;
113 if (names.find(cubeName) == names.end())
114 names.insert(cubeName);
115 else {
116 ALOG("cube name " << cubeName
117 << " occurs more than once, will retrieve the first cube with that name only");
118 }
119 }
120 }
121 return names;
122}
123
124QuantLib::ext::shared_ptr<NPVCube> OREApp::getCube(std::string cubeName) {
125 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
126 for (const auto& c : analyticsManager_->npvCubes()) {
127 for (auto b : c.second) {
128 if (cubeName == b.first)
129 return b.second;
130 }
131 }
132 QL_FAIL("npv cube " << cubeName << " not found in results");
133}
134
135std::set<std::string> OREApp::getMarketCubeNames() {
136 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
137 std::set<std::string> names;
138 for (const auto& c : analyticsManager_->mktCubes()) {
139 for (auto b : c.second) {
140 string cubeName = b.first;
141 if (names.find(cubeName) == names.end())
142 names.insert(cubeName);
143 else {
144 ALOG("market cube name " << cubeName
145 << " occurs more than once, will retrieve the first cube with that name only");
146 }
147 }
148 }
149 return names;
150}
151
152QuantLib::ext::shared_ptr<AggregationScenarioData> OREApp::getMarketCube(std::string cubeName) {
153 QL_REQUIRE(analyticsManager_, "analyticsManager_ not set yet, call analytics first");
154 for (const auto& c : analyticsManager_->mktCubes()) {
155 for (auto b : c.second) {
156 if (cubeName == b.first)
157 return b.second;
158 }
159 }
160 QL_FAIL("market cube " << cubeName << " not found in results");
161}
162
163std::vector<std::string> OREApp::getErrors() {
164 return errorMessages_;
165}
166
168 boost::chrono::duration<double> seconds = boost::chrono::nanoseconds(runTimer_.elapsed().wall);
169 return seconds.count();
170}
171
172QuantLib::ext::shared_ptr<CSVLoader> OREApp::buildCsvLoader(const QuantLib::ext::shared_ptr<Parameters>& params) {
173 bool implyTodaysFixings = false;
174 vector<string> marketFiles = {};
175 vector<string> fixingFiles = {};
176 vector<string> dividendFiles = {};
177
178 filesystem::path inputPath = params_->get("setup", "inputPath");
179
180 std::string tmp = params_->get("setup", "implyTodaysFixings", false);
181 if (tmp != "")
182 implyTodaysFixings = ore::data::parseBool(tmp);
183
184 tmp = params->get("setup", "marketDataFile", false);
185 if (tmp != "")
186 marketFiles = getFileNames(tmp, inputPath);
187 else {
188 ALOG("market data file not found");
189 }
190
191 tmp = params->get("setup", "fixingDataFile", false);
192 if (tmp != "")
193 fixingFiles = getFileNames(tmp, inputPath);
194 else {
195 ALOG("fixing data file not found");
196 }
197
198 tmp = params->get("setup", "dividendDataFile", false);
199 if (tmp != "")
200 dividendFiles = getFileNames(tmp, inputPath);
201 else {
202 WLOG("dividend data file not found");
203 }
204
205 tmp = params->get("setup", "fixingCutoff", false);
206 Date cutoff = Date();
207 if (tmp != "")
208 cutoff = parseDate(tmp);
209 else {
210 WLOG("fixing cutoff date not set");
211 }
212
213 auto loader = boost::make_shared<CSVLoader>(marketFiles, fixingFiles, dividendFiles, implyTodaysFixings, cutoff);
214
215 return loader;
216}
217
219
220 try {
221 LOG("ORE analytics starting");
223
224 QL_REQUIRE(params_, "ORE input parameters not set");
225
226 Settings::instance().evaluationDate() = inputs_->asof();
227
228 GlobalPseudoCurrencyMarketParameters::instance().set(inputs_->pricingEngine()->globalParameters());
229
230 // Initialize the global conventions
231 InstrumentConventions::instance().setConventions(inputs_->conventions());
232
233 // Create a market data loader that reads market data, fixings, dividends from csv files
234 auto csvLoader = buildCsvLoader(params_);
235 auto loader = QuantLib::ext::make_shared<MarketDataCsvLoader>(inputs_, csvLoader);
236
237 // Create the analytics manager
238 analyticsManager_ = QuantLib::ext::make_shared<AnalyticsManager>(inputs_, loader);
239 LOG("Available analytics: " << to_string(analyticsManager_->validAnalytics()));
240 CONSOLEW("Requested analytics");
241 CONSOLE(to_string(inputs_->analytics()));
242 LOG("Requested analytics: " << to_string(inputs_->analytics()));
243
244 QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
245 if (inputs_->outputTodaysMarketCalibration()) {
246 auto marketCalibrationReport = QuantLib::ext::make_shared<ore::data::InMemoryReport>();
247 mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(string(), marketCalibrationReport);
248 }
249
250 // Run the requested analytics
251 analyticsManager_->runAnalytics(mcr);
252
253 // Write reports to files in the results path
255 analyticsManager_->toFile(reports,
256 inputs_->resultsPath().string(), outputs_->fileNameMap(),
257 inputs_->csvSeparator(), inputs_->csvCommentCharacter(),
258 inputs_->csvQuoteChar(), inputs_->reportNaString());
259
260 // Write npv cube(s)
261 for (auto a : analyticsManager_->npvCubes()) {
262 for (auto b : a.second) {
263 LOG("write npv cube " << b.first);
264 string reportName = b.first;
265 std::string fileName = inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "csv.gz");
266 LOG("write npv cube " << reportName << " to file " << fileName);
268 r.cube = b.second;
269 if (b.first == "cube") {
270 // store meta data together with npv cube
271 r.scenarioGeneratorData = inputs_->scenarioGeneratorData();
272 r.storeFlows = inputs_->storeFlows();
273 r.storeCreditStateNPVs = inputs_->storeCreditStateNPVs();
274 }
275 saveCube(fileName, r);
276 }
277 }
278
279 // Write market cube(s)
280 for (auto a : analyticsManager_->mktCubes()) {
281 for (auto b : a.second) {
282 string reportName = b.first;
283 std::string fileName = inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "csv.gz");
284 LOG("write market cube " << reportName << " to file " << fileName);
285 saveAggregationScenarioData(fileName, *b.second);
286 }
287 }
288
289 for (auto a: analyticsManager_->stressTests()){
290 for(auto b: a.second){
291 string reportName = b.first;
292 std::string fileName =
293 inputs_->resultsPath().string() + "/" + outputs_->outputFileName(reportName, "xml");
294 LOG("write converted stress test scenario definition " << reportName << " to file " << fileName);
295 b.second->toFile(fileName);
296 }
297 }
298
299 }
300 catch (std::exception& e) {
301 ostringstream oss;
302 oss << "Error in ORE analytics: " << e.what();
303 ALOG(oss.str());
305 CONSOLE(oss.str());
306 QL_FAIL(oss.str());
307 }
308
310 LOG("ORE analytics done");
311}
312
313
315 if (console_) {
316 ConsoleLog::instance().switchOn();
317 }
318
319 outputPath_ = params_->get("setup", "outputPath");
320 logFile_ = outputPath_ + "/" + params_->get("setup", "logFile");
321 logMask_ = 15;
322 // Get log mask if available
323 if (params_->has("setup", "logMask")) {
324 logMask_ = static_cast<Size>(parseInteger(params_->get("setup", "logMask")));
325 }
326
328 progressLogToConsole_ = false;
330
331 if (params_->hasGroup("logging")) {
332 string tmp = params_->get("logging", "logFile", false);
333 if (!tmp.empty()) {
334 logFile_ = outputPath_ + '/' + tmp;
335 }
336 tmp = params_->get("logging", "logMask", false);
337 if (!tmp.empty()) {
338 logMask_ = static_cast<Size>(parseInteger(tmp));
339 }
340 tmp = params_->get("logging", "progressLogFile", false);
341 if (!tmp.empty()) {
342 progressLogFile_ = outputPath_ + '/' + tmp;
343 }
344 tmp = params_->get("logging", "progressLogRotationSize", false);
345 if (!tmp.empty()) {
346 progressLogRotationSize_ = static_cast<Size>(parseInteger(tmp));
347 }
348 tmp = params_->get("logging", "progressLogToConsole", false);
349 if (!tmp.empty()) {
351 }
352 tmp = params_->get("logging", "structuredLogFile", false);
353 if (!tmp.empty()) {
354 structuredLogFile_ = outputPath_ + '/' + tmp;
355 }
356 tmp = params_->get("logging", "structuredLogRotationSize", false);
357 if (!tmp.empty()) {
358 structuredLogRotationSize_ = static_cast<Size>(parseInteger(tmp));
359 }
360 }
361
364
365 // Log the input parameters
366 params_->log();
367
368 // Read all inputs from params and files referenced in params
369 CONSOLEW("Loading inputs");
370 inputs_ = QuantLib::ext::make_shared<OREAppInputParameters>(params_);
371 inputs_->loadParameters();
372 outputs_ = QuantLib::ext::make_shared<OutputParameters>(params_);
373 CONSOLE("OK");
374
375 Settings::instance().evaluationDate() = inputs_->asof();
376 LOG("initFromParameters done, requested analytics:" << to_string(inputs_->analytics()));
377}
378
380 // Initialise Singletons
381 Settings::instance().evaluationDate() = inputs_->asof();
382 InstrumentConventions::instance().setConventions(inputs_->conventions());
383 if (console_) {
384 ConsoleLog::instance().switchOn();
385 }
386
387 outputPath_ = inputs_->resultsPath().string();
390 LOG("initFromInputs done, requested analytics:" << to_string(inputs_->analytics()));
391}
392
394 // Close logs
395 closeLog();
396}
397
399
400 // Only one thread at a time should call run
401 static std::mutex _s_mutex;
402 std::lock_guard<std::mutex> lock(_s_mutex);
403
404 // Clean start, but leave Singletons intact after run is completed
405 {
406 CleanUpThreadLocalSingletons cleanupThreadLocalSingletons;
407 CleanUpThreadGlobalSingletons cleanupThreadGloablSingletons;
408 CleanUpLogSingleton cleanupLogSingleton(true, true);
409 }
410
411 // Use inputs when available, otherwise try params
412 if (inputs_ != nullptr)
414 else if (params_ != nullptr)
416 else {
417 ALOG("both inputs are empty");
418 return;
419 }
420
421 runTimer_.start();
422
423 try {
424 structuredLogger_->clear();
425 analytics();
426 } catch (std::exception& e) {
427 StructuredAnalyticsWarningMessage("OREApp::run()", "Error", e.what()).log();
428 CONSOLE("Error: " << e.what());
429 return;
430 }
431
432 runTimer_.stop();
433
434 // cache the error messages because we reset the loggers
435 errorMessages_ = structuredLogger_->messages();
436
437 CONSOLE("run time: " << runTimer_.format(default_places, "%w") << " sec");
438 CONSOLE("ORE done.");
439 LOG("ORE done.");
440}
441
442void OREApp::run(const std::vector<std::string>& marketData,
443 const std::vector<std::string>& fixingData) {
444
445 // Only one thread at a time should call run
446 static std::mutex _s_mutex;
447 std::lock_guard<std::mutex> lock(_s_mutex);
448
449 // Clean start, but leave Singletons intact after run is completed
450 {
451 CleanUpThreadLocalSingletons cleanupThreadLocalSingletons;
452 CleanUpThreadGlobalSingletons cleanupThreadGloablSingletons;
453 CleanUpLogSingleton cleanupLogSingleton(true, true);
454 }
455
456 // Use inputs when available, otherwise try params
457 if (inputs_ != nullptr)
459 else if (params_ != nullptr)
461 else {
462 ALOG("both inputs are empty");
463 return;
464 }
465
466 runTimer_.start();
467
468 try {
469 LOG("ORE analytics starting");
470 structuredLogger_->clear();
472
473 QL_REQUIRE(inputs_, "ORE input parameters not set");
474
475 // Set global evaluation date, though already set in the OREAppInputParameters c'tor
476 Settings::instance().evaluationDate() = inputs_->asof();
477
478 // FIXME
479 QL_REQUIRE(inputs_->pricingEngine(), "pricingEngine not set");
480 GlobalPseudoCurrencyMarketParameters::instance().set(inputs_->pricingEngine()->globalParameters());
481
482 // Initialize the global conventions
483 QL_REQUIRE(inputs_->conventions(), "conventions not set");
484 InstrumentConventions::instance().setConventions(inputs_->conventions());
485
486 // Create a market data loader that takes input from the provided vectors
487 auto loader = QuantLib::ext::make_shared<MarketDataInMemoryLoader>(inputs_, marketData, fixingData);
488
489 // Create the analytics manager
490 analyticsManager_ = QuantLib::ext::make_shared<AnalyticsManager>(inputs_, loader);
491 LOG("Available analytics: " << to_string(analyticsManager_->validAnalytics()));
492 CONSOLEW("Requested analytics:");
493 CONSOLE(to_string(inputs_->analytics()));
494 LOG("Requested analytics: " << to_string(inputs_->analytics()));
495
496 QuantLib::ext::shared_ptr<MarketCalibrationReportBase> mcr;
497 if (inputs_->outputTodaysMarketCalibration()) {
498 auto marketCalibrationReport = QuantLib::ext::make_shared<ore::data::InMemoryReport>();
499 mcr = QuantLib::ext::make_shared<MarketCalibrationReport>(string(), marketCalibrationReport);
500 }
501
502 // Run the requested analytics
503 analyticsManager_->runAnalytics(mcr);
504
506 // Leave any report writing to the calling aplication
507 }
508 catch (std::exception& e) {
509 ostringstream oss;
510 oss << "Error in ORE analytics: " << e.what();
511 StructuredAnalyticsWarningMessage("OREApp::run()", oss.str(), e.what()).log();
513 CONSOLE(oss.str());
514 QL_FAIL(oss.str());
515 return;
516 }
517
518 runTimer_.stop();
519
520 LOG("ORE analytics done");
521}
522
523void OREApp::setupLog(const std::string& path, const std::string& file, Size mask,
524 const boost::filesystem::path& logRootPath, const std::string& progressLogFile,
525 Size progressLogRotationSize, bool progressLogToConsole, const std::string& structuredLogFile,
526 Size structuredLogRotationSize) {
527 closeLog();
528
529 boost::filesystem::path p{path};
530 if (!boost::filesystem::exists(p)) {
531 boost::filesystem::create_directories(p);
532 }
533 QL_REQUIRE(boost::filesystem::is_directory(p), "output path '" << path << "' is not a directory.");
534
535 Log::instance().registerLogger(QuantLib::ext::make_shared<FileLogger>(file));
536 boost::filesystem::path oreRootPath =
537 logRootPath.empty() ? boost::filesystem::path(__FILE__).parent_path().parent_path().parent_path().parent_path()
538 : logRootPath;
539 Log::instance().setRootPath(oreRootPath);
540 Log::instance().setMask(mask);
541 Log::instance().switchOn();
542
543 // Progress logger
544 auto progressLogger = QuantLib::ext::make_shared<ProgressLogger>();
545 string progressLogFilePath = progressLogFile.empty() ? path + "/log_progress.json" : progressLogFile;
546 progressLogger->setFileLog(progressLogFilePath, path, progressLogRotationSize);
547 progressLogger->setCoutLog(progressLogToConsole);
548 Log::instance().registerIndependentLogger(progressLogger);
549
550 // Structured message logger
551 structuredLogger_ = QuantLib::ext::make_shared<StructuredLogger>();
552 string structuredLogFilePath = structuredLogFile.empty() ? path + "/log_structured.json" : structuredLogFile;
553 structuredLogger_->setFileLog(structuredLogFilePath, path, structuredLogRotationSize);
554 Log::instance().registerIndependentLogger(structuredLogger_);
555
556 // Event message logger
557 auto eventLogger = QuantLib::ext::make_shared<EventLogger>();
558 eventLogger->setFileLog(path + "/log_event_");
559 ore::data::Log::instance().registerIndependentLogger(eventLogger);
560}
561
562void OREApp::closeLog() { Log::instance().removeAllLoggers(); }
563
564std::string OREApp::version() { return std::string(OPEN_SOURCE_RISK_VERSION); }
565
567 LOG("load OREAppInputParameters called");
568
569 // switch default for backward compatibility
570 setEntireMarket(false);
571 setAllFixings(true);
575
576 QL_REQUIRE(params_->hasGroup("setup"), "parameter group 'setup' missing");
577
578 filesystem::path inputPath = params_->get("setup", "inputPath");
579 std::string outputPath = params_->get("setup", "outputPath");
580
581 // Load calendar adjustments
582 std::string tmp = params_->get("setup", "calendarAdjustment", false);
583 if (tmp != "") {
584 CalendarAdjustmentConfig calendarAdjustments;
585 filesystem::path calendarAdjustmentFile = inputPath / tmp;
586 LOG("Loading calendar adjustments from file: " << calendarAdjustmentFile);
587 calendarAdjustments.fromFile(calendarAdjustmentFile.generic_string());
588 } else {
589 WLOG("Calendar adjustments not found, using defaults");
590 }
591
592 // Load currency configs
593 tmp = params_->get("setup", "currencyConfiguration", false);
594 if (tmp != "") {
595 CurrencyConfig currencyConfig;
596 filesystem::path currencyConfigFile = inputPath / tmp;
597 LOG("Loading currency configurations from file: " << currencyConfigFile);
598 currencyConfig.fromFile(currencyConfigFile.generic_string());
599 } else {
600 WLOG("Currency configurations not found, using defaults");
601 }
602
603 setAsOfDate(params_->get("setup", "asofDate"));
604
605 // Set it immediately, otherwise the scenario generator grid below will be based on today's date
606 Settings::instance().evaluationDate() = asof();
607
608 setResultsPath(outputPath);
609
610 // first look for baseCurrency in setUp, and then in NPV node
611 tmp = params_->get("setup", "baseCurrency", false);
612 if (tmp != "")
613 setBaseCurrency(tmp);
614 else if (params_->hasGroup("npv"))
615 setBaseCurrency(params_->get("npv", "baseCurrency"));
616 else {
617 WLOG("Base currency not set");
618 }
619
620 tmp = params_->get("setup", "useMarketDataFixings", false);
621 if (tmp != "")
623
624 tmp = params_->get("setup", "dryRun", false);
625 if (tmp != "")
626 setDryRun(parseBool(tmp));
627
628 tmp = params_->get("setup", "reportNaString", false);
629 if (tmp != "")
631
632 tmp = params_->get("setup", "eomInflationFixings", false);
633 if (tmp != "")
635
636 tmp = params_->get("setup", "nThreads", false);
637 if (tmp != "")
639
640 tmp = params_->get("setup", "entireMarket", false);
641 if (tmp != "")
643
644 tmp = params_->get("setup", "iborFallbackOverride", false);
645 if (tmp != "")
647
648 tmp = params_->get("setup", "continueOnError", false);
649 if (tmp != "")
651
652 tmp = params_->get("setup", "lazyMarketBuilding", false);
653 if (tmp != "")
655
656 tmp = params_->get("setup", "buildFailedTrades", false);
657 if (tmp != "")
659
660 tmp = params_->get("setup", "observationModel", false);
661 if (tmp != "") {
663 ObservationMode::instance().setMode(observationModel());
664 LOG("Observation Mode is " << observationModel());
665 }
666
667 tmp = params_->get("setup", "implyTodaysFixings", false);
668 if (tmp != "")
670
671 tmp = params_->get("setup", "referenceDataFile", false);
672 if (tmp != "") {
673 filesystem::path refDataFile = inputPath / tmp;
674 LOG("Loading reference data from file: " << refDataFile);
675 setRefDataManagerFromFile(refDataFile.generic_string());
676 } else {
677 WLOG("Reference data not found");
678 }
679
680 tmp = params_->get("setup", "scriptLibrary", false);
681 if (tmp != "") {
682 filesystem::path scriptFile = inputPath / tmp;
683 LOG("Loading script library from file: " << scriptFile);
684 setScriptLibraryFromFile(scriptFile.generic_string());
685 }
686 else {
687 WLOG("Script library not loaded");
688 }
689
690 if (params_->has("setup", "conventionsFile") && params_->get("setup", "conventionsFile") != "") {
691 filesystem::path conventionsFile = inputPath / params_->get("setup", "conventionsFile");
692 LOG("Loading conventions from file: " << conventionsFile);
693 setConventionsFromFile(conventionsFile.generic_string());
694 } else {
695 ALOG("Conventions not found");
696 }
697
698 if (params_->has("setup", "iborFallbackConfig") && params_->get("setup", "iborFallbackConfig") != "") {
699 filesystem::path tmp = inputPath / params_->get("setup", "iborFallbackConfig");
700 LOG("Loading Ibor fallback config from file: " << tmp);
701 setIborFallbackConfigFromFile(tmp.generic_string());
702 } else {
703 WLOG("Using default Ibor fallback config");
704 }
705
706 if (params_->has("setup", "curveConfigFile") && params_->get("setup", "curveConfigFile") != "") {
707 filesystem::path curveConfigFile = inputPath / params_->get("setup", "curveConfigFile");
708 LOG("Load curve configurations from file: ");
709 setCurveConfigsFromFile(curveConfigFile.generic_string());
710 } else {
711 ALOG("no curve configs loaded");
712 }
713
714 tmp = params_->get("setup", "pricingEnginesFile", false);
715 if (tmp != "") {
716 filesystem::path pricingEnginesFile = inputPath / tmp;
717 LOG("Load pricing engine data from file: " << pricingEnginesFile);
718 setPricingEngineFromFile(pricingEnginesFile.generic_string());
719 } else {
720 ALOG("Pricing engine data not found");
721 }
722
723 tmp = params_->get("setup", "marketConfigFile", false);
724 if (tmp != "") {
725 filesystem::path marketConfigFile = inputPath / tmp;
726 LOG("Loading today's market parameters from file" << marketConfigFile);
727 setTodaysMarketParamsFromFile(marketConfigFile.generic_string());
728 } else {
729 ALOG("Today's market parameters not found");
730 }
731
732 if (params_->has("setup", "buildFailedTrades"))
733 setBuildFailedTrades(parseBool(params_->get("setup", "buildFailedTrades")));
734
735 tmp = params_->get("setup", "portfolioFile", false);
736 if (tmp != "") {
737 setPortfolioFromFile(tmp, inputPath);
738 } else {
739 WLOG("Portfolio data not provided");
740 }
741
742 if (params_->hasGroup("markets")) {
743 setMarketConfigs(params_->markets());
744 for (auto m : marketConfigs())
745 LOG("MarketContext::" << m.first << " = " << m.second);
746 }
747
748 if (params_->has("setup", "csvCommentReportHeader"))
749 setCsvCommentCharacter(parseBool(params_->get("setup", "csvCommentReportHeader")));
750
751 if (params_->has("setup", "csvSeparator")) {
752 tmp = params_->get("setup", "csvSeparator");
753 QL_REQUIRE(tmp.size() == 1, "csvSeparator must be exactly one character");
754 setCsvSeparator(tmp[0]);
755 }
756
757 /*************
758 * NPV
759 *************/
760
761 tmp = params_->get("npv", "active", false);
762 if (!tmp.empty() && parseBool(tmp))
763 insertAnalytic("NPV");
764
765 tmp = params_->get("npv", "additionalResults", false);
766 if (tmp != "")
768
769 tmp = params_->get("npv", "additionalResultsReportPrecision", false);
770 if (tmp != "")
772
773 /*************
774 * P&L
775 *************/
776
777 tmp = params_->get("pnl", "active", false);
778 if (!tmp.empty() && parseBool(tmp)) {
779 insertAnalytic("PNL");
780
781 tmp = params_->get("pnl", "mporDate", false);
782 if (tmp != "")
784
785 tmp = params_->get("pnl", "mporDays", false);
786 if (tmp != "")
788
789 tmp = params_->get("pnl", "mporCalendar", false);
790 if (tmp != "")
791 setMporCalendar(tmp);
792
793 tmp = params_->get("pnl", "simulationConfigFile", false);
794 if (tmp != "") {
795 string simulationConfigFile = (inputPath / tmp).generic_string();
796 LOG("Loading scenario simulation config from file" << simulationConfigFile);
797 // Should we check whether other analytics are setting this, too?
798 setScenarioSimMarketParamsFromFile(simulationConfigFile);
799 } else {
800 ALOG("Scenario Simulation market data not loaded");
801 }
802 }
803
804 /*************
805 * CASHFLOW
806 *************/
807
808 tmp = params_->get("cashflow", "active", false);
809 if (!tmp.empty() && parseBool(tmp))
810 insertAnalytic("CASHFLOW");
811
812 tmp = params_->get("cashflow", "includePastCashflows", false);
813 if (tmp != "")
815
816 /*************
817 * Curves
818 *************/
819
820 tmp = params_->get("curves", "active", false);
821 if (tmp != "") {
822 bool mkt = parseBool(tmp);
823 setOutputCurves(mkt);
824 }
825
826 tmp = params_->get("curves", "grid", false);
827 if (tmp != "")
828 setCurvesGrid(tmp);
829
830 tmp = params_->get("curves", "configuration", false);
831 if (tmp != "")
833
834 tmp = params_->get("curves", "outputTodaysMarketCalibration", false);
835 if (tmp != "")
837
838 /*************
839 * SENSITIVITY
840 *************/
841
842 // FIXME: The following are not loaded from params so far, relying on defaults
843 // xbsParConversion_ = false;
844 // analyticFxSensis_ = true;
845 // useSensiSpreadedTermStructures_ = true;
846
847 tmp = params_->get("sensitivity", "active", false);
848 if (!tmp.empty() && parseBool(tmp)) {
849 insertAnalytic("SENSITIVITY");
850
851 tmp = params_->get("sensitivity", "parSensitivity", false);
852 if (tmp != "")
854
855 tmp = params_->get("sensitivity", "optimiseRiskFactors", false);
856 if (tmp != "")
858
859 tmp = params_->get("sensitivity", "outputJacobi", false);
860 if (tmp != "")
862
863 tmp = params_->get("sensitivity", "alignPillars", false);
864 if (tmp != "")
866 else
868
869 tmp = params_->get("sensitivity", "marketConfigFile", false);
870 if (tmp != "") {
871 string file = (inputPath / tmp).generic_string();
872 LOG("Loading sensitivity scenario sim market parameters from file" << file);
874 } else {
875 WLOG("ScenarioSimMarket parameters for sensitivity not loaded");
876 }
877
878 tmp = params_->get("sensitivity", "sensitivityConfigFile", false);
879 if (tmp != "") {
880 string file = (inputPath / tmp).generic_string();
881 LOG("Load sensitivity scenario data from file" << file);
883 } else {
884 WLOG("Sensitivity scenario data not loaded");
885 }
886
887 tmp = params_->get("sensitivity", "pricingEnginesFile", false);
888 if (tmp != "") {
889 string file = (inputPath / tmp).generic_string();
890 LOG("Load pricing engine data from file: " << file);
892 } else {
893 WLOG("Pricing engine data not found for sensitivity analysis, using global");
894 // FIXME
896 }
897
898 tmp = params_->get("sensitivity", "outputSensitivityThreshold", false);
899 if (tmp != "")
901
902 tmp = params_->get("sensitivity", "recalibrateModels", false);
903 if (tmp != "")
905 }
906
907 /************
908 * SCENARIO
909 ************/
910
911 tmp = params_->get("scenario", "active", false);
912 if (!tmp.empty() && parseBool(tmp)) {
913 insertAnalytic("SCENARIO");
914
915 tmp = params_->get("scenario", "simulationConfigFile", false);
916 if (tmp != "") {
917 string simulationConfigFile = (inputPath / tmp).generic_string();
918 LOG("Loading scenario simulation config from file" << simulationConfigFile);
919 setScenarioSimMarketParamsFromFile(simulationConfigFile);
920 } else {
921 ALOG("Scenario Simulation market data not loaded");
922 }
923
924 tmp = params_->get("scenario", "scenarioOutputFile", false);
925 if (tmp != "")
927 }
928
929 /****************
930 * STRESS
931 ****************/
932
933 tmp = params_->get("stress", "active", false);
934 if (!tmp.empty() && parseBool(tmp)) {
935 insertAnalytic("STRESS");
937 tmp = params_->get("stress", "marketConfigFile", false);
938 if (tmp != "") {
939 string file = (inputPath / tmp).generic_string();
940 LOG("Loading stress test scenario sim market parameters from file" << file);
942 } else {
943 WLOG("ScenarioSimMarket parameters for stress testing not loaded");
944 }
945
946 tmp = params_->get("stress", "stressConfigFile", false);
947 if (tmp != "") {
948 string file = (inputPath / tmp).generic_string();
949 LOG("Load stress test scenario data from file" << file);
951 } else {
952 WLOG("Stress scenario data not loaded");
953 }
954
955 tmp = params_->get("stress", "pricingEnginesFile", false);
956 if (tmp != "") {
957 string file = (inputPath / tmp).generic_string();
958 LOG("Load pricing engine data from file: " << file);
960 } else {
961 WLOG("Pricing engine data not found for stress testing, using global");
962 }
963
964 tmp = params_->get("stress", "outputThreshold", false);
965 if (tmp != "")
967
968 tmp = params_->get("stress", "optimiseRiskFactors", false);
969 if (tmp != "")
971
972 tmp = params_->get("stress", "sensitivityConfigFile", false);
973 if (tmp != "") {
974 string file = (inputPath / tmp).generic_string();
975 LOG("Load sensitivity scenario data from file" << file);
977 } else {
978 WLOG("Sensitivity scenario data not loaded, don't support par stress tests");
979 }
980
981 tmp = params_->get("stress", "lowerBoundCapVols", false);
982 if (tmp != "") {
984 }
985 tmp = params_->get("stress", "upperBoundCapVols", false);
986 if (tmp != "") {
988 }
989 tmp = params_->get("stress", "lowerBoundDiscountFactors", false);
990 if (tmp != "") {
992 }
993 tmp = params_->get("stress", "upperBoundDiscountFactors", false);
994 if (tmp != "") {
996 }
997 tmp = params_->get("stress", "lowerBoundSurvivalProb", false);
998 if (tmp != "") {
1000 }
1001 tmp = params_->get("stress", "upperBoundSurvivalProb", false);
1002 if (tmp != "") {
1004 }
1005 tmp = params_->get("stress", "accuracy", false);
1006 if (tmp != "") {
1008 }
1009 }
1010
1011 /****************
1012 * PAR STRESS CONVERSION
1013 ****************/
1014
1015 tmp = params_->get("parStressConversion", "active", false);
1016 if (!tmp.empty() && parseBool(tmp)) {
1017 insertAnalytic("PARSTRESSCONVERSION");
1019 tmp = params_->get("parStressConversion", "marketConfigFile", false);
1020 if (tmp != "") {
1021 string file = (inputPath / tmp).generic_string();
1022 LOG("Loading parStressConversion test scenario sim market parameters from file" << file);
1024 } else {
1025 WLOG("ScenarioSimMarket parameters for par stress conversion testing not loaded");
1026 }
1027
1028 tmp = params_->get("parStressConversion", "stressConfigFile", false);
1029 if (tmp != "") {
1030 string file = (inputPath / tmp).generic_string();
1031 LOG("Load stress test scenario data from file" << file);
1033 } else {
1034 WLOG("Stress scenario data not loaded");
1035 }
1036
1037 tmp = params_->get("parStressConversion", "pricingEnginesFile", false);
1038 if (tmp != "") {
1039 string file = (inputPath / tmp).generic_string();
1040 LOG("Load pricing engine data from file: " << file);
1042 } else {
1043 WLOG("Pricing engine data not found for stress testing, using global");
1044 }
1045
1046 tmp = params_->get("parStressConversion", "sensitivityConfigFile", false);
1047 if (tmp != "") {
1048 string file = (inputPath / tmp).generic_string();
1049 LOG("Load sensitivity scenario data from file" << file);
1051 } else {
1052 WLOG("Sensitivity scenario data not loaded, don't support par stress tests");
1053 }
1054
1055 tmp = params_->get("parStressConversion", "lowerBoundCapVols", false);
1056 if (tmp != "") {
1058 }
1059 tmp = params_->get("parStressConversion", "upperBoundCapVols", false);
1060 if (tmp != "") {
1062 }
1063 tmp = params_->get("parStressConversion", "lowerBoundDiscountFactors", false);
1064 if (tmp != "") {
1066 }
1067 tmp = params_->get("parStressConversion", "upperBoundDiscountFactors", false);
1068 if (tmp != "") {
1070 }
1071 tmp = params_->get("parStressConversion", "lowerBoundSurvivalProb", false);
1072 if (tmp != "") {
1074 }
1075 tmp = params_->get("parStressConversion", "upperBoundSurvivalProb", false);
1076 if (tmp != "") {
1078 }
1079 tmp = params_->get("parStressConversion", "accuracy", false);
1080 if (tmp != "") {
1082 }
1083 }
1084
1085 /****************
1086 * ZERO TO PAR SHIFT CONVERSION
1087 ****************/
1088
1089 tmp = params_->get("zeroToParShift", "active", false);
1090 if (!tmp.empty() && parseBool(tmp)) {
1091 insertAnalytic("ZEROTOPARSHIFT");
1093 tmp = params_->get("zeroToParShift", "marketConfigFile", false);
1094 if (tmp != "") {
1095 string file = (inputPath / tmp).generic_string();
1096 LOG("Loading zero to par shift conversion scenario sim market parameters from file " << file);
1098 } else {
1099 WLOG("ScenarioSimMarket parameters for zero to par shift conversion not loaded");
1100 }
1101
1102 tmp = params_->get("zeroToParShift", "stressConfigFile", false);
1103 if (tmp != "") {
1104 string file = (inputPath / tmp).generic_string();
1105 LOG("Load zero to par shift conversion scenario data from file" << file);
1107 } else {
1108 WLOG("Zero to par shift conversion scenario data not loaded");
1109 }
1110
1111 tmp = params_->get("zeroToParShift", "pricingEnginesFile", false);
1112 if (tmp != "") {
1113 string file = (inputPath / tmp).generic_string();
1114 LOG("Load pricing engine data from file: " << file);
1116 } else {
1117 WLOG("Pricing engine data not found for Zero to par shift conversion, using global");
1118 }
1119
1120 tmp = params_->get("zeroToParShift", "sensitivityConfigFile", false);
1121 if (tmp != "") {
1122 string file = (inputPath / tmp).generic_string();
1123 LOG("Load sensitivity scenario data from file" << file);
1125 } else {
1126 WLOG("Sensitivity scenario data not loaded for zero to par shift conversion");
1127 }
1128 }
1129
1130 /********************
1131 * VaR - Parametric
1132 ********************/
1133
1134 tmp = params_->get("parametricVar", "active", false);
1135 if (!tmp.empty() && parseBool(tmp)) {
1136 insertAnalytic("PARAMETRIC_VAR");
1137
1138 tmp = params_->get("parametricVar", "salvageCovarianceMatrix", false);
1139 if (tmp != "")
1141
1142 tmp = params_->get("parametricVar", "quantiles", false);
1143 if (tmp != "")
1144 setVarQuantiles(tmp);
1145
1146 tmp = params_->get("parametricVar", "breakdown", false);
1147 if (tmp != "")
1149
1150 tmp = params_->get("parametricVar", "portfolioFilter", false);
1151 if (tmp != "")
1152 setPortfolioFilter(tmp);
1153
1154 tmp = params_->get("parametricVar", "method", false);
1155 if (tmp != "")
1156 setVarMethod(tmp);
1157
1158 tmp = params_->get("parametricVar", "mcSamples", false);
1159 if (tmp != "")
1161
1162 tmp = params_->get("parametricVar", "mcSeed", false);
1163 if (tmp != "")
1165
1166 tmp = params_->get("parametricVar", "covarianceInputFile", false);
1167 QL_REQUIRE(tmp != "", "covarianceInputFile not provided");
1168 std::string covFile = (inputPath / tmp).generic_string();
1169 LOG("Load Covariance Data from file " << covFile);
1171
1172 tmp = params_->get("parametricVar", "sensitivityInputFile", false);
1173 QL_REQUIRE(tmp != "", "sensitivityInputFile not provided");
1174 std::string sensiFile = (inputPath / tmp).generic_string();
1175 LOG("Get sensitivity data from file " << sensiFile);
1177
1178 tmp = params_->get("parametricVar", "outputHistoricalScenarios", false);
1179 if (tmp != "")
1181 }
1182
1183 /********************
1184 * VaR - Historical Simulation
1185 ********************/
1186
1187 tmp = params_->get("historicalSimulationVar", "active", false);
1188 if (!tmp.empty() && parseBool(tmp)) {
1189 insertAnalytic("HISTSIM_VAR");
1190
1191 tmp = params_->get("historicalSimulationVar", "historicalScenarioFile", false);
1192 QL_REQUIRE(tmp != "", "historicalScenarioFile not provided");
1193 std::string scenarioFile = (inputPath / tmp).generic_string();
1194 setHistoricalScenarioReader(scenarioFile);
1195
1196 tmp = params_->get("historicalSimulationVar", "simulationConfigFile", false);
1197 QL_REQUIRE(tmp != "", "simulationConfigFile not provided");
1198 string simulationConfigFile = (inputPath / tmp).generic_string();
1199 setHistVarSimMarketParamsFromFile(simulationConfigFile);
1200
1201 tmp = params_->get("historicalSimulationVar", "historicalPeriod", false);
1202 if (tmp != "")
1204
1205 tmp = params_->get("historicalSimulationVar", "mporDays", false);
1206 if (tmp != "")
1207 setMporDays(static_cast<Size>(parseInteger(tmp)));
1208
1209 tmp = params_->get("historicalSimulationVar", "mporCalendar", false);
1210 if (tmp != "")
1211 setMporCalendar(tmp);
1212
1213 tmp = params_->get("historicalSimulationVar", "mporOverlappingPeriods", false);
1214 if (tmp != "")
1216
1217 tmp = params_->get("historicalSimulationVar", "quantiles", false);
1218 if (tmp != "")
1219 setVarQuantiles(tmp);
1220
1221 tmp = params_->get("historicalSimulationVar", "breakdown", false);
1222 if (tmp != "")
1224
1225 tmp = params_->get("historicalSimulationVar", "portfolioFilter", false);
1226 if (tmp != "")
1227 setPortfolioFilter(tmp);
1228
1229 tmp = params_->get("historicalSimulationVar", "outputHistoricalScenarios", false);
1230 if (tmp != "")
1232 }
1233
1234 /****************
1235 * PNL Explain
1236 ****************/
1237 tmp = params_->get("pnlExplain", "active", false);
1238 if (!tmp.empty() && parseBool(tmp)) {
1239 insertAnalytic("PNL_EXPLAIN");
1240
1241 tmp = params_->get("pnlExplain", "mporDate", false);
1242 if (tmp != "")
1243 setMporDate(parseDate(tmp));
1244
1245 tmp = params_->get("pnlExplain", "historicalScenarioFile", false);
1246 if (tmp != "") {
1247 std::string scenarioFile = (inputPath / tmp).generic_string();
1248 setHistoricalScenarioReader(scenarioFile);
1249 }
1250
1251 tmp = params_->get("pnlExplain", "simulationConfigFile", false);
1252 if (tmp != "") {
1253 string file = (inputPath / tmp).generic_string();
1254 LOG("Loading sensitivity scenario sim market parameters from file" << file);
1257 } else {
1258 WLOG("ScenarioSimMarket parameters for sensitivity not loaded");
1259 }
1260
1261 tmp = params_->get("pnlExplain", "sensitivityConfigFile", false);
1262 if (tmp != "") {
1263 string file = (inputPath / tmp).generic_string();
1264 LOG("Load sensitivity scenario data from file" << file);
1266 } else {
1267 WLOG("Sensitivity scenario data not loaded");
1268 }
1269 }
1270 /****************
1271 * SIMM and IM Schedule
1272 ****************/
1273
1274 LOG("SIMM");
1275 tmp = params_->get("simm", "active", false);
1276 bool doSimm = !tmp.empty() ? parseBool(tmp) : false;
1277 if (doSimm) {
1278 insertAnalytic("SIMM");
1279
1280 tmp = params_->get("simm", "version", false);
1281 if (tmp != "")
1282 setSimmVersion(tmp);
1283
1284 tmp = params_->get("simm", "mporDays", false);
1285 if (tmp != "")
1286 setMporDays(static_cast<Size>(parseInteger(tmp)));
1287
1288 tmp = params_->get("simm", "crif", false);
1289 if (tmp != "") {
1290 string file = (inputPath / tmp).generic_string();
1292 }
1293
1294 tmp = params_->get("simm", "simmCalibration", false);
1295 if (tmp != "") {
1296 string file = (inputPath / tmp).generic_string();
1297 if (boost::filesystem::exists(file))
1299 }
1300
1301 tmp = params_->get("simm", "calculationCurrency", false);
1302 if (tmp != "") {
1305 } else {
1306 QL_REQUIRE(baseCurrency() != "", "either base currency or calculation currency is required");
1307 }
1308
1309 tmp = params_->get("simm", "calculationCurrencyCall", false);
1310 if (tmp != "") {
1312 }
1313
1314 tmp = params_->get("simm", "calculationCurrencyPost", false);
1315 if (tmp != "") {
1317 }
1318
1319 tmp = params_->get("simm", "resultCurrency", false);
1320 if (tmp != "")
1322 else
1324
1325 tmp = params_->get("simm", "reportingCurrency", false);
1326 if (tmp != "")
1328
1329 tmp = params_->get("simm", "enforceIMRegulations", false);
1330 if (tmp != "")
1332
1333 tmp = params_->get("simm", "writeIntermediateReports", false);
1334 if (tmp != "")
1336 }
1337
1338 LOG("IM SCHEDULE");
1339 tmp = params_->get("imschedule", "active", false);
1340 if (!tmp.empty() && parseBool(tmp)) {
1341 insertAnalytic("IM_SCHEDULE");
1342
1343 tmp = params_->get("imschedule", "version", false);
1344 if (tmp != "") {
1345 string tmpSimm = params_->get("simm", "version", false);
1346 QL_REQUIRE(!doSimm || tmp == tmpSimm, "version for imschedule and simm should match");
1347 setSimmVersion(tmp);
1348 } else if (simmVersion() == "") {
1349 LOG("set SIMM version for IM Schedule to 2.6, required to load CRIF")
1350 setSimmVersion("2.6");
1351 }
1352
1353 tmp = params_->get("imschedule", "crif", false);
1354 if (tmp != "") {
1355 string tmpSimm = params_->get("simm", "crif", false);
1356 QL_REQUIRE(!doSimm || tmp == tmpSimm, "crif files for imschedule and simm should match");
1357 string file = (inputPath / tmp).generic_string();
1359 }
1360
1361 tmp = params_->get("imschedule", "calculationCurrency", false);
1362 if (tmp != "") {
1363 string tmpSimm = params_->get("simm", "calculationCurrency", false);
1364 QL_REQUIRE(!doSimm || tmp == tmpSimm, "calculation currency for for imschedule and simm should match");
1367 } else {
1368 QL_REQUIRE(baseCurrency() != "", "either base currency or calculation currency is required");
1369 }
1370
1371 tmp = params_->get("imschedule", "calculationCurrencyCall", false);
1372 if (tmp != "") {
1373 string tmpSimm = params_->get("simm", "calculationCurrencyCall", false);
1374 QL_REQUIRE(!doSimm || tmp == tmpSimm, "calculation currency for imschedule and simm should match");
1376 }
1377
1378 tmp = params_->get("imschedule", "calculationCurrencyPost", false);
1379 if (tmp != "") {
1380 string tmpSimm = params_->get("simm", "calculationCurrencyPost", false);
1381 QL_REQUIRE(!doSimm || tmp == tmpSimm, "calculation currency for imschedule and simm should match");
1383 }
1384
1385 tmp = params_->get("imschedule", "resultCurrency", false);
1386 if (tmp != "") {
1387 string tmpSimm = params_->get("simm", "resultCurrency", false);
1388 QL_REQUIRE(!doSimm || tmp == tmpSimm, "result currency for imschedule and simm should match");
1390 }
1391 else
1393
1394 tmp = params_->get("imschedule", "reportingCurrency", false);
1395 if (tmp != "") {
1396 string tmpSimm = params_->get("simm", "reportingCurrency", false);
1397 QL_REQUIRE(!doSimm || tmp == tmpSimm, "reporting currency for imschedule and simm should match");
1399 }
1400
1401 tmp = params_->get("imschedule", "enforceIMRegulations", false);
1402 if (tmp != "") {
1403 string tmpSimm = params_->get("simm", "enforceIMRegulations", false);
1404 QL_REQUIRE(!doSimm || tmp == tmpSimm, "enforceIMRegulations for imschedule and simm should match");
1406 }
1407 }
1408
1409 /************
1410 * Simulation
1411 ************/
1412
1413 tmp = params_->get("simulation", "active", false);
1414 if (!tmp.empty() && parseBool(tmp)) {
1415 insertAnalytic("EXPOSURE");
1416 }
1417
1418 // check this here because we need to know further below when checking for EXPOSURE or XVA analytic
1419 tmp = params_->get("xva", "active", false);
1420 if (!tmp.empty() && parseBool(tmp))
1421 insertAnalytic("XVA");
1422
1423 tmp = params_->get("xvaStress", "active", false);
1424 if (!tmp.empty() && parseBool(tmp))
1425 insertAnalytic("XVA_STRESS");
1426
1427 tmp = params_->get("xvaSensitivity", "active", false);
1428 if (!tmp.empty() && parseBool(tmp))
1429 insertAnalytic("XVA_SENSITIVITY");
1430
1431 tmp = params_->get("simulation", "salvageCorrelationMatrix", false);
1432 if (tmp != "")
1434
1435 tmp = params_->get("simulation", "amc", false);
1436 if (tmp != "")
1437 setAmc(parseBool(tmp));
1438
1439 tmp = params_->get("simulation", "amcCg", false);
1440 if (tmp != "")
1441 setAmcCg(parseBool(tmp));
1442
1443 tmp = params_->get("simulation", "xvaCgSensitivityConfigFile", false);
1444 if (tmp != "") {
1445 string file = (inputPath / tmp).generic_string();
1446 LOG("Load xva cg sensitivity scenario data from file" << file);
1448 }
1449
1450 tmp = params_->get("simulation", "amcTradeTypes", false);
1451 if (tmp != "")
1452 setAmcTradeTypes(tmp);
1453
1457
1458 if (analytics().find("EXPOSURE") != analytics().end() || analytics().find("XVA") != analytics().end() ||
1459 analytics().find("XVA_STRESS") != analytics().end() ||
1460 analytics().find("XVA_SENSITIVITY") != analytics().end()) {
1461 tmp = params_->get("simulation", "simulationConfigFile", false);
1462 if (tmp != "") {
1463 string simulationConfigFile = (inputPath / tmp).generic_string();
1464 LOG("Loading simulation config from file" << simulationConfigFile);
1465 setExposureSimMarketParamsFromFile(simulationConfigFile);
1466 setCrossAssetModelDataFromFile(simulationConfigFile);
1467 setScenarioGeneratorDataFromFile(simulationConfigFile);
1468 auto grid = scenarioGeneratorData()->getGrid();
1469 DLOG("grid size=" << grid->size() << ", dates=" << grid->dates().size() << ", valuationDates="
1470 << grid->valuationDates().size() << ", closeOutDates=" << grid->closeOutDates().size());
1471 } else {
1472 ALOG("Simulation market, model and scenario generator data not loaded");
1473 }
1474
1475 tmp = params_->get("simulation", "pricingEnginesFile", false);
1476 if (tmp != "") {
1477 string pricingEnginesFile = (inputPath / tmp).generic_string();
1478 LOG("Load simulation pricing engine data from file: " << pricingEnginesFile);
1479 setSimulationPricingEngineFromFile(pricingEnginesFile);
1480 } else {
1481 WLOG("Simulation pricing engine data not found, using standard pricing engines");
1482 }
1483
1484 tmp = params_->get("simulation", "amcPricingEnginesFile", false);
1485 if (tmp != "") {
1486 string pricingEnginesFile = (inputPath / tmp).generic_string(); ;
1487 LOG("Load amc pricing engine data from file: " << pricingEnginesFile);
1488 setAmcPricingEngineFromFile(pricingEnginesFile);
1489 } else {
1490 WLOG("AMC pricing engine data not found, using standard pricing engines");
1492 }
1493
1495 tmp = params_->get("simulation", "baseCurrency", false);
1496 if (tmp != "")
1498
1499 tmp = params_->get("simulation", "observationModel", false);
1500 if (tmp != "")
1502 else
1504
1505 tmp = params_->get("simulation", "storeFlows", false);
1506 if (tmp == "Y")
1507 setStoreFlows(true);
1508
1509 tmp = params_->get("simulation", "storeCreditStateNPVs", false);
1510 if (!tmp.empty())
1512
1513 tmp = params_->get("simulation", "storeSurvivalProbabilities", false);
1514 if (tmp == "Y")
1516
1517 tmp = params_->get("simulation", "nettingSetId", false);
1518 if (tmp != "")
1519 setNettingSetId(tmp);
1520
1521 tmp = params_->get("simulation", "cubeFile", false);
1522 if (tmp != "")
1523 setWriteCube(true);
1524
1525 tmp = params_->get("simulation", "scenariodump", false);
1526 if (tmp != "")
1527 setWriteScenarios(true);
1528
1529 tmp = params_->get("simulation", "xvaCgBumpSensis", false);
1530 if (tmp != "")
1532
1533 }
1534
1535 /**********************
1536 * XVA specifically
1537 **********************/
1538
1539 tmp = params_->get("xva", "baseCurrency", false);
1540 if (tmp != "")
1541 setXvaBaseCurrency(tmp);
1542 else
1544
1545 if (analytics().find("XVA") != analytics().end() && analytics().find("EXPOSURE") == analytics().end()) {
1546 setLoadCube(true);
1547 tmp = params_->get("xva", "cubeFile", false);
1548 if (tmp != "") {
1549 string cubeFile = (resultsPath() / tmp).generic_string();
1550 LOG("Load cube from file " << cubeFile);
1551 setCubeFromFile(cubeFile);
1552 LOG("Cube loading done: ids=" << cube()->numIds() << " dates=" << cube()->numDates()
1553 << " samples=" << cube()->samples() << " depth=" << cube()->depth());
1554 } else {
1555 ALOG("cube file name not provided");
1556 }
1557 }
1558
1559 if (analytics().find("XVA") != analytics().end() || analytics().find("XVA_STRESS") != analytics().end() ||
1560 analytics().find("XVA_SENSITIVITY") != analytics().end()) {
1561 tmp = params_->get("xva", "csaFile", false);
1562 QL_REQUIRE(tmp != "", "Netting set manager is required for XVA");
1563 string csaFile = (inputPath / tmp).generic_string();
1564 LOG("Loading netting and csa data from file " << csaFile);
1566
1567 tmp = params_->get("xva", "collateralBalancesFile", false);
1568 if (tmp != "") {
1569 string collBalancesFile = (inputPath / tmp).generic_string();
1570 LOG("Loading collateral balances from file " << collBalancesFile);
1571 setCollateralBalancesFromFile(collBalancesFile);
1572 }
1573 }
1574
1575 tmp = params_->get("xva", "nettingSetCubeFile", false);
1576 if (loadCube() && tmp != "") {
1577 string cubeFile = (resultsPath() / tmp).generic_string();
1578 LOG("Load nettingset cube from file " << cubeFile);
1579 setNettingSetCubeFromFile(cubeFile);
1580 DLOG("NettingSetCube loading done: ids="
1581 << nettingSetCube()->numIds() << " dates=" << nettingSetCube()->numDates()
1582 << " samples=" << nettingSetCube()->samples() << " depth=" << nettingSetCube()->depth());
1583 }
1584
1585 tmp = params_->get("xva", "cptyCubeFile", false);
1586 if (loadCube() && tmp != "") {
1587 string cubeFile = resultsPath().string() + "/" + tmp;
1588 LOG("Load cpty cube from file " << cubeFile);
1589 setCptyCubeFromFile(cubeFile);
1590 DLOG("CptyCube loading done: ids=" << cptyCube()->numIds() << " dates=" << cptyCube()->numDates()
1591 << " samples=" << cptyCube()->samples() << " depth=" << cptyCube()->depth());
1592 }
1593
1594 tmp = params_->get("xva", "scenarioFile", false);
1595 if (loadCube() && tmp != "") {
1596 string cubeFile = resultsPath().string() + "/" + tmp;
1597 LOG("Load agg scen data from file " << cubeFile);
1598 setMarketCubeFromFile(cubeFile);
1599 LOG("MktCube loading done");
1600 }
1601
1602 tmp = params_->get("xva", "flipViewXVA", false);
1603 if (tmp != "")
1605
1606 tmp = params_->get("xva", "mporCashFlowMode", false);
1607 if (tmp != "")
1609
1610 tmp = params_->get("xva", "fullInitialCollateralisation", false);
1611 if (tmp != "")
1613
1614 tmp = params_->get("xva", "exposureProfilesByTrade", false);
1615 if (tmp != "")
1617
1618 tmp = params_->get("xva", "exposureProfiles", false);
1619 if (tmp != "")
1621
1622 tmp = params_->get("xva", "quantile", false);
1623 if (tmp != "")
1625
1626 tmp = params_->get("xva", "calculationType", false);
1627 if (tmp != "")
1629
1630 tmp = params_->get("xva", "allocationMethod", false);
1631 if (tmp != "")
1633
1634 tmp = params_->get("xva", "marginalAllocationLimit", false);
1635 if (tmp != "")
1637
1638 tmp = params_->get("xva", "exerciseNextBreak", false);
1639 if (tmp != "")
1641
1642 tmp = params_->get("xva", "cva", false);
1643 if (tmp != "")
1645
1646 tmp = params_->get("xva", "dva", false);
1647 if (tmp != "")
1649
1650 tmp = params_->get("xva", "fva", false);
1651 if (tmp != "")
1653
1654 tmp = params_->get("xva", "colva", false);
1655 if (tmp != "")
1657
1658 tmp = params_->get("xva", "collateralFloor", false);
1659 if (tmp != "")
1661
1662 tmp = params_->get("xva", "dim", false);
1663 if (tmp != "")
1665
1666 tmp = params_->get("xva", "dimModel", false);
1667 if (tmp != "") {
1668 QL_REQUIRE(tmp == "Regression" || tmp == "Flat",
1669 "DIM model " << tmp << " not supported, expected Regression or Flat");
1670 setDimModel(tmp);
1671 }
1672
1673 tmp = params_->get("xva", "mva", false);
1674 if (tmp != "")
1676
1677 tmp = params_->get("xva", "kva", false);
1678 if (tmp != "")
1680
1681 tmp = params_->get("xva", "dynamicCredit", false);
1682 if (tmp != "")
1684
1685 tmp = params_->get("xva", "cvaSensi", false);
1686 if (tmp != "")
1687 setCvaSensi(parseBool(tmp));
1688
1689 tmp = params_->get("xva", "cvaSensiGrid", false);
1690 if (tmp != "")
1691 setCvaSensiGrid(tmp);
1692
1693 tmp = params_->get("xva", "cvaSensiShiftSize", false);
1694 if (tmp != "")
1696
1697 tmp = params_->get("xva", "dvaName", false);
1698 if (tmp != "")
1699 setDvaName(tmp);
1700
1701 tmp = params_->get("xva", "rawCubeOutputFile", false);
1702 if (tmp != "") {
1704 setRawCubeOutput(true);
1705 }
1706
1707 tmp = params_->get("xva", "netCubeOutputFile", false);
1708 if (tmp != "") {
1710 setNetCubeOutput(true);
1711 }
1712
1713 // FVA
1714
1715 tmp = params_->get("xva", "fvaBorrowingCurve", false);
1716 if (tmp != "")
1718
1719 tmp = params_->get("xva", "fvaLendingCurve", false);
1720 if (tmp != "")
1721 setFvaLendingCurve(tmp);
1722
1723 tmp = params_->get("xva", "flipViewBorrowingCurvePostfix", false);
1724 if (tmp != "")
1726
1727 tmp = params_->get("xva", "flipViewLendingCurvePostfix", false);
1728 if (tmp != "")
1730
1731 // DIM
1732
1733 tmp = params_->get("xva", "deterministicInitialMarginFile", false);
1734 if (tmp != "") {
1735 string imFile = (inputPath / tmp).generic_string();
1736 LOG("Load initial margin evolution from file " << tmp);
1738 }
1739
1740 tmp = params_->get("xva", "dimQuantile", false);
1741 if (tmp != "")
1743
1744 tmp = params_->get("xva", "dimHorizonCalendarDays", false);
1745 if (tmp != "")
1747
1748 tmp = params_->get("xva", "dimRegressionOrder", false);
1749 if (tmp != "")
1751
1752 tmp = params_->get("xva", "dimRegressors", false);
1753 if (tmp != "")
1754 setDimRegressors(tmp);
1755
1756 tmp = params_->get("xva", "dimOutputGridPoints", false);
1757 if (tmp != "")
1759
1760 tmp = params_->get("xva", "dimOutputNettingSet", false);
1761 if (tmp != "")
1763
1764 tmp = params_->get("xva", "dimLocalRegressionEvaluations", false);
1765 if (tmp != "")
1767
1768 tmp = params_->get("xva", "dimLocalRegressionBandwidth", false);
1769 if (tmp != "")
1771
1772 // KVA
1773
1774 tmp = params_->get("xva", "kvaCapitalDiscountRate", false);
1775 if (tmp != "")
1777
1778 tmp = params_->get("xva", "kvaAlpha", false);
1779 if (tmp != "")
1780 setKvaAlpha(parseReal(tmp));
1781
1782 tmp = params_->get("xva", "kvaRegAdjustment", false);
1783 if (tmp != "")
1785
1786 tmp = params_->get("xva", "kvaCapitalHurdle", false);
1787 if (tmp != "")
1789
1790 tmp = params_->get("xva", "kvaOurPdFloor", false);
1791 if (tmp != "")
1793
1794 tmp = params_->get("xva", "kvaTheirPdFloor", false);
1795 if (tmp != "")
1797
1798 tmp = params_->get("xva", "kvaOurCvaRiskWeight", false);
1799 if (tmp != "")
1801
1802 tmp = params_->get("xva", "kvaTheirCvaRiskWeight", false);
1803 if (tmp != "")
1805
1806 // credit simulation
1807
1808 tmp = params_->get("xva", "creditMigration", false);
1809 if (tmp != "")
1811
1812 tmp = params_->get("xva", "creditMigrationDistributionGrid", false);
1813 if (tmp != "")
1814 setCreditMigrationDistributionGrid(parseListOfValues<Real>(tmp, &parseReal));
1815
1816 tmp = params_->get("xva", "creditMigrationTimeSteps", false);
1817 if (tmp != "")
1818 setCreditMigrationTimeSteps(parseListOfValues<Size>(tmp, &parseInteger));
1819
1820 tmp = params_->get("xva", "creditMigrationConfig", false);
1821 if (tmp != "") {
1822 string file = (inputPath / tmp).generic_string();
1823 LOG("Loading credit migration config from file" << file);
1825 }
1826
1827 tmp = params_->get("xva", "creditMigrationOutputFiles", false);
1828 if (tmp != "")
1830
1831 /*************
1832 * XVA Stress
1833 *************/
1834
1835 if (analytics().find("XVA_STRESS") != analytics().end()) {
1836 tmp = params_->get("xvaStress", "marketConfigFile", false);
1837 if (!tmp.empty()) {
1838 string file = (inputPath / tmp).generic_string();
1839 LOG("Loading xva stress test scenario sim market parameters from file" << file);
1841 } else {
1842 WLOG("ScenarioSimMarket parameters for xva stress testing not loaded");
1843 }
1844
1845 tmp = params_->get("xvaStress", "stressConfigFile", false);
1846 if (!tmp.empty()) {
1847 string file = (inputPath / tmp).generic_string();
1848 LOG("Load xav stress test scenario data from file" << file);
1850 } else {
1851 WLOG("Xva Stress scenario data not loaded");
1852 }
1853
1854 tmp = params_->get("xvaStress", "writeCubes", false);
1855 if (!tmp.empty()) {
1856 bool writeCubes = false;
1857 bool success = tryParse<bool>(tmp, writeCubes, parseBool);
1858 if (success) {
1859 setXvaStressWriteCubes(writeCubes);
1860 }
1861 }
1862
1863 tmp = params_->get("xvaStress", "sensitivityConfigFile", false);
1864 if (tmp != "") {
1865 string file = (inputPath / tmp).generic_string();
1866 LOG("Load sensitivity scenario data from file" << file);
1868 } else {
1869 WLOG("Sensitivity scenario data not loaded, don't support par stress tests");
1870 }
1871 }
1872
1873 /*************
1874 * XVA Sensi
1875 *************/
1876
1877 if (analytics().find("XVA_SENSITIVITY") != analytics().end()) {
1878 tmp = params_->get("xvaSensitivity", "marketConfigFile", false);
1879 if (!tmp.empty()) {
1880 string file = (inputPath / tmp).generic_string();
1881 LOG("Loading xva sensitivity scenario sim market parameters from file" << file);
1883 } else {
1884 WLOG("ScenarioSimMarket parameters for xva sensitivity not loaded");
1885 }
1886
1887 tmp = params_->get("xvaSensitivity", "sensitivityConfigFile", false);
1888 if (!tmp.empty()) {
1889 string file = (inputPath / tmp).generic_string();
1890 LOG("Load xva sensitivity scenario data from file" << file);
1892 } else {
1893 WLOG("Xva sensitivity scenario data not loaded");
1894 }
1895 }
1896
1897 /*************
1898 * cashflow npv and dynamic backtesting
1899 *************/
1900
1901 tmp = params_->get("cashflow", "cashFlowHorizon", false);
1902 if (tmp != "")
1903 setCashflowHorizon(tmp);
1904
1905 tmp = params_->get("cashflow", "portfolioFilterDate", false);
1906 if (tmp != "")
1908
1909 /*************
1910 * ZERO TO PAR SENSI CONVERSION
1911 *************/
1912
1913 tmp = params_->get("zeroToParSensiConversion", "active", false);
1914 if (!tmp.empty() && parseBool(tmp)) {
1915 insertAnalytic("PARCONVERSION");
1916
1917 tmp = params_->get("zeroToParSensiConversion", "sensitivityInputFile", false);
1918 if (tmp != "") {
1919 setParConversionInputFile((inputPath / tmp).generic_string());
1920 }
1921
1922 tmp = params_->get("zeroToParSensiConversion", "idColumn", false);
1923 if (tmp != "") {
1925 }
1926
1927 tmp = params_->get("zeroToParSensiConversion", "riskFactorColumn", false);
1928 if (tmp != "") {
1930 }
1931
1932 tmp = params_->get("zeroToParSensiConversion", "deltaColumn", false);
1933 if (tmp != "") {
1935 }
1936
1937 tmp = params_->get("zeroToParSensiConversion", "currencyColumn", false);
1938 if (tmp != "") {
1940 }
1941
1942 tmp = params_->get("zeroToParSensiConversion", "baseNpvColumn", false);
1943 if (tmp != "") {
1945 }
1946
1947 tmp = params_->get("zeroToParSensiConversion", "shiftSizeColumn", false);
1948 if (tmp != "") {
1950 }
1951
1952 tmp = params_->get("zeroToParSensiConversion", "marketConfigFile", false);
1953 if (tmp != "") {
1954 string file = (inputPath / tmp).generic_string();
1955 LOG("Loading par converions scenario sim market parameters from file" << file);
1957 } else {
1958 WLOG("ScenarioSimMarket parameters for par conversion testing not loaded");
1959 }
1960
1961 tmp = params_->get("zeroToParSensiConversion", "sensitivityConfigFile", false);
1962 if (tmp != "") {
1963 string file = (inputPath / tmp).generic_string();
1964 LOG("Load par conversion scenario data from file" << file);
1966 } else {
1967 WLOG("Par conversion scenario data not loaded");
1968 }
1969
1970 tmp = params_->get("zeroToParSensiConversion", "pricingEnginesFile", false);
1971 if (tmp != "") {
1972 string file = (inputPath / tmp).generic_string();
1973 LOG("Load pricing engine data from file: " << file);
1975 } else {
1976 WLOG("Pricing engine data not found for par conversion, using global");
1977 }
1978
1979 tmp = params_->get("zeroToParSensiConversion", "outputThreshold", false);
1980 if (tmp != "")
1982
1983 tmp = params_->get("zeroToParSensiConversion", "outputJacobi", false);
1984 if (tmp != "")
1986 }
1987
1988 /**********************
1989 * Scenario_Statistics
1990 **********************/
1991
1992 tmp = params_->get("scenarioStatistics", "active", false);
1993 if (!tmp.empty() && parseBool(tmp)) {
1994 insertAnalytic("SCENARIO_STATISTICS");
1995 tmp = params_->get("scenarioStatistics", "distributionBuckets", false);
1996 if (tmp != "")
1998
1999 tmp = params_->get("scenarioStatistics", "outputZeroRate", false);
2000 if (tmp != "")
2002
2003 tmp = params_->get("scenarioStatistics", "simulationConfigFile", false);
2004 if (tmp != "") {
2005 string simulationConfigFile = (inputPath / tmp).generic_string();
2006 LOG("Loading simulation config from file" << simulationConfigFile);
2007 setExposureSimMarketParamsFromFile(simulationConfigFile);
2008 setCrossAssetModelDataFromFile(simulationConfigFile);
2009 setScenarioGeneratorDataFromFile(simulationConfigFile);
2010 auto grid = scenarioGeneratorData()->getGrid();
2011 DLOG("grid size=" << grid->size() << ", dates=" << grid->dates().size() << ", valuationDates="
2012 << grid->valuationDates().size() << ", closeOutDates=" << grid->closeOutDates().size());
2013 } else {
2014 ALOG("Simulation market, model and scenario generator data not loaded");
2015 }
2016
2017 tmp = params_->get("scenarioStatistics", "scenariodump", false);
2018 if (tmp != "")
2019 setWriteScenarios(true);
2020 }
2021
2022 if (analytics().size() == 0) {
2023 insertAnalytic("MARKETDATA");
2025 if (lazyMarketBuilding())
2026 LOG("Lazy market build being overridden to \"false\" for MARKETDATA analytic.")
2027 setLazyMarketBuilding(false);
2028 }
2029
2030 LOG("analytics: " << analytics().size());
2031 for (auto a: analytics())
2032 LOG("analytic: " << a);
2033
2034 LOG("buildInputParameters done");
2035}
2036
2037} // namespace analytics
2038} // namespace ore
std::map< std::string, std::map< std::string, QuantLib::ext::shared_ptr< ore::data::InMemoryReport > > > analytic_reports
Definition: analytic.hpp:51
void setStressAccurary(const double value)
void setParStressScenarioDataFromFile(const std::string &fileName)
void setZeroToParShiftPricingEngineFromFile(const std::string &fileName)
void setNetCubeOutputFile(const std::string &s)
void setSimulationPricingEngineFromFile(const std::string &fileName)
void setSensiScenarioDataFromFile(const std::string &fileName)
void setParStressPricingEngine(const std::string &xml)
void setNettingSetManagerFromFile(const std::string &fileName)
void setStressPricingEngineFromFile(const std::string &fileName)
void setParConversionInputRiskFactorColumn(const std::string &s)
void setParConversionInputShiftSizeColumn(const std::string &s)
const QuantLib::ext::shared_ptr< NPVCube > & cptyCube() const
void setSimmCalculationCurrencyCall(const std::string &s)
void setSimmVersion(const std::string &s)
void setCubeFromFile(const std::string &file)
void setSensiSimMarketParamsFromFile(const std::string &fileName)
void setStressPricingEngine(const std::string &xml)
void setDimModel(const std::string &s)
void setParConversionInputDeltaColumn(const std::string &s)
void setParStressLowerBoundRatesDiscountFactor(const double value)
void setScenarioOutputFile(const std::string &filename)
void setCollateralBalancesFromFile(const std::string &fileName)
void setCreditSimulationParametersFromFile(const std::string &fileName)
void setXvaStressSensitivityScenarioDataFromFile(const std::string &fileName)
void setStoreCreditStateNPVs(Size states)
void setZeroToParShiftScenarioDataFromFile(const std::string &fileName)
void setReportNaString(const std::string &s)
void setStressUpperBoundSurvivalProb(const double value)
void setSensitivityStreamFromFile(const std::string &fileName)
void setStressSimMarketParamsFromFile(const std::string &fileName)
void setSimmReportingCurrency(const std::string &s)
void setCashflowHorizon(const std::string &s)
void setCurvesMarketConfig(const std::string &s)
void setSimmCalculationCurrencyPost(const std::string &s)
void setPricingEngineFromFile(const std::string &fileName)
void setBenchmarkVarPeriod(const std::string &period)
void setFvaBorrowingCurve(const std::string &s)
void setParStressUpperBoundSurvivalProb(const double value)
void setCovarianceDataFromFile(const std::string &fileName)
void setMarketConfigs(const std::map< std::string, std::string > &m)
void setRefDataManagerFromFile(const std::string &fileName)
void setParStressLowerBoundCapFloorVolatility(const double value)
void setCreditMigrationDistributionGrid(const std::vector< Real > &grid)
void setAmcPricingEngineFromFile(const std::string &fileName)
void setHistVarSimMarketParamsFromFile(const std::string &fileName)
void setParConversionSimMarketParamsFromFile(const std::string &fileName)
void setParConversionScenarioDataFromFile(const std::string &fileName)
void setMarketCubeFromFile(const std::string &file)
void setSimulationPricingEngine(const std::string &xml)
void setCsvCommentCharacter(const char &c)
void setParStressSensitivityScenarioDataFromFile(const std::string &fileName)
void setFvaLendingCurve(const std::string &s)
void setExposureAllocationMethod(const std::string &s)
void setSimmCalibrationDataFromFile(const std::string &fileName)
void setNettingSetCubeFromFile(const std::string &file)
void setPortfolioFilterDate(const std::string &s)
void setCreditMigrationOutputFiles(const std::string &s)
void setExposureSimMarketParamsFromFile(const std::string &fileName)
void setCreditMigrationTimeSteps(const std::vector< Size > &ts)
void setStressLowerBoundCapFloorVolatility(const double value)
void setZeroToParShiftPricingEngine(const std::string &xml)
void setBaseCurrency(const std::string &s)
void setExposureObservationModel(const std::string &s)
void setScenarioDistributionSteps(const Size s)
void setScenarioOutputZeroRate(const bool b)
void setParConversionInputIdColumn(const std::string &s)
void setPortfolioFilter(const std::string &s)
const QuantLib::ext::shared_ptr< ore::data::EngineData > & pricingEngine() const
void setXvaCgSensiScenarioDataFromFile(const std::string &fileName)
void setOutputHistoricalScenarios(const bool b)
void setAsOfDate(const std::string &s)
void setStressSensitivityScenarioDataFromFile(const std::string &fileName)
void setAmcPricingEngine(const std::string &xml)
void setParStressPricingEngineFromFile(const std::string &fileName)
void setScriptLibraryFromFile(const std::string &fileName)
const std::string & simmVersion() const
void setStressUpperBoundCapFloorVolatility(const double value)
void setZeroToParShiftSimMarketParamsFromFile(const std::string &fileName)
void setDimOutputNettingSet(const std::string &s)
const QuantLib::ext::shared_ptr< NPVCube > & nettingSetCube() const
void setStressLowerBoundSurvivalProb(const double value)
void setSimmResultCurrency(const std::string &s)
void setParStressSimMarketParamsFromFile(const std::string &fileName)
void setZeroToParShiftSensitivityScenarioDataFromFile(const std::string &fileName)
void setFlipViewBorrowingCurvePostfix(const std::string &s)
void insertAnalytic(const std::string &s)
void setXvaBaseCurrency(const std::string &s)
void setXvaStressWriteCubes(const bool writeCubes)
const std::map< std::string, std::string > & marketConfigs() const
void setExposureBaseCurrency(const std::string &s)
const std::string & observationModel() const
void setAmcTradeTypes(const std::string &s)
void setPortfolioFromFile(const std::string &fileNameString, const std::filesystem::path &inputPath)
void setCrifFromFile(const std::string &fileName, char eol='\n', char delim=',', char quoteChar='\0', char escapeChar='\\')
const QuantLib::Date & asof() const
const QuantLib::ext::shared_ptr< ScenarioGeneratorData > scenarioGeneratorData() const
void setParStressAccurary(const double value)
void setStressOptimiseRiskFactors(bool optimise)
void setFlipViewLendingCurvePostfix(const std::string &s)
void setParStressUpperBoundRatesDiscountFactor(const double value)
void setParConversionInputCurrencyColumn(const std::string &s)
void setVarMethod(const std::string &s)
void setNettingSetId(const std::string &s)
void setSensiPricingEngine(const std::string &xml)
void setXvaStressScenarioDataFromFile(const std::string &s)
void setCptyCubeFromFile(const std::string &file)
void setMporCalendar(const std::string &s)
void setMporCashFlowMode(const MporCashFlowMode m)
void setParConversionInputFile(const std::string &s)
void setCrossAssetModelDataFromFile(const std::string &fileName)
void setXvaStressSimMarketParamsFromFile(const std::string &f)
void setResultsPath(const std::string &s)
void setHistoricalScenarioReader(const std::string &fileName)
void setParConversionPricingEngineFromFile(const std::string &fileName)
void setMporDate(const QuantLib::Date &d)
const std::string & exposureBaseCurrency() const
void setCurveConfigsFromFile(const std::string &fileName)
void setCvaSensiGrid(const std::string &s)
void setScenarioSimMarketParamsFromFile(const std::string &fileName)
void setStressLowerBoundRatesDiscountFactor(const double value)
void setStressUpperBoundRatesDiscountFactor(const double value)
const boost::filesystem::path & resultsPath() const
void setAdditionalResultsReportPrecision(std::size_t p)
void setXvaSensiSimMarketParamsFromFile(const std::string &fileName)
void setTodaysMarketParamsFromFile(const std::string &fileName)
void setIborFallbackConfigFromFile(const std::string &fileName)
const std::string & simmCalculationCurrencyCall() const
void setDimRegressors(const std::string &s)
void setCurvesGrid(const std::string &s)
const QuantLib::ext::shared_ptr< NPVCube > & cube() const
void setParStressUpperBoundCapFloorVolatility(const double value)
void setObservationModel(const std::string &s)
void setDimOutputGridPoints(const std::string &s)
void setDeterministicInitialMarginFromFile(const std::string &fileName)
void setRawCubeOutputFile(const std::string &s)
void setConventionsFromFile(const std::string &fileName)
void setCollateralCalculationType(const std::string &s)
const std::set< std::string > & analytics() const
void setParStressLowerBoundSurvivalProb(const double value)
void setDvaName(const std::string &s)
void setVarQuantiles(const std::string &s)
void setStressScenarioDataFromFile(const std::string &fileName)
void setXvaSensiScenarioDataFromFile(const std::string &fileName)
void setScenarioGeneratorDataFromFile(const std::string &fileName)
const std::string & baseCurrency() const
void setSensiPricingEngineFromFile(const std::string &fileName)
void setParConversionInputBaseNpvColumn(const std::string &s)
QuantLib::ext::shared_ptr< AggregationScenarioData > getMarketCube(std::string cubeName)
Definition: oreapp.cpp:152
QuantLib::Size structuredLogRotationSize_
Definition: oreapp.hpp:122
void setupLog(const std::string &path, const std::string &file, QuantLib::Size mask, const boost::filesystem::path &logRootPath, const std::string &progressLogFile="", QuantLib::Size progressLogRotationSize=100 *1024 *1024, bool progressLogToConsole=false, const std::string &structuredLogFile="", QuantLib::Size structuredLogRotationSize=100 *1024 *1024)
set up logging
Definition: oreapp.cpp:523
boost::timer::cpu_timer runTimer_
Definition: oreapp.hpp:110
virtual void run()
Runs analytics and generates reports after using the first OREApp c'tor.
Definition: oreapp.cpp:398
std::vector< std::string > getErrors()
Definition: oreapp.cpp:163
virtual ~OREApp()
Destructor.
Definition: oreapp.cpp:393
Real getRunTime()
time for executing run(...) in seconds
Definition: oreapp.cpp:167
QuantLib::ext::shared_ptr< AnalyticsManager > analyticsManager_
Definition: oreapp.hpp:108
QuantLib::ext::shared_ptr< PlainInMemoryReport > getReport(std::string reportName)
Definition: oreapp.cpp:96
QuantLib::ext::shared_ptr< OutputParameters > outputs_
Definition: oreapp.hpp:106
std::set< std::string > getMarketCubeNames()
Definition: oreapp.cpp:135
std::vector< std::string > errorMessages_
Definition: oreapp.hpp:125
const QuantLib::ext::shared_ptr< Analytic > & getAnalytic(std::string type)
Definition: oreapp.cpp:74
QuantLib::Size progressLogRotationSize_
Definition: oreapp.hpp:119
QuantLib::ext::shared_ptr< CSVLoader > buildCsvLoader(const QuantLib::ext::shared_ptr< Parameters > &params)
Definition: oreapp.cpp:172
QuantLib::ext::shared_ptr< Parameters > params_
ORE Input parameters.
Definition: oreapp.hpp:104
virtual void analytics()
Definition: oreapp.cpp:218
boost::filesystem::path logRootPath_
Definition: oreapp.hpp:117
std::set< std::string > getSupportedAnalyticTypes()
Definition: oreapp.cpp:69
std::string version()
Definition: oreapp.cpp:564
void closeLog()
remove logs
Definition: oreapp.cpp:562
QuantLib::ext::shared_ptr< NPVCube > getCube(std::string cubeName)
Definition: oreapp.cpp:124
string logFile_
Logging.
Definition: oreapp.hpp:113
QuantLib::ext::shared_ptr< StructuredLogger > structuredLogger_
Definition: oreapp.hpp:109
std::set< std::string > getReportNames()
Definition: oreapp.cpp:79
std::set< std::string > getCubeNames()
Definition: oreapp.cpp:107
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: oreapp.hpp:105
std::set< std::string > getAnalyticTypes()
Definition: oreapp.cpp:64
QuantLib::ext::shared_ptr< Parameters > params_
Definition: oreapp.hpp:139
virtual void loadParameters() override
Definition: oreapp.cpp:566
void fromFile(const std::string &filename)
load / save cubes and agg scen data from / to disk
MporCashFlowMode parseMporCashFlowMode(const std::string &s)
Date parseDate(const string &s)
bool parseBool(const string &s)
Real parseReal(const string &s)
Integer parseInteger(const string &s)
#define LOG(text)
#define DLOG(text)
#define ALOG(text)
#define MEM_LOG_USING_LEVEL(LEVEL)
#define CONSOLEW(text)
#define WLOG(text)
#define CONSOLE(text)
#define ORE_WARNING
Market Data Loader.
Market Data Loader.
vector< string > getFileNames(const string &fileString, const std::filesystem::path &path)
void saveCube(const std::string &filename, const NPVCubeWithMetaData &cube, const bool doublePrecision)
Definition: cube_io.cpp:167
void saveAggregationScenarioData(const std::string &filename, const AggregationScenarioData &cube)
Definition: cube_io.cpp:302
Size size(const ValueType &v)
std::string to_string(const LocationInfo &l)
Singleton class to hold global Observation Mode.
Open Risk Engine App.
QuantLib::ext::shared_ptr< NPVCube > cube
Definition: cube_io.hpp:39
QuantLib::ext::shared_ptr< ScenarioGeneratorData > scenarioGeneratorData
Definition: cube_io.hpp:41
boost::optional< Size > storeCreditStateNPVs
Definition: cube_io.hpp:43
boost::optional< bool > storeFlows
Definition: cube_io.hpp:42
Structured analytics error.
Class for structured analytics warnings.
#define OPEN_SOURCE_RISK_VERSION