Summary
InputParameters::setCreditMigrationAnalytic(bool) stores its argument under the wrong parameter key (OREAnalytics/orea/app/inputparameters.hpp:734 as of 3b62ba248):
// credit simulation
void setCreditMigrationAnalytic(bool b) { parameters_.set("xva", "kvaTheirCvaRiskWeight", b); }
XvaAnalytic reads the flag from ("xva", "creditMigration") (orea/app/analytics/xvaanalytic.cpp:267), so the setter never enables the credit migration analytic. Worse, it plants a bool under ("xva", "kvaTheirCvaRiskWeight"), and when the KVA parameters are loaded (xvaanalytic.cpp:264) loadParameter<Real> first fails the typed any_cast<Real> (caught) and then falls back to loadParameterString(), whose any_cast<string> of the stored bool is not caught. Any call to the setter, true or false, therefore makes the XVA analytic's parameter loading throw a bad_any_cast with no hint of the cause.
Reachability: the setter is part of the Python API (ORE-SWIG/OREAnalytics-SWIG/SWIG/orea_app.i:413). Examples/ORE-API/oreApi.py:277 would call it, but that block is currently commented out ("set credit simulation parameters once added to swig"), so no shipped example hits it; anyone driving InputParameters from Python does. Introduced with the feature/1.114.1_to_master merge (9199569c5), first released in v1.8.16.0. Noticed while working on #359, which is otherwise unrelated.
Reproduction
auto inputs = QuantLib::ext::make_shared<InputParameters>();
inputs->setCreditMigrationAnalytic(true);
bool creditMigration = false;
inputs->loadParameter<bool>(creditMigration, "xva", "creditMigration", false, parseBool); // returns false, flag stays false
QuantLib::Real riskWeight = 0.05;
inputs->loadParameter<QuantLib::Real>(riskWeight, "xva", "kvaTheirCvaRiskWeight", false, parseReal); // throws bad_any_cast
Fix
Write to the creditMigration key. One-line PR with the above as a unit test to follow.
Summary
InputParameters::setCreditMigrationAnalytic(bool)stores its argument under the wrong parameter key (OREAnalytics/orea/app/inputparameters.hpp:734as of3b62ba248):XvaAnalyticreads the flag from("xva", "creditMigration")(orea/app/analytics/xvaanalytic.cpp:267), so the setter never enables the credit migration analytic. Worse, it plants aboolunder("xva", "kvaTheirCvaRiskWeight"), and when the KVA parameters are loaded (xvaanalytic.cpp:264)loadParameter<Real>first fails the typedany_cast<Real>(caught) and then falls back toloadParameterString(), whoseany_cast<string>of the storedboolis not caught. Any call to the setter,trueorfalse, therefore makes the XVA analytic's parameter loading throw abad_any_castwith no hint of the cause.Reachability: the setter is part of the Python API (
ORE-SWIG/OREAnalytics-SWIG/SWIG/orea_app.i:413).Examples/ORE-API/oreApi.py:277would call it, but that block is currently commented out ("set credit simulation parameters once added to swig"), so no shipped example hits it; anyone drivingInputParametersfrom Python does. Introduced with thefeature/1.114.1_to_mastermerge (9199569c5), first released in v1.8.16.0. Noticed while working on #359, which is otherwise unrelated.Reproduction
Fix
Write to the
creditMigrationkey. One-line PR with the above as a unit test to follow.