Skip to content

Commit 72c198c

Browse files
pcaspersjenkins
authored andcommitted
Resolve QPR-12520 "Calibrationerror"
1 parent 335397c commit 72c198c

5 files changed

Lines changed: 52 additions & 5 deletions

File tree

OREAnalytics/orea/app/inputparameters.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,7 @@ class InputParameters {
555555
const QuantLib::ext::shared_ptr<ore::data::NettingSetManager>& nettingSetManager() const { return nettingSetManager_; }
556556
// const QuantLib::ext::shared_ptr<ore::data::CounterpartyManager>& counterpartyManager() const { return counterpartyManager_; }
557557
const QuantLib::ext::shared_ptr<ore::data::CollateralBalances>& collateralBalances() const { return collateralBalances_; }
558+
const Real& simulationBootstrapTolerance() const { return simulationBootstrapTolerance_; }
558559

559560
/*****************
560561
* Getters for xva
@@ -880,6 +881,7 @@ class InputParameters {
880881
// intermediate results of the exposure simulation, before aggregation
881882
QuantLib::ext::shared_ptr<NPVCube> cube_, nettingSetCube_, cptyCube_;
882883
QuantLib::ext::shared_ptr<AggregationScenarioData> mktCube_;
884+
Real simulationBootstrapTolerance_ = 0.0001;
883885

884886
/**************
885887
* XVA analytic

OREData/ored/CMakeLists.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -488,6 +488,7 @@ model/localvolmodelbuilder.hpp
488488
model/modeldata.hpp
489489
model/modelparameter.hpp
490490
model/structuredmodelerror.hpp
491+
model/structuredmodelwarning.hpp
491492
model/utilities.hpp
492493
portfolio/accumulator.hpp
493494
portfolio/ascot.hpp

OREData/ored/model/crossassetmodelbuilder.cpp

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@
2828
#include <ored/model/inflation/infjydata.hpp>
2929
#include <ored/model/irhwmodeldata.hpp>
3030
#include <ored/model/lgmbuilder.hpp>
31-
#include <ored/model/structuredmodelerror.hpp>
31+
#include <ored/model/structuredmodelwarning.hpp>
3232
#include <ored/model/utilities.hpp>
3333
#include <ored/utilities/correlationmatrix.hpp>
3434
#include <ored/utilities/log.hpp>
@@ -634,7 +634,7 @@ void CrossAssetModelBuilder::buildModel() const {
634634
std::to_string(fxOptionCalibrationErrors_[i]) +
635635
" exceeds tolerance " +
636636
std::to_string(config_->bootstrapTolerance());
637-
StructuredModelErrorMessage("Failed to calibrate FX BS Model", exceptionMessage, id_).log();
637+
StructuredModelWarningMessage("Failed to calibrate FX BS Model", exceptionMessage, id_).log();
638638
WLOGGERSTREAM("Calibration details:");
639639
WLOGGERSTREAM(
640640
getCalibrationDetails(fxOptionBaskets_[i], fxParametrizations[i], irParametrizations[0]));
@@ -708,7 +708,7 @@ void CrossAssetModelBuilder::buildModel() const {
708708
std::to_string(eqOptionCalibrationErrors_[i]) +
709709
" exceeds tolerance " +
710710
std::to_string(config_->bootstrapTolerance());
711-
StructuredModelErrorMessage("Failed to calibrate EQ BS Model", exceptionMessage, id_).log();
711+
StructuredModelWarningMessage("Failed to calibrate EQ BS Model", exceptionMessage, id_).log();
712712
WLOGGERSTREAM("Calibration details:");
713713
WLOGGERSTREAM(
714714
getCalibrationDetails(eqOptionBaskets_[i], eqParametrizations[i], irParametrizations[0]));
@@ -848,7 +848,7 @@ void CrossAssetModelBuilder::calibrateInflation(const InfDkData& data, Size mode
848848
string exceptionMessage = "INF (DK) " + std::to_string(modelIdx) + " calibration error " +
849849
std::to_string(inflationCalibrationErrors_[modelIdx]) + " exceeds tolerance " +
850850
std::to_string(config_->bootstrapTolerance());
851-
StructuredModelErrorMessage("Failed to calibrate INF DK Model", exceptionMessage, id_).log();
851+
StructuredModelWarningMessage("Failed to calibrate INF DK Model", exceptionMessage, id_).log();
852852
WLOGGERSTREAM("Calibration details:");
853853
WLOGGERSTREAM(getCalibrationDetails(cb, inflationParam, false));
854854
WLOGGERSTREAM("rmse = " << inflationCalibrationErrors_[modelIdx]);
@@ -1021,7 +1021,7 @@ void CrossAssetModelBuilder::calibrateInflation(const InfJyData& data, Size mode
10211021
ss << "INF (JY) " << modelIdx << " calibration error " << std::scientific
10221022
<< inflationCalibrationErrors_[modelIdx] << " exceeds tolerance " << config_->bootstrapTolerance();
10231023
string exceptionMessage = ss.str();
1024-
StructuredModelErrorMessage("Failed to calibrate INF JY Model", exceptionMessage, id_).log();
1024+
StructuredModelWarningMessage("Failed to calibrate INF JY Model", exceptionMessage, id_).log();
10251025
WLOGGERSTREAM("Calibration details:");
10261026
WLOGGERSTREAM(getCalibrationDetails(rrBasket, idxBasket, inflationParam, rrVol.calibrate()));
10271027
WLOGGERSTREAM("rmse = " << inflationCalibrationErrors_[modelIdx]);
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
/*
2+
Copyright (C) 2024 Quaternion Risk Management Ltd
3+
All rights reserved.
4+
5+
This file is part of ORE, a free-software/open-source library
6+
for transparent pricing and risk analysis - http://opensourcerisk.org
7+
8+
ORE is free software: you can redistribute it and/or modify it
9+
under the terms of the Modified BSD License. You should have received a
10+
copy of the license along with this program.
11+
The license is also available online at <http://opensourcerisk.org>
12+
13+
This program is distributed on the basis that it will form a useful
14+
contribution to risk analytics and model standardisation, but WITHOUT
15+
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16+
FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17+
*/
18+
19+
/*! \file ored/model/structuredmodelerror.hpp
20+
\brief Error for model calibration / building
21+
\ingroup marketdata
22+
*/
23+
24+
#pragma once
25+
26+
#include <boost/algorithm/string.hpp>
27+
#include <ored/utilities/log.hpp>
28+
29+
namespace ore {
30+
namespace data {
31+
32+
//! Utility class for Structured Model errors
33+
class StructuredModelWarningMessage : public StructuredMessage {
34+
public:
35+
StructuredModelWarningMessage(const std::string& exceptionType, const std::string& exceptionWhat,
36+
const std::string& contextId)
37+
: StructuredMessage(
38+
Category::Warning, Group::Model, exceptionWhat,
39+
std::map<std::string, std::string>({{"exceptionType", exceptionType}, {"context-id", contextId}})) {}
40+
};
41+
42+
} // namespace data
43+
} // namespace ore

OREData/ored/ored.hpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -112,6 +112,7 @@
112112
#include <ored/model/modeldata.hpp>
113113
#include <ored/model/modelparameter.hpp>
114114
#include <ored/model/structuredmodelerror.hpp>
115+
#include <ored/model/structuredmodelwarning.hpp>
115116
#include <ored/model/utilities.hpp>
116117
#include <ored/portfolio/accumulator.hpp>
117118
#include <ored/portfolio/ascot.hpp>

0 commit comments

Comments
 (0)