Skip to content

Commit f5785f7

Browse files
Merge branch 'revert-github-205' into 'master'
Revert "Allow absolute pathes in master input file" See merge request qs/ore-github!32
2 parents bfae5e1 + 4cb3964 commit f5785f7

4 files changed

Lines changed: 55 additions & 46 deletions

File tree

OREAnalytics/orea/app/inputparameters.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,12 +32,12 @@
3232
namespace ore {
3333
namespace analytics {
3434

35-
vector<string> getFileNames(const string& fileString, const std::filesystem::path& path) {
35+
vector<string> getFileNames(const string& fileString, const string& path) {
3636
vector<string> fileNames;
3737
boost::split(fileNames, fileString, boost::is_any_of(",;"), boost::token_compress_on);
3838
for (auto it = fileNames.begin(); it < fileNames.end(); it++) {
3939
boost::trim(*it);
40-
*it = (path / *it).generic_string();
40+
*it = path + "/" + *it;
4141
}
4242
return fileNames;
4343
}
@@ -138,7 +138,7 @@ void InputParameters::setPortfolio(const std::string& xml) {
138138
portfolio_->fromXMLString(xml);
139139
}
140140

141-
void InputParameters::setPortfolioFromFile(const std::string& fileNameString, const std::filesystem::path& inputPath) {
141+
void InputParameters::setPortfolioFromFile(const std::string& fileNameString, const std::string& inputPath) {
142142
vector<string> files = getFileNames(fileNameString, inputPath);
143143
portfolio_ = boost::make_shared<Portfolio>(buildFailedTrades_);
144144
for (auto file : files) {

OREAnalytics/orea/app/inputparameters.hpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252
#include <ored/portfolio/referencedata.hpp>
5353
#include <ored/utilities/csvfilereader.hpp>
5454
#include <boost/filesystem/path.hpp>
55-
#include <filesystem>
5655

5756
namespace ore {
5857
namespace analytics {
@@ -92,7 +91,7 @@ class InputParameters {
9291
void setTodaysMarketParams(const std::string& xml);
9392
void setTodaysMarketParamsFromFile(const std::string& fileName);
9493
void setPortfolio(const std::string& xml);
95-
void setPortfolioFromFile(const std::string& fileNameString, const std::filesystem::path& inputPath);
94+
void setPortfolioFromFile(const std::string& fileNameString, const std::string& inputPath);
9695
void setMarketConfigs(const std::map<std::string, std::string>& m);
9796
void setThreads(int i) { nThreads_ = i; }
9897
void setEntireMarket(bool b) { entireMarket_ = b; }
@@ -862,7 +861,6 @@ inline const std::string& InputParameters::marketConfig(const std::string& conte
862861
auto it = marketConfigs_.find(context);
863862
return (it != marketConfigs_.end() ? it->second : Market::defaultConfiguration);
864863
}
865-
std::vector<std::string> getFileNames(const std::string& fileString, const std::filesystem::path& path);
866864

867865
//! Traditional ORE input via ore.xml and various files, output into files
868866
class OutputParameters {

OREAnalytics/orea/app/oreapp.cpp

Lines changed: 50 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -165,13 +165,23 @@ Real OREApp::getRunTime() {
165165
return seconds.count();
166166
}
167167

168+
vector<string> OREApp::getFileNames(const string& fileString, const string& path) {
169+
vector<string> fileNames;
170+
boost::split(fileNames, fileString, boost::is_any_of(",;"), boost::token_compress_on);
171+
for (auto it = fileNames.begin(); it < fileNames.end(); it++) {
172+
boost::trim(*it);
173+
*it = path + "/" + *it;
174+
}
175+
return fileNames;
176+
}
177+
168178
boost::shared_ptr<CSVLoader> OREApp::buildCsvLoader(const boost::shared_ptr<Parameters>& params) {
169179
bool implyTodaysFixings = false;
170180
vector<string> marketFiles = {};
171181
vector<string> fixingFiles = {};
172182
vector<string> dividendFiles = {};
173183

174-
filesystem::path inputPath = params_->get("setup", "inputPath");
184+
std::string inputPath = params_->get("setup", "inputPath");
175185

176186
std::string tmp = params_->get("setup", "implyTodaysFixings", false);
177187
if (tmp != "")
@@ -468,16 +478,16 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
468478

469479
QL_REQUIRE(params_->hasGroup("setup"), "parameter group 'setup' missing");
470480

471-
filesystem::path inputPath = params_->get("setup", "inputPath");
481+
std::string inputPath = params_->get("setup", "inputPath");
472482
std::string outputPath = params_->get("setup", "outputPath");
473483

474484
// Load calendar adjustments
475485
std::string tmp = params_->get("setup", "calendarAdjustment", false);
476486
if (tmp != "") {
477487
CalendarAdjustmentConfig calendarAdjustments;
478-
filesystem::path calendarAdjustmentFile = inputPath / tmp;
488+
string calendarAdjustmentFile = inputPath + "/" + tmp;
479489
LOG("Loading calendar adjustments from file: " << calendarAdjustmentFile);
480-
calendarAdjustments.fromFile(calendarAdjustmentFile.generic_string());
490+
calendarAdjustments.fromFile(calendarAdjustmentFile);
481491
} else {
482492
WLOG("Calendar adjustments not found, using defaults");
483493
}
@@ -486,9 +496,9 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
486496
tmp = params_->get("setup", "currencyConfiguration", false);
487497
if (tmp != "") {
488498
CurrencyConfig currencyConfig;
489-
filesystem::path currencyConfigFile = inputPath / tmp;
499+
string currencyConfigFile = inputPath + "/" + tmp;
490500
LOG("Loading currency configurations from file: " << currencyConfigFile);
491-
currencyConfig.fromFile(currencyConfigFile.generic_string());
501+
currencyConfig.fromFile(currencyConfigFile);
492502
} else {
493503
WLOG("Currency configurations not found, using defaults");
494504
}
@@ -563,61 +573,61 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
563573

564574
tmp = params_->get("setup", "referenceDataFile", false);
565575
if (tmp != "") {
566-
filesystem::path refDataFile = inputPath / tmp;
576+
string refDataFile = inputPath + "/" + tmp;
567577
LOG("Loading reference data from file: " << refDataFile);
568-
inputs->setRefDataManagerFromFile(refDataFile.generic_string());
578+
inputs->setRefDataManagerFromFile(refDataFile);
569579
} else {
570580
WLOG("Reference data not found");
571581
}
572582

573583
tmp = params_->get("setup", "scriptLibrary", false);
574584
if (tmp != "") {
575-
filesystem::path scriptFile = inputPath / tmp;
585+
string scriptFile = inputPath + "/" + tmp;
576586
LOG("Loading script library from file: " << scriptFile);
577-
inputs->setScriptLibraryFromFile(scriptFile.generic_string());
587+
inputs->setScriptLibraryFromFile(scriptFile);
578588
}
579589
else {
580590
WLOG("Script library not loaded");
581591
}
582592

583593
if (params_->has("setup", "conventionsFile") && params_->get("setup", "conventionsFile") != "") {
584-
filesystem::path conventionsFile = inputPath / params_->get("setup", "conventionsFile");
594+
string conventionsFile = inputPath + "/" + params_->get("setup", "conventionsFile");
585595
LOG("Loading conventions from file: " << conventionsFile);
586-
inputs->setConventionsFromFile(conventionsFile.generic_string());
596+
inputs->setConventionsFromFile(conventionsFile);
587597
} else {
588598
ALOG("Conventions not found");
589599
}
590600

591601
if (params_->has("setup", "iborFallbackConfig") && params_->get("setup", "iborFallbackConfig") != "") {
592-
filesystem::path tmp = inputPath / params_->get("setup", "iborFallbackConfig");
602+
std::string tmp = inputPath + "/" + params_->get("setup", "iborFallbackConfig");
593603
LOG("Loading Ibor fallback config from file: " << tmp);
594-
inputs->setIborFallbackConfigFromFile(tmp.generic_string());
604+
inputs->setIborFallbackConfigFromFile(tmp);
595605
} else {
596606
WLOG("Using default Ibor fallback config");
597607
}
598608

599609
if (params_->has("setup", "curveConfigFile") && params_->get("setup", "curveConfigFile") != "") {
600-
filesystem::path curveConfigFile = inputPath / params_->get("setup", "curveConfigFile");
610+
string curveConfigFile = inputPath + "/" + params_->get("setup", "curveConfigFile");
601611
LOG("Load curve configurations from file: ");
602-
inputs->setCurveConfigsFromFile(curveConfigFile.generic_string());
612+
inputs->setCurveConfigsFromFile(curveConfigFile);
603613
} else {
604614
ALOG("no curve configs loaded");
605615
}
606616

607617
tmp = params_->get("setup", "pricingEnginesFile", false);
608618
if (tmp != "") {
609-
filesystem::path pricingEnginesFile = inputPath / tmp;
619+
string pricingEnginesFile = inputPath + "/" + tmp;
610620
LOG("Load pricing engine data from file: " << pricingEnginesFile);
611-
inputs->setPricingEngineFromFile(pricingEnginesFile.generic_string());
621+
inputs->setPricingEngineFromFile(pricingEnginesFile);
612622
} else {
613623
ALOG("Pricing engine data not found");
614624
}
615625

616626
tmp = params_->get("setup", "marketConfigFile", false);
617627
if (tmp != "") {
618-
filesystem::path marketConfigFile = inputPath / tmp;
628+
string marketConfigFile = inputPath + "/" + tmp;
619629
LOG("Loading today's market parameters from file" << marketConfigFile);
620-
inputs->setTodaysMarketParamsFromFile(marketConfigFile.generic_string());
630+
inputs->setTodaysMarketParamsFromFile(marketConfigFile);
621631
} else {
622632
ALOG("Today's market parameters not found");
623633
}
@@ -726,7 +736,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
726736

727737
tmp = params_->get("sensitivity", "marketConfigFile", false);
728738
if (tmp != "") {
729-
string file = (inputPath / tmp).generic_string();
739+
string file = inputPath + "/" + tmp;
730740
LOG("Loading sensitivity scenario sim market parameters from file" << file);
731741
inputs->setSensiSimMarketParamsFromFile(file);
732742
} else {
@@ -735,7 +745,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
735745

736746
tmp = params_->get("sensitivity", "sensitivityConfigFile", false);
737747
if (tmp != "") {
738-
string file = (inputPath / tmp).generic_string();
748+
string file = inputPath + "/" + tmp;
739749
LOG("Load sensitivity scenario data from file" << file);
740750
inputs->setSensiScenarioDataFromFile(file);
741751
} else {
@@ -744,7 +754,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
744754

745755
tmp = params_->get("sensitivity", "pricingEnginesFile", false);
746756
if (tmp != "") {
747-
string file = (inputPath / tmp).generic_string();
757+
string file = inputPath + "/" + tmp;
748758
LOG("Load pricing engine data from file: " << file);
749759
inputs->setSensiPricingEngineFromFile(file);
750760
} else {
@@ -795,7 +805,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
795805
inputs->setStressPricingEngine(inputs->pricingEngine());
796806
tmp = params_->get("stress", "marketConfigFile", false);
797807
if (tmp != "") {
798-
string file = (inputPath / tmp).generic_string();
808+
string file = inputPath + "/" + tmp;
799809
LOG("Loading stress test scenario sim market parameters from file" << file);
800810
inputs->setStressSimMarketParamsFromFile(file);
801811
} else {
@@ -804,7 +814,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
804814

805815
tmp = params_->get("stress", "stressConfigFile", false);
806816
if (tmp != "") {
807-
string file = (inputPath / tmp).generic_string();
817+
string file = inputPath + "/" + tmp;
808818
LOG("Load stress test scenario data from file" << file);
809819
inputs->setStressScenarioDataFromFile(file);
810820
} else {
@@ -813,7 +823,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
813823

814824
tmp = params_->get("stress", "pricingEnginesFile", false);
815825
if (tmp != "") {
816-
string file = (inputPath / tmp).generic_string();
826+
string file = inputPath + "/" + tmp;
817827
LOG("Load pricing engine data from file: " << file);
818828
inputs->setStressPricingEngineFromFile(file);
819829
} else {
@@ -863,13 +873,13 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
863873

864874
tmp = params_->get("parametricVar", "covarianceInputFile", false);
865875
QL_REQUIRE(tmp != "", "covarianceInputFile not provided");
866-
std::string covFile = (inputPath / tmp).generic_string();
876+
std::string covFile = inputPath + "/" + tmp;
867877
LOG("Load Covariance Data from file " << covFile);
868878
inputs->setCovarianceDataFromFile(covFile);
869879

870880
tmp = params_->get("parametricVar", "sensitivityInputFile", false);
871881
QL_REQUIRE(tmp != "", "sensitivityInputFile not provided");
872-
std::string sensiFile = (inputPath / tmp).generic_string();
882+
std::string sensiFile = inputPath + "/" + tmp;
873883
LOG("Get sensitivity data from file " << sensiFile);
874884
inputs->setSensitivityStreamFromFile(sensiFile);
875885
}
@@ -892,7 +902,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
892902

893903
tmp = params_->get("simm", "crif", false);
894904
if (tmp != "") {
895-
string file = (inputPath / tmp).generic_string();
905+
string file = inputPath + "/" + tmp;
896906
inputs->setCrifFromFile(file, inputs->csvEolChar(), inputs->csvSeparator(), '\"', inputs->csvEscapeChar());
897907
}
898908

@@ -976,7 +986,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
976986
inputs->analytics().find("XVA") != inputs->analytics().end()) {
977987
tmp = params_->get("simulation", "simulationConfigFile", false) ;
978988
if (tmp != "") {
979-
string simulationConfigFile = (inputPath / tmp).generic_string();
989+
string simulationConfigFile = inputPath + "/" + tmp;
980990
LOG("Loading simulation config from file" << simulationConfigFile);
981991
inputs->setExposureSimMarketParamsFromFile(simulationConfigFile);
982992
inputs->setCrossAssetModelDataFromFile(simulationConfigFile);
@@ -991,7 +1001,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
9911001

9921002
tmp = params_->get("simulation", "pricingEnginesFile", false);
9931003
if (tmp != "") {
994-
string pricingEnginesFile = (inputPath / tmp).generic_string();
1004+
string pricingEnginesFile = inputPath + "/" + tmp;
9951005
LOG("Load simulation pricing engine data from file: " << pricingEnginesFile);
9961006
inputs->setSimulationPricingEngineFromFile(pricingEnginesFile);
9971007
} else {
@@ -1000,7 +1010,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
10001010

10011011
tmp = params_->get("simulation", "amcPricingEnginesFile", false);
10021012
if (tmp != "") {
1003-
string pricingEnginesFile = (inputPath / tmp).generic_string(); ;
1013+
string pricingEnginesFile = inputPath + "/" + tmp;
10041014
LOG("Load amc pricing engine data from file: " << pricingEnginesFile);
10051015
inputs->setAmcPricingEngineFromFile(pricingEnginesFile);
10061016
} else {
@@ -1074,7 +1084,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
10741084
if (inputs->analytics().find("XVA") != inputs->analytics().end()) {
10751085
tmp = params_->get("xva", "csaFile", false);
10761086
QL_REQUIRE(tmp != "", "Netting set manager is required for XVA");
1077-
string csaFile = (inputPath / tmp).generic_string();
1087+
string csaFile = inputPath + "/" + tmp;
10781088
LOG("Loading netting and csa data from file" << csaFile);
10791089
inputs->setNettingSetManagerFromFile(csaFile);
10801090

@@ -1242,7 +1252,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
12421252

12431253
tmp = params_->get("xva", "deterministicInitialMarginFile", false);
12441254
if (tmp != "") {
1245-
string imFile = (inputPath / tmp).generic_string();
1255+
string imFile = inputPath + "/" + tmp;
12461256
LOG("Load initial margin evolution from file " << tmp);
12471257
inputs->setDeterministicInitialMarginFromFile(imFile);
12481258
}
@@ -1329,7 +1339,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
13291339

13301340
tmp = params_->get("xva", "creditMigrationConfig", false);
13311341
if (tmp != "") {
1332-
string file = (inputPath / tmp).generic_string();
1342+
string file = inputPath + "/" + tmp;
13331343
LOG("Loading credit migration config from file" << file);
13341344
inputs->setCreditSimulationParametersFromFile(file);
13351345
}
@@ -1358,7 +1368,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
13581368

13591369
tmp = params_->get("zeroToParSensiConversion", "sensitivityInputFile", false);
13601370
if (tmp != "") {
1361-
inputs->setParConversionInputFile((inputPath / tmp).generic_string());
1371+
inputs->setParConversionInputFile(inputPath + "/" + tmp);
13621372
}
13631373

13641374
tmp = params_->get("zeroToParSensiConversion", "idColumn", false);
@@ -1393,7 +1403,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
13931403

13941404
tmp = params_->get("zeroToParSensiConversion", "marketConfigFile", false);
13951405
if (tmp != "") {
1396-
string file = (inputPath / tmp).generic_string();
1406+
string file = inputPath + "/" + tmp;
13971407
LOG("Loading par converions scenario sim market parameters from file" << file);
13981408
inputs->setParConversionSimMarketParamsFromFile(file);
13991409
} else {
@@ -1402,7 +1412,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
14021412

14031413
tmp = params_->get("zeroToParSensiConversion", "sensitivityConfigFile", false);
14041414
if (tmp != "") {
1405-
string file = (inputPath / tmp).generic_string();
1415+
string file = inputPath + "/" + tmp;
14061416
LOG("Load par conversion scenario data from file" << file);
14071417
inputs->setParConversionScenarioDataFromFile(file);
14081418
} else {
@@ -1411,7 +1421,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
14111421

14121422
tmp = params_->get("zeroToParSensiConversion", "pricingEnginesFile", false);
14131423
if (tmp != "") {
1414-
string file = (inputPath / tmp).generic_string();
1424+
string file = inputPath + "/" + tmp;
14151425
LOG("Load pricing engine data from file: " << file);
14161426
inputs->setParConversionPricingEngineFromFile(file);
14171427
} else {
@@ -1445,7 +1455,7 @@ void OREApp::buildInputParameters(boost::shared_ptr<InputParameters> inputs,
14451455

14461456
tmp = params_->get("scenarioStatistics", "simulationConfigFile", false);
14471457
if (tmp != "") {
1448-
string simulationConfigFile = (inputPath / tmp).generic_string();
1458+
string simulationConfigFile = inputPath + "/" + tmp;
14491459
LOG("Loading simulation config from file" << simulationConfigFile);
14501460
inputs->setExposureSimMarketParamsFromFile(simulationConfigFile);
14511461
inputs->setCrossAssetModelDataFromFile(simulationConfigFile);

OREAnalytics/orea/app/oreapp.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,7 @@ class OREApp {
8484
//! Populate InputParameters object from classic ORE key-value pairs in Parameters
8585
void buildInputParameters(boost::shared_ptr<InputParameters> inputs,
8686
const boost::shared_ptr<Parameters>& params);
87+
vector<string> getFileNames(const string& fileString, const string& path);
8788
boost::shared_ptr<CSVLoader> buildCsvLoader(const boost::shared_ptr<Parameters>& params);
8889
//! set up logging
8990
void setupLog(const std::string& path, const std::string& file, QuantLib::Size mask,

0 commit comments

Comments
 (0)