Skip to content

Commit 7dea14c

Browse files
author
Sjogren
committed
Merge remote-tracking branch 'origin/master' into feature/martin_docs1
2 parents 775f6e8 + 60d93a7 commit 7dea14c

62 files changed

Lines changed: 509 additions & 220 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

OREAnalytics/orea/app/analytics/crifanalytic.cpp

Lines changed: 16 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,10 @@ void CrifAnalyticImpl::setUpConfigurations() {
171171
QL_REQUIRE(analytic()->configurations().simMarketParams, "CrifAnalytic: simMarketParams not set");
172172
QL_REQUIRE(analytic()->configurations().sensiScenarioData, "CrifAnalytic: sensiScenarioData not set");
173173
QL_REQUIRE(analytic()->configurations().todaysMarketParams, "CrifAnalytic: todaysMarketParams not set");
174-
174+
175+
inputs_->loadParameter<bool>(applySimmExemptions_, "crif", "applySimmExemptions", false,
176+
std::function<bool(const string&)>(parseBool));
177+
175178
setGenerateAdditionalResults(true);
176179
}
177180

@@ -208,15 +211,19 @@ void CrifAnalyticImpl::runAnalytic(const QuantLib::ext::shared_ptr<ore::data::In
208211
analytic()->addReport(LABEL, "npv_no_simm_exemptions", npvWithoutReport);
209212

210213
std::set<std::string> removedTrades, modifiedTrades;
211-
analytic()->startTimer("applySimmExemptions()");
212-
try {
213-
std::tie(removedTrades, modifiedTrades) =
214-
applySimmExemptions(*analytic()->portfolio(), engineFactory(), crifAnalytic->simmExemptionOverrides(),
215-
inputs_->useAtParCouponsTrades());
216-
} catch (std::exception& e) {
217-
QL_FAIL(e.what());
214+
if (applySimmExemptions_) {
215+
analytic()->startTimer("applySimmExemptions()");
216+
try {
217+
std::tie(removedTrades, modifiedTrades) =
218+
applySimmExemptions(*analytic()->portfolio(), engineFactory(), crifAnalytic->simmExemptionOverrides(),
219+
inputs_->useAtParCouponsTrades());
220+
} catch (std::exception& e) {
221+
QL_FAIL(e.what());
222+
}
223+
analytic()->stopTimer("applySimmExemptions()");
224+
} else {
225+
WLOG("Skipping application of SIMM exemptions as applySimmExemptions is set to false");
218226
}
219-
analytic()->stopTimer("applySimmExemptions()");
220227

221228
// If we have an empty portfolio, then quit the CRIF analytic
222229
if (analytic()->portfolio()->size() == 0) {

OREAnalytics/orea/app/analytics/crifanalytic.hpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,9 @@ class CrifAnalyticImpl : public Analytic::Impl {
4545
void runAnalytic(const QuantLib::ext::shared_ptr<ore::data::InMemoryLoader>& loader,
4646
const std::set<std::string>& runTypes = {}) override;
4747
void setUpConfigurations() override;
48+
49+
private:
50+
bool applySimmExemptions_ = true;
4851
};
4952

5053

OREAnalytics/orea/app/dummymarketdataloader.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@
2323
#pragma once
2424

2525
#include <orea/app/marketdataloader.hpp>
26-
#include <ql/tuple.hpp>
26+
#include <tuple>
2727

2828
namespace ore {
2929
namespace analytics {

OREAnalytics/orea/engine/marketriskbacktest.cpp

Lines changed: 22 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -373,7 +373,8 @@ void MarketRiskBacktest::createReports(const ext::shared_ptr<MarketRiskReport::R
373373
if (pnl) {
374374
for (const auto& t : pnlColumns())
375375
pnl->addColumn(std::get<0>(t), std::get<1>(t), std::get<2>(t));
376-
pnl->addColumn("DiscountSpec", string());
376+
pnl->addColumn("DiscountSpecKey1", string());
377+
pnl->addColumn("DiscountSpecKey2", string());
377378
}
378379
}
379380

@@ -383,7 +384,8 @@ void MarketRiskBacktest::createReports(const ext::shared_ptr<MarketRiskReport::R
383384
pnlTrade->addColumn("TradeId", string());
384385
for (const auto& t : pnlColumns())
385386
pnlTrade->addColumn(std::get<0>(t), std::get<1>(t), std::get<2>(t));
386-
pnlTrade->addColumn("DiscountSpec", string());
387+
pnlTrade->addColumn("DiscountSpecKey1", string());
388+
pnlTrade->addColumn("DiscountSpecKey2", string());
387389
}
388390
}
389391
}
@@ -458,16 +460,29 @@ void MarketRiskBacktest::addPnlRow(const QuantLib::ext::shared_ptr<BacktestRepor
458460
.add(currency.empty() ? calculationCurrency_ : currency);
459461

460462
// Append DiscountSpec column (from TodaysMarketParameters) if available and applicable
461-
std::string discountSpecStr;
463+
std::string discountSpecStr1;
462464
if (todaysmarket_ && key_1.keytype == QuantExt::RiskFactorKey::KeyType::DiscountCurve) {
463465
const auto& discMap = todaysmarket_->mapping(ore::data::MarketObject::DiscountCurve, ore::data::Market::defaultConfiguration);
464466
auto it = discMap.find(key_1.name);
465467
if (it != discMap.end()){
466-
discountSpecStr = it->second;
467-
}
468+
discountSpecStr1 = it->second;
469+
}
470+
}
471+
if (!discountSpecStr1.empty())
472+
report.add(discountSpecStr1);
473+
else
474+
report.add(string());
475+
476+
std::string discountSpecStr2;
477+
if (todaysmarket_ && key_2.keytype == QuantExt::RiskFactorKey::KeyType::DiscountCurve) {
478+
const auto& discMap = todaysmarket_->mapping(ore::data::MarketObject::DiscountCurve, ore::data::Market::defaultConfiguration);
479+
auto it = discMap.find(key_2.name);
480+
if (it != discMap.end()){
481+
discountSpecStr2 = it->second;
482+
}
468483
}
469-
if (!discountSpecStr.empty())
470-
report.add(discountSpecStr);
484+
if (!discountSpecStr2.empty())
485+
report.add(discountSpecStr2);
471486
else
472487
report.add(string());
473488
}

OREAnalytics/orea/engine/parsensitivityinstrumentbuilder.cpp

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1798,11 +1798,9 @@ QuantLib::ext::shared_ptr<Instrument> ParSensitivityInstrumentBuilder::makeYoyIn
17981798
discountCurve = market->discountCurve(ccy, marketConfiguration);
17991799
}
18001800
}
1801-
QL_DEPRECATED_DISABLE_WARNING
18021801
QuantLib::ext::shared_ptr<YearOnYearInflationSwap> helper(new YearOnYearInflationSwap(
18031802
YearOnYearInflationSwap::Payer, 1.0, fixSchedule, 0.0, conv->dayCounter(), yoySchedule, index,
1804-
conv->observationLag(), 0.0, conv->dayCounter(), conv->infCalendar()));
1805-
QL_DEPRECATED_ENABLE_WARNING
1803+
conv->observationLag(), QuantLib::CPI::AsIndex, 0.0, conv->dayCounter(), conv->infCalendar()));
18061804
QuantLib::ext::shared_ptr<InflationCouponPricer> yoyCpnPricer =
18071805
QuantLib::ext::make_shared<YoYInflationCouponPricer>(discountCurve);
18081806
for (auto& c : helper->yoyLeg()) {
@@ -1879,12 +1877,11 @@ void ParSensitivityInstrumentBuilder::makeYoYCapFloor(ParSensitivityInstrumentBu
18791877
}
18801878

18811879
// build the leg data and instrument
1882-
QL_DEPRECATED_DISABLE_WARNING
1883-
Leg yoyLeg = yoyInflationLeg(yoySchedule, yoySchedule.calendar(), index, conv->observationLag())
1884-
.withNotionals(1.0)
1885-
.withPaymentDayCounter(conv->dayCounter())
1886-
.withRateCurve(discountCurve);
1887-
QL_DEPRECATED_ENABLE_WARNING
1880+
Leg yoyLeg =
1881+
yoyInflationLeg(yoySchedule, yoySchedule.calendar(), index, conv->observationLag(), QuantLib::CPI::AsIndex)
1882+
.withNotionals(1.0)
1883+
.withPaymentDayCounter(conv->dayCounter())
1884+
.withRateCurve(discountCurve);
18881885
if (market == nullptr)
18891886
return;
18901887

OREAnalytics/orea/engine/saccrcalculator.cpp

Lines changed: 17 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ void SaccrCalculator::aggregate() {
270270
DLOG("SA-CCR: Hedging set AddOn calculation");
271271
for (map<HedgingSetKey, Real>::iterator it = addOnHedgingSet_.begin(); it != addOnHedgingSet_.end(); it++) {
272272
// Add-ons
273-
const NettingSetDetails& nettingSetDetails = QuantLib::ext::get<0>(it->first);
274-
const AssetClass& assetClass = QuantLib::ext::get<1>(it->first);
275-
const string& hedgingSet = QuantLib::ext::get<2>(it->first);
273+
const NettingSetDetails& nettingSetDetails = std::get<0>(it->first);
274+
const AssetClass& assetClass = std::get<1>(it->first);
275+
const string& hedgingSet = std::get<2>(it->first);
276276
if (assetClass == AssetClass::IR) {
277277
// effectiveNotional_[it->first] =
278278
// sqrt(D1 * D1 + D2 * D2 + D3 * D3 + 1.4 * (D1 * D2 + D2 * D3) + 0.6 * D1 * D3);
@@ -290,12 +290,12 @@ void SaccrCalculator::aggregate() {
290290
Real addonType = 0;
291291
Real addonTypeSquared = 0;
292292
for (const auto& [hedgingSubsetKey, effectiveNotional] : subsetEffectiveNotional_) {
293-
HedgingSetKey hedgingSetKey(QuantLib::ext::get<0>(hedgingSubsetKey),
294-
QuantLib::ext::get<1>(hedgingSubsetKey),
295-
QuantLib::ext::get<2>(hedgingSubsetKey));
293+
HedgingSetKey hedgingSetKey(std::get<0>(hedgingSubsetKey),
294+
std::get<1>(hedgingSubsetKey),
295+
std::get<2>(hedgingSubsetKey));
296296
if (hedgingSetKey != it->first)
297297
continue;
298-
const string& hedgingSubset = QuantLib::ext::get<3>(hedgingSubsetKey);
298+
const string& hedgingSubset = std::get<3>(hedgingSubsetKey);
299299
vector<string> tokens;
300300
boost::split(tokens, hedgingSubset, boost::is_any_of("_"));
301301
QL_REQUIRE(tokens.size() == 1 || tokens.size() == 2,
@@ -319,10 +319,10 @@ void SaccrCalculator::aggregate() {
319319
Real addonType = 0;
320320
Real addonTypeSquared = 0;
321321
for (const auto& [hedgingSubsetKey, effectiveNotional] : subsetEffectiveNotional_) {
322-
string hedgingSubset = QuantLib::ext::get<3>(hedgingSubsetKey);
323-
HedgingSetKey hedgingSetKey(QuantLib::ext::get<0>(hedgingSubsetKey),
324-
QuantLib::ext::get<1>(hedgingSubsetKey),
325-
QuantLib::ext::get<2>(hedgingSubsetKey));
322+
string hedgingSubset = std::get<3>(hedgingSubsetKey);
323+
HedgingSetKey hedgingSetKey(std::get<0>(hedgingSubsetKey),
324+
std::get<1>(hedgingSubsetKey),
325+
std::get<2>(hedgingSubsetKey));
326326
if (hedgingSetKey != it->first)
327327
continue;
328328
bool isEquityIndex = isIndex_[hedgingSubset];
@@ -352,9 +352,9 @@ void SaccrCalculator::aggregate() {
352352
DLOG("SA-CCR: Asset Class AddOn calculation");
353353
for (map<AssetClassKey, Real>::iterator it = addOnAssetClass_.begin(); it != addOnAssetClass_.end(); it++) {
354354
for (map<HedgingSetKey, Real>::iterator ith = addOnHedgingSet_.begin(); ith != addOnHedgingSet_.end(); ith++) {
355-
NettingSetDetails nettingSetDetails = QuantLib::ext::get<0>(ith->first);
356-
AssetClass assetClass = QuantLib::ext::get<1>(ith->first);
357-
// string hedgingSet = QuantLib::ext::get<2>(it->first);
355+
NettingSetDetails nettingSetDetails = std::get<0>(ith->first);
356+
AssetClass assetClass = std::get<1>(ith->first);
357+
// string hedgingSet = std::get<2>(it->first);
358358
AssetClassKey key(nettingSetDetails, assetClass);
359359
if (it->first != key)
360360
continue;
@@ -421,12 +421,12 @@ void SaccrCalculator::aggregate() {
421421

422422
hedgingSets_.clear();
423423
for (map<HedgingSetKey, Real>::iterator it = addOnHedgingSet_.begin(); it != addOnHedgingSet_.end(); it++) {
424-
NettingSetDetails nettingSetDetails = QuantLib::ext::get<0>(it->first);
425-
AssetClass ac = QuantLib::ext::get<1>(it->first);
424+
NettingSetDetails nettingSetDetails = std::get<0>(it->first);
425+
AssetClass ac = std::get<1>(it->first);
426426
pair<NettingSetDetails, AssetClass> key(nettingSetDetails, ac);
427427
if (hedgingSets_.find(key) == hedgingSets_.end())
428428
hedgingSets_[key] = vector<string>();
429-
hedgingSets_[key].push_back(QuantLib::ext::get<2>(it->first));
429+
hedgingSets_[key].push_back(std::get<2>(it->first));
430430
}
431431

432432
if (reports_.size() > 0)

OREAnalytics/orea/engine/smrc.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
#include <utility> // pair
2727
#include <vector>
2828

29-
#include <ql/tuple.hpp>
29+
#include <tuple>
3030
#include <boost/tuple/tuple_comparison.hpp>
3131

3232
#include <ql/time/period.hpp>

OREAnalytics/orea/engine/standardapproachcvacalculator.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@
2222
#include <ored/utilities/log.hpp>
2323
#include <ql/errors.hpp>
2424
#include <ql/math/comparison.hpp>
25-
#include <ql/tuple.hpp>
25+
#include <tuple>
2626
#include <boost/math/distributions/normal.hpp>
2727
#include <ored/utilities/parsers.hpp>
2828
#include <ored/utilities/to_string.hpp>
@@ -244,9 +244,9 @@ QuantLib::Real StandardApproachCvaCalculator::getHedgeSensi(const CvaRiskFactorK
244244
return 0.0;
245245
} else {
246246
auto& indexRiskFactor = cvaNetSensitivities_.get<CvaRiskFactorTag>();
247-
if (indexRiskFactor.count(QuantLib::ext::make_tuple("", rt, b, mt, rf, CvaType::CvaHedge)) == 0)
247+
if (indexRiskFactor.count(std::make_tuple("", rt, b, mt, rf, CvaType::CvaHedge)) == 0)
248248
QL_FAIL("no hedge sensitivity found for " << rt << " " << b << " " << mt << " " << rf << " ");
249-
auto it = indexRiskFactor.find(QuantLib::ext::make_tuple("", rt, b, mt, rf, CvaType::CvaHedge));
249+
auto it = indexRiskFactor.find(std::make_tuple("", rt, b, mt, rf, CvaType::CvaHedge));
250250
return it->value;
251251
}
252252
}
@@ -272,7 +272,7 @@ void StandardApproachCvaCalculator::calculate() {
272272
for (auto mt : marginTypes) {
273273
set<std::string> buckets;
274274
set<std::string> riskFactors;
275-
auto p = indexRiskType.equal_range(QuantLib::ext::make_tuple(n, rt, mt));
275+
auto p = indexRiskType.equal_range(std::make_tuple(n, rt, mt));
276276
while (p.first != p.second) {
277277
buckets.insert(p.first->bucket);
278278
checkRiskFactor(rt, mt, p.first->riskFactor);
@@ -285,8 +285,8 @@ void StandardApproachCvaCalculator::calculate() {
285285
map<string, Real> ws;
286286
vector<Real> ws_hdg;
287287
for (auto rf : riskFactors) {
288-
if (indexRiskFactor.count(QuantLib::ext::make_tuple(n, rt, b, mt, rf, CvaType::CvaAggregate)) != 0) {
289-
auto it = indexRiskFactor.find(QuantLib::ext::make_tuple(n, rt, b, mt, rf, CvaType::CvaAggregate));
288+
if (indexRiskFactor.count(std::make_tuple(n, rt, b, mt, rf, CvaType::CvaAggregate)) != 0) {
289+
auto it = indexRiskFactor.find(std::make_tuple(n, rt, b, mt, rf, CvaType::CvaAggregate));
290290
Real sk_cva = it->value;
291291
Real sk_hdg = getHedgeSensi(rt, b, mt, rf, sk_cva);
292292
Real rw = getRiskWeight(rt, b, mt, rf);

OREAnalytics/orea/scenario/scenariosimmarket.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2636,7 +2636,7 @@ ScenarioSimMarket::ScenarioSimMarket(
26362636
}
26372637

26382638
for (Size i = 1; i < yoyCurveTimes.size(); i++) {
2639-
Real rate = yoyInflationTs->yoyRate(quoteDates[i - 1], yoyInflationTs->observationLag());
2639+
Real rate = yoyInflationTs->yoyRate(quoteDates[i - 1] - yoyInflationTs->observationLag());
26402640
auto q = QuantLib::ext::make_shared<SimpleQuote>(useSpreadedTermStructures_ ? 0.0 : rate);
26412641
if (i == 1) {
26422642
// add the zero rate at first tenor to the T0 time, to ensure flat interpolation of T1

0 commit comments

Comments
 (0)