37vector<string>
getFileNames(
const string& fileString,
const std::filesystem::path& path) {
38 vector<string> fileNames;
39 boost::split(fileNames, fileString, boost::is_any_of(
",;"), boost::token_compress_on);
40 for (
auto it = fileNames.begin(); it < fileNames.end(); it++) {
42 *it = (path / *it).generic_string();
55 Settings::instance().evaluationDate() =
asof_;
61 "market config " << it->second <<
" already set for context " << it->first);
66 refDataManager_ = QuantLib::ext::make_shared<BasicReferenceDataManager>();
71 refDataManager_ = QuantLib::ext::make_shared<BasicReferenceDataManager>(fileName);
76 data.fromXMLString(xml);
77 ScriptLibraryStorage::instance().set(std::move(
data));
82 data.fromFile(fileName);
83 ScriptLibraryStorage::instance().set(std::move(
data));
87 conventions_ = QuantLib::ext::make_shared<Conventions>();
92 conventions_ = QuantLib::ext::make_shared<Conventions>();
97 auto curveConfig = QuantLib::ext::make_shared<CurveConfigurations>();
98 curveConfig->fromXMLString(xml);
103 auto curveConfig = QuantLib::ext::make_shared<CurveConfigurations>();
104 curveConfig->fromFile(fileName);
144 vector<string> files =
getFileNames(fileNameString, inputPath);
146 for (
auto file : files) {
147 LOG(
"Loading portfolio from file: " << file);
383 if(r.scenarioGeneratorData)
387 if(r.storeCreditStateNPVs)
414 std::vector<std::string> dummy;
415 while (reader.
next()) {
420 LOG(
"Read " <<
covarianceData_.size() <<
" valid covariance data lines from " << fileName);
424 std::vector<std::string> dummy;
425 while (reader.
next()) {
451 boost::filesystem::path baseScenarioPath(fileName);
452 QL_REQUIRE(exists(baseScenarioPath),
"The provided base scenario file, " << baseScenarioPath <<
", does not exist");
453 QL_REQUIRE(is_regular_file(baseScenarioPath),
454 "The provided base scenario file, " << baseScenarioPath <<
", is not a file");
456 fileName, QuantLib::ext::make_shared<SimpleScenarioFactory>(
false));
475 std::map<std::string, std::map<Date, Real>>
data;
476 while (reader.
next()) {
478 std::string nettingSet = reader.
get(
"NettingSet");
479 Real initialMargin =
parseReal(reader.
get(
"InitialMargin"));
482 if (
data.find(nettingSet) ==
data.end())
483 data[nettingSet] = std::map<Date,Real>();
484 std::map<Date,Real>& evolution =
data[nettingSet];
485 evolution[date] = initialMargin;
487 for (
auto d :
data) {
488 std::string n = d.first;
489 LOG(
"Loading IM evolution for netting set " << n <<
", size " << d.second.size());
492 for (
auto row : d.second) {
493 im.push_back(row.second);
494 date.push_back(row.first);
496 TimeSeries<Real> ts(date.begin(), date.end(), im.begin());
500 WLOG(
"External IM evolution for NettingSet " << n <<
" loaded");
535 bool updateMappings =
true;
536 bool aggregateTrades =
false;
538 aggregateTrades, eol, delim, quoteChar, escapeChar,
reportNaString());
539 crif_ = crifLoader.loadCrif();
543 bool updateMappings =
true;
544 bool aggregateTrades =
false;
547 aggregateTrades, eol, delim, quoteChar, escapeChar,
reportNaString());
548 crif_ = crifLoader.loadCrif();
565 QuantLib::ext::shared_ptr<SimmBucketMapperBase> sbm = QuantLib::ext::dynamic_pointer_cast<SimmBucketMapperBase>(
simmBucketMapper_);
566 sbm->fromXMLString(xml);
572 QuantLib::ext::shared_ptr<SimmBucketMapperBase> sbm = QuantLib::ext::dynamic_pointer_cast<SimmBucketMapperBase>(
simmBucketMapper_);
573 sbm->fromFile(fileName);
584 analytics_ = std::set<std::string>(v.begin(), v.end());
592 LOG(
"OutputFileNameMap called");
598 cubeFileName_ = params->get(
"simulation",
"cubeFile",
false);
599 mktCubeFileName_ = params->get(
"simulation",
"aggregationScenarioDataFileName",
false);
603 std::string tmp = params->get(
"xva",
"dimRegressionFiles",
false);
608 jacobiFileName_ = params->get(
"sensitivity",
"jacobiOutputFile",
false);
614 varFileName_ = params->get(
"parametricVar",
"outputFile",
false);
616 varFileName_ = params->get(
"historicalSimulationVar",
"outputFile",
false);
652 vector<Size> dimOutputGridPoints;
653 tmp = params->get(
"xva",
"dimOutputGridPoints",
false);
655 dimOutputGridPoints = parseListOfValues<Size>(tmp,
parseInteger);
657 "dim regression output grid points size (" << dimOutputGridPoints.size() <<
") "
662 tmp = params->get(
"xva",
"creditMigrationTimeSteps",
false);
665 for (
auto const& t : ts) {
667 params->get(
"xva",
"creditMigrationOutputFiles") +
"_" + std::to_string(t);
671 LOG(
"OutputFileNameMap complete");
677 return internalName +
"." + suffix;
794 QL_REQUIRE(
asof() != Date(),
"Asof date is required for mpor date");
795 QL_REQUIRE(!
mporCalendar().empty(),
"MporCalendar or BaseCurrency is required for mpor date");
796 QL_REQUIRE(
mporDays() != Null<Size>(),
"mporDays is required for mpor date");
809 "Internal error, load simm bucket mapper before retrieving simmconfiguration");
std::string cashflowOutputFileName_
std::string parStressTestConversionFile_
std::string zeroToParShiftFile_
std::string rawCubeFileName_
std::string sensitivityScenarioFileName_
std::string jacobiInverseFileName_
std::string stressZeroScenarioDataFileName_
std::string parSensitivityFileName_
std::string parConversionOutputFileName_
std::string jacobiFileName_
std::string scenarioDumpFileName_
std::string mktCubeFileName_
std::string cubeFileName_
std::string scenarioOutputName_
std::map< std::string, std::string > fileNameMap_
std::string outputFileName(const std::string &internalName, const std::string &suffix)
std::string parConversionJacobiInverseFileName_
std::string stressTestFileName_
std::string pnlOutputFileName_
std::string dimEvolutionFileName_
std::string netCubeFileName_
std::vector< std::string > dimRegressionFileNames_
std::string pnlExplainOutputFileName_
OutputParameters(const QuantLib::ext::shared_ptr< Parameters > ¶ms)
std::string sensitivityFileName_
std::string npvOutputFileName_
std::string curvesOutputFileName_
std::string xvaStressTestFileName_
std::string parConversionJacobiFileName_
std::string get(const std::string &field) const
void add(const QuantLib::ext::shared_ptr< CurveConfigurations > &config, std::string id=std::string())
static IborFallbackConfig defaultConfig()
Class for loading CRIF records.
load / save cubes and agg scen data from / to disk
Calendar parseCalendar(const string &s)
Date parseDate(const string &s)
Period parsePeriod(const string &s)
Real parseReal(const string &s)
Integer parseInteger(const string &s)
Class for reading historical scenarios from file.
A cube implementation that stores the cube in memory.
vector< string > getFileNames(const string &fileString, const std::filesystem::path &path)
QuantLib::ext::shared_ptr< AggregationScenarioData > loadAggregationScenarioData(const std::string &filename)
RiskFactorKey parseRiskFactorKey(const string &str)
QuantLib::ext::shared_ptr< SimmConfiguration > buildSimmConfiguration(const string &simmVersion, const QuantLib::ext::shared_ptr< SimmBucketMapper > &simmBucketMapper, const QuantLib::ext::shared_ptr< SimmCalibrationData > &simmCalibrationData, const Size &mporDays)
NPVCubeWithMetaData loadCube(const std::string &filename, const bool doublePrecision)
std::vector< string > parseListOfValues(string s, const char escape, const char delim, const char quote)
Singleton class to hold global Observation Mode.
Class for streaming SensitivityRecords from file.
Shift scenario generation.
Base SIMM class for mapping qualifiers to buckets.
factory classes for simple scenarios
static std::vector< std::set< std::string > > additionalHeaders