Skip to content

Commit 87aa370

Browse files
mgronckijenkins
authored andcommitted
QPR-12376 bugfix scenario recast
1 parent 7670735 commit 87aa370

2 files changed

Lines changed: 8 additions & 44 deletions

File tree

Examples/Example_67/Input/simulation.xml

Lines changed: 0 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -200,42 +200,6 @@
200200
<!-- Alternative: LinearZero -->
201201
<Extrapolation>Y</Extrapolation>
202202
</Configuration>
203-
<Configuration curve='EUR'>
204-
<Tenors>3D, 11D, 18D, 25D, 33D, 66D, 94D, 125D, 157D, 186D, 217D, 248D, 278D, 308D, 339D, 370D, 459D, 551D, 643D, 735D, 1102D, 1466D, 1831D, 2196D, 2561D, 2926D, 3293D, 3657D, 4022D, 4387D, 5484D, 7311D, 9138D, 10962D</Tenors>
205-
<Interpolation>LogLinear</Interpolation>
206-
<!-- Alternative: LinearZero -->
207-
<Extrapolation>Y</Extrapolation>
208-
</Configuration>
209-
<Configuration curve='EUR-EONIA'>
210-
<Tenors>3D, 11D, 18D, 25D, 33D, 66D, 94D, 125D, 157D, 186D, 217D, 248D, 278D, 308D, 339D, 370D, 459D, 551D, 643D, 735D, 1102D, 1466D, 1831D, 2196D, 2561D, 2926D, 3293D, 3657D, 4022D, 4387D, 5484D, 7311D, 9138D, 10962D</Tenors>
211-
<Interpolation>LogLinear</Interpolation>
212-
<!-- Alternative: LinearZero -->
213-
<Extrapolation>Y</Extrapolation>
214-
</Configuration>
215-
<Configuration curve='EUR-EURIBOR-6M'>
216-
<Tenors>186D, 735D, 1102D, 1466D, 1831D, 2196D, 2561D, 3657D, 4387D, 5484D, 7311D, 9138D, 25574D, 18267D</Tenors>
217-
<Interpolation>LogLinear</Interpolation>
218-
<!-- Alternative: LinearZero -->
219-
<Extrapolation>Y</Extrapolation>
220-
</Configuration>
221-
<Configuration curve='EUR-EURIBOR-3M'>
222-
<Tenors>5D, 33D, 66D, 94D, 125D, 157D, 186D, 217D, 249D, 278D, 370D, 459D, 735D, 1102D, 1466D, 1831D, 2196D, 2561D, 2926D, 3293D, 3657D, 4387D, 5484D, 7311D, 9138D, 14614D, 18267D</Tenors>
223-
<Interpolation>LogLinear</Interpolation>
224-
<!-- Alternative: LinearZero -->
225-
<Extrapolation>Y</Extrapolation>
226-
</Configuration>
227-
<Configuration curve='USD'>
228-
<Tenors>90D, 182D, 276D, 367D, 735D, 1102D, 1466D, 1831D, 2561D, 3657D, 7311D, 10962D, 14614D, 18267D</Tenors>
229-
<Interpolation>LogLinear</Interpolation>
230-
<!-- Alternative: LinearZero -->
231-
<Extrapolation>Y</Extrapolation>
232-
</Configuration>
233-
<Configuration curve='USD-FedFunds'>
234-
<Tenors>90D, 182D, 276D, 367D, 735D, 1102D, 1466D, 1831D, 2561D, 3657D, 7311D, 10962D, 14614D, 18267D</Tenors>
235-
<Interpolation>LogLinear</Interpolation>
236-
<!-- Alternative: LinearZero -->
237-
<Extrapolation>Y</Extrapolation>
238-
</Configuration>
239203
</YieldCurves>
240204
<Indices>
241205
<Index>EUR-EURIBOR-6M</Index>

OREAnalytics/orea/scenario/scenarioutilities.cpp

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,16 @@ QuantLib::ext::shared_ptr<Scenario> recastScenario(
237237
for (auto const& k : scenario->keys()) {
238238
if(newCoordinates.count({k.keytype, k.name})==1){
239239
keys.insert(std::make_pair(k.keytype, k.name));
240+
TLOG("Insert keys " << k.keytype << " " << k.name)
240241
} else{
241-
DLOG("Recast skip " << k.keytype << " " << k.name);
242+
TLOG("Recast skip " << k.keytype << " " << k.name);
242243
}
243244
}
244245

245246

246247

247248
for (auto const& k : keys) {
249+
248250
auto c0 = oldCoordinates.find(k);
249251
auto c1 = newCoordinates.find(k);
250252
QL_REQUIRE(c0 != scenario->coordinates().end(), "recastScenario(): no coordinates for "
@@ -265,26 +267,24 @@ QuantLib::ext::shared_ptr<Scenario> recastScenario(
265267
result->add(key, scenario->get(key));
266268

267269
} else {
268-
269270
// interpolate new values from old values
270-
271271
Size newKeyIndex = 0;
272-
273272
std::vector<Size> indices(c0->second.size(), 0);
274273
int workingIndex;
275274
do {
276275
workingIndex = indices.size() - 1;
277-
indices[workingIndex]++;
278-
while (workingIndex >= 0 && indices[workingIndex] == c1->second[workingIndex].size()+1) {
276+
while (workingIndex >= 0 && indices[workingIndex] == c1->second[workingIndex].size()) {
279277
--workingIndex;
280278
if (workingIndex >= 0)
281279
indices[workingIndex] = 0;
282280
}
283281
if (workingIndex >= 0) {
284282
RiskFactorKey key(k.first, k.second, newKeyIndex++);
285-
result->add(key, interpolatedValue(c0->second, c1->second, indices, k, scenario));
283+
auto iValue = interpolatedValue(c0->second, c1->second, indices, k, scenario);
284+
TLOG("Add "<< key << " interpolated value = " << iValue);
285+
result->add(key, iValue);
286+
indices[workingIndex]++;
286287
}
287-
288288
} while (workingIndex >= 0);
289289
}
290290
}

0 commit comments

Comments
 (0)