Skip to content

Commit 92bb54c

Browse files
pcaspersjenkins
authored andcommitted
QPR-12014 handle empty scheme
1 parent 1991248 commit 92bb54c

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

OREAnalytics/orea/cube/sensitivitycube.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,7 @@ SensitivityCube::SensitivityCube(const boost::shared_ptr<NPVSensiCube>& cube,
7878
}
7979

8080
void SensitivityCube::initialise() {
81+
8182
QL_REQUIRE(scenarioDescriptions_[0].type() == ShiftScenarioDescription::Type::Base,
8283
"Expected the first scenario in the sensitivity cube to be of type 'Base'");
8384

@@ -213,7 +214,7 @@ Real SensitivityCube::delta(const Size tradeIdx, const RiskFactorKey& riskFactor
213214
auto s = shiftSchemes_.find(riskFactorKey);
214215
QL_REQUIRE(s != shiftSchemes_.end(),
215216
"SensitivityCube::delta(" << tradeIdx << ", " << riskFactorKey << "): no shift scheme stored.");
216-
if (s->second == "Forward") {
217+
if (s->second == "Forward" || s->second.empty()) {
217218
Size scenarioIdx = index(riskFactorKey, upFactors_).index;
218219
return cube_->get(tradeIdx, scenarioIdx) - cube_->getT0(tradeIdx, 0);
219220
} else if (s->second == "Backward") {
@@ -226,7 +227,7 @@ Real SensitivityCube::delta(const Size tradeIdx, const RiskFactorKey& riskFactor
226227
} else {
227228
QL_FAIL("SensitivityCube::delta(" << tradeIdx << ", " << riskFactorKey << "): unknown shift scheme '"
228229
<< s->second << "'");
229-
}
230+
}
230231
}
231232

232233
Real SensitivityCube::delta(const string& tradeId, const RiskFactorKey& riskFactorKey) const {

0 commit comments

Comments
 (0)