Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
XvaRunner Class Reference

#include <orea/app/xvarunner.hpp>

+ Collaboration diagram for XvaRunner:

Public Member Functions

virtual ~XvaRunner ()
 
 XvaRunner (const QuantLib::ext::shared_ptr< InputParameters > &inputs, QuantLib::Date asof, const std::string &baseCurrency, const QuantLib::ext::shared_ptr< ore::data::Portfolio > &portfolio, const QuantLib::ext::shared_ptr< ore::data::NettingSetManager > &netting, const QuantLib::ext::shared_ptr< ore::data::CollateralBalances > &collateralBalances, const QuantLib::ext::shared_ptr< ore::data::EngineData > &engineData, const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &curveConfigs, const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &todaysMarketParams, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &simMarketData, const QuantLib::ext::shared_ptr< ScenarioGeneratorData > &scenarioGeneratorData, const QuantLib::ext::shared_ptr< ore::data::CrossAssetModelData > &crossAssetModelData, const QuantLib::ext::shared_ptr< ReferenceDataManager > &referenceData=nullptr, const IborFallbackConfig &iborFallbackConfig=IborFallbackConfig::defaultConfig(), QuantLib::Real dimQuantile=0.99, QuantLib::Size dimHorizonCalendarDays=14, map< string, bool > analytics={}, string calculationType="Symmetric", string dvaName="", string fvaBorrowingCurve="", string fvaLendingCurve="", bool fullInitialCollateralisation=true, bool storeFlows=false)
 
void runXva (const QuantLib::ext::shared_ptr< ore::data::Market > &market, bool continueOnErr=true, const std::map< std::string, QuantLib::Real > &currentIM=std::map< std::string, QuantLib::Real >())
 
const QuantLib::ext::shared_ptr< PostProcess > & postProcess ()
 
void buildCamModel (const QuantLib::ext::shared_ptr< ore::data::Market > &market, bool continueOnErr=true)
 
void bufferSimulationPaths ()
 
virtual void buildSimMarket (const QuantLib::ext::shared_ptr< ore::data::Market > &market, const boost::optional< std::set< std::string > > &currencyFilter=boost::none, const bool continueOnErr=true)
 
void buildCube (const boost::optional< std::set< std::string > > &tradeIds, bool continueOnErr=true)
 
QuantLib::ext::shared_ptr< NPVCubenpvCube () const
 
QuantLib::ext::shared_ptr< NPVCubenettingCube () const
 
QuantLib::Handle< AggregationScenarioDataaggregationScenarioData ()
 
void generatePostProcessor (const QuantLib::ext::shared_ptr< Market > &market, const QuantLib::ext::shared_ptr< NPVCube > &npvCube, const QuantLib::ext::shared_ptr< NPVCube > &nettingCube, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, const bool continueOnErr=true, const std::map< std::string, QuantLib::Real > &currentIM=std::map< std::string, QuantLib::Real >())
 
std::set< std::string > getNettingSetIds (const QuantLib::ext::shared_ptr< Portfolio > &portfolio=nullptr) const
 

Protected Member Functions

virtual QuantLib::ext::shared_ptr< NPVCubegetNettingSetCube (std::vector< QuantLib::ext::shared_ptr< ValuationCalculator > > &calculators, const QuantLib::ext::shared_ptr< Portfolio > &portfolio)
 
virtual QuantLib::ext::shared_ptr< NPVCubegetNpvCube (const Date &asof, const std::set< std::string > &ids, const std::vector< Date > &dates, const Size samples, const Size depth) const
 
virtual QuantLib::ext::shared_ptr< DynamicInitialMarginCalculatorgetDimCalculator (const QuantLib::ext::shared_ptr< NPVCube > &cube, const QuantLib::ext::shared_ptr< CubeInterpretation > &cubeInterpreter, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &model=nullptr, const QuantLib::ext::shared_ptr< NPVCube > &nettingCube=nullptr, const std::map< std::string, QuantLib::Real > &currentIM=std::map< std::string, QuantLib::Real >())
 
virtual QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParametersprojectSsmData (const std::set< std::string > &currencyFilter) const
 
virtual QuantLib::ext::shared_ptr< ore::analytics::ScenarioGeneratorgetProjectedScenarioGenerator (const boost::optional< std::set< std::string > > &currencyFilter, const QuantLib::ext::shared_ptr< Market > &market, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &projectedSsmData, const QuantLib::ext::shared_ptr< ScenarioFactory > &scenarioFactory, const bool continueOnErr) const
 

Protected Attributes

QuantLib::ext::shared_ptr< InputParametersinputs_
 
QuantLib::Date asof_
 
std::string baseCurrency_
 
QuantLib::ext::shared_ptr< ore::data::Portfolioportfolio_
 
QuantLib::ext::shared_ptr< ore::data::NettingSetManagernetting_
 
QuantLib::ext::shared_ptr< ore::data::CollateralBalancescollateralBalances_
 
QuantLib::ext::shared_ptr< ore::data::EngineDataengineData_
 
QuantLib::ext::shared_ptr< ore::data::CurveConfigurationscurveConfigs_
 
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameterstodaysMarketParams_
 
QuantLib::ext::shared_ptr< ScenarioSimMarketParameterssimMarketData_
 
QuantLib::ext::shared_ptr< ScenarioGeneratorDatascenarioGeneratorData_
 
QuantLib::ext::shared_ptr< ore::data::CrossAssetModelDatacrossAssetModelData_
 
QuantLib::ext::shared_ptr< ReferenceDataManagerreferenceData_
 
IborFallbackConfig iborFallbackConfig_
 
QuantLib::Real dimQuantile_
 
QuantLib::Size dimHorizonCalendarDays_
 
map< string, boolanalytics_
 
string inputCalculationType_
 
string dvaName_
 
string fvaBorrowingCurve_
 
string fvaLendingCurve_
 
bool fullInitialCollateralisation_
 
bool storeFlows_
 
QuantLib::ext::shared_ptr< QuantExt::CrossAssetModelmodel_
 
QuantLib::ext::shared_ptr< ScenarioSimMarketsimMarket_
 
QuantLib::ext::shared_ptr< EngineFactorysimFactory_
 
QuantLib::RelinkableHandle< AggregationScenarioDatascenarioData_
 
QuantLib::ext::shared_ptr< NPVCubecube_
 
QuantLib::ext::shared_ptr< NPVCubenettingCube_
 
QuantLib::ext::shared_ptr< CubeInterpretationcubeInterpreter_
 
std::string calculationType_
 
QuantLib::ext::shared_ptr< PostProcesspostProcess_
 
QuantLib::ext::shared_ptr< std::vector< std::vector< QuantLib::Path > > > bufferedPaths_
 

Detailed Description

Definition at line 39 of file xvarunner.hpp.

Constructor & Destructor Documentation

◆ ~XvaRunner()

virtual ~XvaRunner ( )
virtual

Definition at line 41 of file xvarunner.hpp.

41{}

◆ XvaRunner()

XvaRunner ( const QuantLib::ext::shared_ptr< InputParameters > &  inputs,
QuantLib::Date  asof,
const std::string &  baseCurrency,
const QuantLib::ext::shared_ptr< ore::data::Portfolio > &  portfolio,
const QuantLib::ext::shared_ptr< ore::data::NettingSetManager > &  netting,
const QuantLib::ext::shared_ptr< ore::data::CollateralBalances > &  collateralBalances,
const QuantLib::ext::shared_ptr< ore::data::EngineData > &  engineData,
const QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > &  curveConfigs,
const QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > &  todaysMarketParams,
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &  simMarketData,
const QuantLib::ext::shared_ptr< ScenarioGeneratorData > &  scenarioGeneratorData,
const QuantLib::ext::shared_ptr< ore::data::CrossAssetModelData > &  crossAssetModelData,
const QuantLib::ext::shared_ptr< ReferenceDataManager > &  referenceData = nullptr,
const IborFallbackConfig iborFallbackConfig = IborFallbackConfig::defaultConfig(),
QuantLib::Real  dimQuantile = 0.99,
QuantLib::Size  dimHorizonCalendarDays = 14,
map< string, bool analytics = {},
string  calculationType = "Symmetric",
string  dvaName = "",
string  fvaBorrowingCurve = "",
string  fvaLendingCurve = "",
bool  fullInitialCollateralisation = true,
bool  storeFlows = false 
)

Definition at line 34 of file xvarunner.cpp.

48 : inputs_(inputs), asof_(asof), baseCurrency_(baseCurrency), portfolio_(portfolio), netting_(netting),
49 collateralBalances_(collateralBalances), engineData_(engineData),
50 curveConfigs_(curveConfigs), todaysMarketParams_(todaysMarketParams), simMarketData_(simMarketData),
51 scenarioGeneratorData_(scenarioGeneratorData), crossAssetModelData_(crossAssetModelData),
52 referenceData_(referenceData), iborFallbackConfig_(iborFallbackConfig), dimQuantile_(dimQuantile),
53 dimHorizonCalendarDays_(dimHorizonCalendarDays), analytics_(analytics), inputCalculationType_(calculationType),
54 dvaName_(dvaName), fvaBorrowingCurve_(fvaBorrowingCurve), fvaLendingCurve_(fvaLendingCurve),
55 fullInitialCollateralisation_(fullInitialCollateralisation), storeFlows_(storeFlows) {
56
57 if (analytics_.size() == 0) {
58 WLOG("post processor analytics not set, using defaults");
59 analytics_["dim"] = true;
60 analytics_["mva"] = true;
61 analytics_["kva"] = false;
62 analytics_["cvaSensi"] = true;
63 }
64}
QuantLib::ext::shared_ptr< ore::data::CurveConfigurations > curveConfigs_
Definition: xvarunner.hpp:136
QuantLib::ext::shared_ptr< ore::data::TodaysMarketParameters > todaysMarketParams_
Definition: xvarunner.hpp:137
QuantLib::Size dimHorizonCalendarDays_
Definition: xvarunner.hpp:144
map< string, bool > analytics_
Definition: xvarunner.hpp:145
QuantLib::ext::shared_ptr< ore::data::Portfolio > portfolio_
Definition: xvarunner.hpp:132
QuantLib::ext::shared_ptr< ScenarioGeneratorData > scenarioGeneratorData_
Definition: xvarunner.hpp:139
QuantLib::Real dimQuantile_
Definition: xvarunner.hpp:143
QuantLib::ext::shared_ptr< ore::data::CrossAssetModelData > crossAssetModelData_
Definition: xvarunner.hpp:140
QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > simMarketData_
Definition: xvarunner.hpp:138
IborFallbackConfig iborFallbackConfig_
Definition: xvarunner.hpp:142
QuantLib::ext::shared_ptr< ReferenceDataManager > referenceData_
Definition: xvarunner.hpp:141
QuantLib::ext::shared_ptr< InputParameters > inputs_
Definition: xvarunner.hpp:129
QuantLib::ext::shared_ptr< ore::data::NettingSetManager > netting_
Definition: xvarunner.hpp:133
QuantLib::ext::shared_ptr< ore::data::CollateralBalances > collateralBalances_
Definition: xvarunner.hpp:134
QuantLib::ext::shared_ptr< ore::data::EngineData > engineData_
Definition: xvarunner.hpp:135
#define WLOG(text)
Date asof(14, Jun, 2018)

Member Function Documentation

◆ runXva()

void runXva ( const QuantLib::ext::shared_ptr< ore::data::Market > &  market,
bool  continueOnErr = true,
const std::map< std::string, QuantLib::Real > &  currentIM = std::map<std::string, QuantLib::Real>() 
)

Definition at line 249 of file xvarunner.cpp.

250 {
251
252 LOG("XvaRunner::runXva called");
253
254 buildCamModel(market);
255 buildSimMarket(market, boost::none, true);
256 buildCube(boost::none, continueOnErr);
257 generatePostProcessor(market, npvCube(), nettingCube(), *aggregationScenarioData(), continueOnErr, currentIM);
258}
void buildCamModel(const QuantLib::ext::shared_ptr< ore::data::Market > &market, bool continueOnErr=true)
Definition: xvarunner.cpp:82
QuantLib::ext::shared_ptr< NPVCube > npvCube() const
Definition: xvarunner.hpp:83
void generatePostProcessor(const QuantLib::ext::shared_ptr< Market > &market, const QuantLib::ext::shared_ptr< NPVCube > &npvCube, const QuantLib::ext::shared_ptr< NPVCube > &nettingCube, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, const bool continueOnErr=true, const std::map< std::string, QuantLib::Real > &currentIM=std::map< std::string, QuantLib::Real >())
Definition: xvarunner.cpp:228
void buildCube(const boost::optional< std::set< std::string > > &tradeIds, bool continueOnErr=true)
Definition: xvarunner.cpp:156
QuantLib::Handle< AggregationScenarioData > aggregationScenarioData()
Definition: xvarunner.hpp:89
virtual void buildSimMarket(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const boost::optional< std::set< std::string > > &currencyFilter=boost::none, const bool continueOnErr=true)
Definition: xvarunner.cpp:122
QuantLib::ext::shared_ptr< NPVCube > nettingCube() const
Definition: xvarunner.hpp:86
#define LOG(text)
+ Here is the call graph for this function:

◆ postProcess()

const QuantLib::ext::shared_ptr< PostProcess > & postProcess ( )

Definition at line 66 of file xvarunner.hpp.

66{ return postProcess_; }
QuantLib::ext::shared_ptr< PostProcess > postProcess_
Definition: xvarunner.hpp:161

◆ buildCamModel()

void buildCamModel ( const QuantLib::ext::shared_ptr< ore::data::Market > &  market,
bool  continueOnErr = true 
)

Definition at line 82 of file xvarunner.cpp.

82 {
83
84 LOG("XvaRunner::buildCamModel() called");
85
86 Settings::instance().evaluationDate() = asof_;
87 CrossAssetModelBuilder modelBuilder(
90 Market::defaultConfiguration, false, continueOnErr, "", SalvagingAlgorithm::None, "xva cam building");
91 model_ = *modelBuilder.model();
92}
QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > model_
Definition: xvarunner.hpp:154
static const string defaultConfiguration
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ bufferSimulationPaths()

void bufferSimulationPaths ( )

Definition at line 94 of file xvarunner.cpp.

94 {
95
96 LOG("XvaRunner::bufferSimulationPaths() called");
97
98 auto stateProcess = model_->stateProcess();
99 if (auto tmp = QuantLib::ext::dynamic_pointer_cast<CrossAssetStateProcess>(stateProcess)) {
100 tmp->resetCache(scenarioGeneratorData_->getGrid()->timeGrid().size() - 1);
101 }
102 auto pathGen = MultiPathGeneratorFactory().build(scenarioGeneratorData_->sequenceType(), stateProcess,
103 scenarioGeneratorData_->getGrid()->timeGrid(),
105 scenarioGeneratorData_->directionIntegers());
106
107 if (!bufferedPaths_) {
108 bufferedPaths_ = QuantLib::ext::make_shared<std::vector<std::vector<Path>>>(
109 scenarioGeneratorData_->samples(), std::vector<Path>(stateProcess->size(), TimeGrid()));
110 }
111
112 for (Size p = 0; p < scenarioGeneratorData_->samples(); ++p) {
113 const MultiPath& path = pathGen->next().value;
114 for (Size d = 0; d < stateProcess->size(); ++d) {
115 (*bufferedPaths_)[p][d] = path[d];
116 }
117 }
118
119 LOG("XvaRunner::bufferSimulationPaths() finished");
120}
QuantLib::ext::shared_ptr< std::vector< std::vector< QuantLib::Path > > > bufferedPaths_
Definition: xvarunner.hpp:163
+ Here is the call graph for this function:

◆ buildSimMarket()

void buildSimMarket ( const QuantLib::ext::shared_ptr< ore::data::Market > &  market,
const boost::optional< std::set< std::string > > &  currencyFilter = boost::none,
const bool  continueOnErr = true 
)
virtual

Definition at line 122 of file xvarunner.cpp.

123 {
124 LOG("XvaRunner::buildSimMarket() called");
125
126 Settings::instance().evaluationDate() = asof_;
127
128 QuantLib::ext::shared_ptr<ScenarioSimMarketParameters> projectedSsmData;
129 if (currencyFilter) {
130 projectedSsmData = projectSsmData(*currencyFilter);
131 }
132 else {
133 projectedSsmData = simMarketData_;
134 }
135
136 QuantLib::ext::shared_ptr<ScenarioFactory> sf = QuantLib::ext::make_shared<SimpleScenarioFactory>(true);
137 QuantLib::ext::shared_ptr<ScenarioGenerator> sg =
138 getProjectedScenarioGenerator(currencyFilter, market, projectedSsmData, sf, continueOnErr);
139 simMarket_ = QuantLib::ext::make_shared<ScenarioSimMarket>(market, projectedSsmData, Market::defaultConfiguration,
140 *curveConfigs_, *todaysMarketParams_, true, false, true, false,
141 iborFallbackConfig_, false);
142 simMarket_->scenarioGenerator() = sg;
143
144 DLOG("build scenario data");
145
146 scenarioData_.linkTo(QuantLib::ext::make_shared<InMemoryAggregationScenarioData>(
147 scenarioGeneratorData_->getGrid()->valuationDates().size(), scenarioGeneratorData_->samples()));
148 simMarket_->aggregationScenarioData() = *scenarioData_;
149
150 auto ed = QuantLib::ext::make_shared<EngineData>(*engineData_);
151 ed->globalParameters()["RunType"] = "Exposure";
152 simFactory_ = QuantLib::ext::make_shared<EngineFactory>(ed, simMarket_, map<MarketContext, string>(), referenceData_,
154}
QuantLib::ext::shared_ptr< ScenarioSimMarket > simMarket_
Definition: xvarunner.hpp:155
QuantLib::RelinkableHandle< AggregationScenarioData > scenarioData_
Definition: xvarunner.hpp:157
QuantLib::ext::shared_ptr< EngineFactory > simFactory_
Definition: xvarunner.hpp:156
virtual QuantLib::ext::shared_ptr< ore::analytics::ScenarioSimMarketParameters > projectSsmData(const std::set< std::string > &currencyFilter) const
Definition: xvarunner.cpp:67
virtual QuantLib::ext::shared_ptr< ore::analytics::ScenarioGenerator > getProjectedScenarioGenerator(const boost::optional< std::set< std::string > > &currencyFilter, const QuantLib::ext::shared_ptr< Market > &market, const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &projectedSsmData, const QuantLib::ext::shared_ptr< ScenarioFactory > &scenarioFactory, const bool continueOnErr) const
Definition: xvarunner.cpp:72
#define DLOG(text)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ buildCube()

void buildCube ( const boost::optional< std::set< std::string > > &  tradeIds,
bool  continueOnErr = true 
)

Definition at line 156 of file xvarunner.cpp.

156 {
157
158 LOG("XvaRunner::buildCube called");
159
160 Settings::instance().evaluationDate() = asof_;
161
162 QuantLib::ext::shared_ptr<Portfolio> portfolio = QuantLib::ext::make_shared<Portfolio>();
163 if (tradeIds) {
164 for (auto const& t : *tradeIds) {
165 QL_REQUIRE(portfolio_->has(t), "XvaRunner::buildCube(): portfolio does not contain trade with id '"
166 << t << "' specified in the filter");
167 portfolio->add(portfolio_->get(t));
168 }
169 } else {
170 portfolio = portfolio_;
171 }
172
173 DLOG("build portfolio");
174
175 // FIXME why do we need this? portfolio_->reset() is not sufficient to ensure XVA simulation run fast (and this is
176 // called before)
177 for (auto const& [tid, t] : portfolio_->trades()) {
178 try {
179 t->build(simFactory_);
180 } catch (...) {
181 // we don't care, this is just to reset the portfolio, the real build is below
182 }
183 }
184
185 portfolio->build(simFactory_);
186
187 DLOG("build calculators");
188
189 std::vector<QuantLib::ext::shared_ptr<ValuationCalculator>> calculators;
190 QuantLib::ext::shared_ptr<NPVCalculator> npvCalculator = QuantLib::ext::make_shared<NPVCalculator>(baseCurrency_);
191 cubeInterpreter_ = QuantLib::ext::make_shared<CubeInterpretation>(storeFlows_, scenarioGeneratorData_->withCloseOutLag(),
193 if (scenarioGeneratorData_->withCloseOutLag()) {
194 // depth 2: NPV and close-out NPV
195 cube_ = getNpvCube(asof_, portfolio->ids(), scenarioGeneratorData_->getGrid()->valuationDates(),
196 scenarioGeneratorData_->samples(), 2);
197 calculators.push_back(QuantLib::ext::make_shared<MPORCalculator>(npvCalculator, cubeInterpreter_->defaultDateNpvIndex(),
198 cubeInterpreter_->closeOutDateNpvIndex()));
199 calculationType_ = "NoLag";
201 ALOG("Forcing calculation type " << calculationType_ << " for simulations with close-out grid");
202 }
203 } else {
204 if (storeFlows_) {
205 // regular, depth 2: NPV and cash flow
206 cube_ = getNpvCube(asof_, portfolio->ids(), scenarioGeneratorData_->getGrid()->dates(),
207 scenarioGeneratorData_->samples(), 2);
208 calculators.push_back(QuantLib::ext::make_shared<CashflowCalculator>(
209 baseCurrency_, asof_, scenarioGeneratorData_->getGrid(), cubeInterpreter_->mporFlowsIndex()));
210 } else
211 // regular, depth 1
212 cube_ = getNpvCube(asof_, portfolio->ids(), scenarioGeneratorData_->getGrid()->dates(),
213 scenarioGeneratorData_->samples(), 1);
214 calculators.push_back(npvCalculator);
216 }
217
218 DLOG("get netting cube");
219
220 nettingCube_ = getNettingSetCube(calculators, portfolio);
221
222 DLOG("run valuation engine");
223
224 ValuationEngine engine(asof_, scenarioGeneratorData_->getGrid(), simMarket_);
225 engine.buildCube(portfolio, cube_, calculators, scenarioGeneratorData_->withMporStickyDate(), nettingCube_);
226}
std::string calculationType_
Definition: xvarunner.hpp:160
QuantLib::ext::shared_ptr< CubeInterpretation > cubeInterpreter_
Definition: xvarunner.hpp:159
virtual QuantLib::ext::shared_ptr< NPVCube > getNpvCube(const Date &asof, const std::set< std::string > &ids, const std::vector< Date > &dates, const Size samples, const Size depth) const
Definition: xvarunner.cpp:287
virtual QuantLib::ext::shared_ptr< NPVCube > getNettingSetCube(std::vector< QuantLib::ext::shared_ptr< ValuationCalculator > > &calculators, const QuantLib::ext::shared_ptr< Portfolio > &portfolio)
Definition: xvarunner.hpp:104
QuantLib::ext::shared_ptr< NPVCube > cube_
Definition: xvarunner.hpp:158
QuantLib::ext::shared_ptr< NPVCube > nettingCube_
Definition: xvarunner.hpp:158
#define ALOG(text)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ npvCube()

QuantLib::ext::shared_ptr< NPVCube > npvCube ( ) const

Definition at line 83 of file xvarunner.hpp.

83{ return cube_; }
+ Here is the caller graph for this function:

◆ nettingCube()

QuantLib::ext::shared_ptr< NPVCube > nettingCube ( ) const

Definition at line 86 of file xvarunner.hpp.

86{ return nettingCube_; }
+ Here is the caller graph for this function:

◆ aggregationScenarioData()

QuantLib::Handle< AggregationScenarioData > aggregationScenarioData ( )

Definition at line 89 of file xvarunner.hpp.

89{ return scenarioData_; }
+ Here is the caller graph for this function:

◆ generatePostProcessor()

void generatePostProcessor ( const QuantLib::ext::shared_ptr< Market > &  market,
const QuantLib::ext::shared_ptr< NPVCube > &  npvCube,
const QuantLib::ext::shared_ptr< NPVCube > &  nettingCube,
const QuantLib::ext::shared_ptr< AggregationScenarioData > &  scenarioData,
const bool  continueOnErr = true,
const std::map< std::string, QuantLib::Real > &  currentIM = std::map<std::string, QuantLib::Real>() 
)

Definition at line 228 of file xvarunner.cpp.

233 {
234
235 LOG("XvaRunner::generatePostProcessor called");
236
237 QL_REQUIRE(analytics_.size() > 0, "analytics map not set");
238
239 QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator> dimCalculator =
241
242 postProcess_ = QuantLib::ext::make_shared<PostProcess>(portfolio_, netting_, collateralBalances_,
243 market, "", npvCube, scenarioData, analytics_,
244 baseCurrency_, "None", 1.0, 0.95, calculationType_, dvaName_,
245 fvaBorrowingCurve_, fvaLendingCurve_, dimCalculator,
247}
virtual QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > getDimCalculator(const QuantLib::ext::shared_ptr< NPVCube > &cube, const QuantLib::ext::shared_ptr< CubeInterpretation > &cubeInterpreter, const QuantLib::ext::shared_ptr< AggregationScenarioData > &scenarioData, const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &model=nullptr, const QuantLib::ext::shared_ptr< NPVCube > &nettingCube=nullptr, const std::map< std::string, QuantLib::Real > &currentIM=std::map< std::string, QuantLib::Real >())
Definition: xvarunner.cpp:260
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getNettingSetIds()

std::set< std::string > getNettingSetIds ( const QuantLib::ext::shared_ptr< Portfolio > &  portfolio = nullptr) const

Definition at line 279 of file xvarunner.cpp.

279 {
280 // collect netting set ids from portfolio
281 std::set<std::string> nettingSetIds;
282 for (auto const& [tradeId,trade] : portfolio == nullptr ? portfolio_->trades() : portfolio->trades())
283 nettingSetIds.insert(trade->envelope().nettingSetId());
284 return nettingSetIds;
285}

◆ getNettingSetCube()

virtual QuantLib::ext::shared_ptr< NPVCube > getNettingSetCube ( std::vector< QuantLib::ext::shared_ptr< ValuationCalculator > > &  calculators,
const QuantLib::ext::shared_ptr< Portfolio > &  portfolio 
)
protectedvirtual

Definition at line 104 of file xvarunner.hpp.

105 {
106 return nullptr;
107 };
+ Here is the caller graph for this function:

◆ getNpvCube()

QuantLib::ext::shared_ptr< NPVCube > getNpvCube ( const Date &  asof,
const std::set< std::string > &  ids,
const std::vector< Date > &  dates,
const Size  samples,
const Size  depth 
) const
protectedvirtual

Definition at line 287 of file xvarunner.cpp.

289 {
290 if (depth == 1) {
291 return QuantLib::ext::make_shared<SinglePrecisionInMemoryCube>(asof, ids, dates, samples, 0.0f);
292 } else {
293 return QuantLib::ext::make_shared<SinglePrecisionInMemoryCubeN>(asof, ids, dates, samples, depth, 0.0f);
294 }
295}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ getDimCalculator()

QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > getDimCalculator ( const QuantLib::ext::shared_ptr< NPVCube > &  cube,
const QuantLib::ext::shared_ptr< CubeInterpretation > &  cubeInterpreter,
const QuantLib::ext::shared_ptr< AggregationScenarioData > &  scenarioData,
const QuantLib::ext::shared_ptr< QuantExt::CrossAssetModel > &  model = nullptr,
const QuantLib::ext::shared_ptr< NPVCube > &  nettingCube = nullptr,
const std::map< std::string, QuantLib::Real > &  currentIM = std::map<std::string, QuantLib::Real>() 
)
protectedvirtual

Definition at line 260 of file xvarunner.cpp.

264 {
265
266 QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator> dimCalculator;
267 Size dimRegressionOrder = 0;
268 vector<string> dimRegressors; // FIXME: empty vector means regression vs netting set NPV
269 Size dimLocalRegressionEvaluations = 0; // skip local regression
270 Real dimLocalRegressionBandwidth = 0.25;
271
272 dimCalculator = QuantLib::ext::make_shared<RegressionDynamicInitialMarginCalculator>(
273 inputs_, portfolio_, cube, cubeInterpreter, scenarioData, dimQuantile_, dimHorizonCalendarDays_, dimRegressionOrder,
274 dimRegressors, dimLocalRegressionEvaluations, dimLocalRegressionBandwidth, currentIM);
275
276 return dimCalculator;
277}
+ Here is the caller graph for this function:

◆ projectSsmData()

QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > projectSsmData ( const std::set< std::string > &  currencyFilter) const
protectedvirtual

Definition at line 67 of file xvarunner.cpp.

67 {
68 QL_FAIL("XvaRunner::projectSsmData() is only available in ORE+");
69}
+ Here is the caller graph for this function:

◆ getProjectedScenarioGenerator()

QuantLib::ext::shared_ptr< ore::analytics::ScenarioGenerator > getProjectedScenarioGenerator ( const boost::optional< std::set< std::string > > &  currencyFilter,
const QuantLib::ext::shared_ptr< Market > &  market,
const QuantLib::ext::shared_ptr< ScenarioSimMarketParameters > &  projectedSsmData,
const QuantLib::ext::shared_ptr< ScenarioFactory > &  scenarioFactory,
const bool  continueOnErr 
) const
protectedvirtual

Definition at line 72 of file xvarunner.cpp.

75 {
76 QL_REQUIRE(!currencyFilter,
77 "XvaRunner::getProjectedScenarioGenerator() with currency filter is only available in ORE+");
78 ScenarioGeneratorBuilder sgb(scenarioGeneratorData_);
79 return sgb.build(model_, sf, projectedSsmData, asof_, market, Market::defaultConfiguration);
80}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ inputs_

QuantLib::ext::shared_ptr<InputParameters> inputs_
protected

Definition at line 129 of file xvarunner.hpp.

◆ asof_

QuantLib::Date asof_
protected

Definition at line 130 of file xvarunner.hpp.

◆ baseCurrency_

std::string baseCurrency_
protected

Definition at line 131 of file xvarunner.hpp.

◆ portfolio_

QuantLib::ext::shared_ptr<ore::data::Portfolio> portfolio_
protected

Definition at line 132 of file xvarunner.hpp.

◆ netting_

QuantLib::ext::shared_ptr<ore::data::NettingSetManager> netting_
protected

Definition at line 133 of file xvarunner.hpp.

◆ collateralBalances_

QuantLib::ext::shared_ptr<ore::data::CollateralBalances> collateralBalances_
protected

Definition at line 134 of file xvarunner.hpp.

◆ engineData_

QuantLib::ext::shared_ptr<ore::data::EngineData> engineData_
protected

Definition at line 135 of file xvarunner.hpp.

◆ curveConfigs_

QuantLib::ext::shared_ptr<ore::data::CurveConfigurations> curveConfigs_
protected

Definition at line 136 of file xvarunner.hpp.

◆ todaysMarketParams_

QuantLib::ext::shared_ptr<ore::data::TodaysMarketParameters> todaysMarketParams_
protected

Definition at line 137 of file xvarunner.hpp.

◆ simMarketData_

QuantLib::ext::shared_ptr<ScenarioSimMarketParameters> simMarketData_
protected

Definition at line 138 of file xvarunner.hpp.

◆ scenarioGeneratorData_

QuantLib::ext::shared_ptr<ScenarioGeneratorData> scenarioGeneratorData_
protected

Definition at line 139 of file xvarunner.hpp.

◆ crossAssetModelData_

QuantLib::ext::shared_ptr<ore::data::CrossAssetModelData> crossAssetModelData_
protected

Definition at line 140 of file xvarunner.hpp.

◆ referenceData_

QuantLib::ext::shared_ptr<ReferenceDataManager> referenceData_
protected

Definition at line 141 of file xvarunner.hpp.

◆ iborFallbackConfig_

IborFallbackConfig iborFallbackConfig_
protected

Definition at line 142 of file xvarunner.hpp.

◆ dimQuantile_

QuantLib::Real dimQuantile_
protected

Definition at line 143 of file xvarunner.hpp.

◆ dimHorizonCalendarDays_

QuantLib::Size dimHorizonCalendarDays_
protected

Definition at line 144 of file xvarunner.hpp.

◆ analytics_

map<string, bool> analytics_
protected

Definition at line 145 of file xvarunner.hpp.

◆ inputCalculationType_

string inputCalculationType_
protected

Definition at line 146 of file xvarunner.hpp.

◆ dvaName_

string dvaName_
protected

Definition at line 147 of file xvarunner.hpp.

◆ fvaBorrowingCurve_

string fvaBorrowingCurve_
protected

Definition at line 148 of file xvarunner.hpp.

◆ fvaLendingCurve_

string fvaLendingCurve_
protected

Definition at line 149 of file xvarunner.hpp.

◆ fullInitialCollateralisation_

bool fullInitialCollateralisation_
protected

Definition at line 150 of file xvarunner.hpp.

◆ storeFlows_

bool storeFlows_
protected

Definition at line 151 of file xvarunner.hpp.

◆ model_

QuantLib::ext::shared_ptr<QuantExt::CrossAssetModel> model_
protected

Definition at line 154 of file xvarunner.hpp.

◆ simMarket_

QuantLib::ext::shared_ptr<ScenarioSimMarket> simMarket_
protected

Definition at line 155 of file xvarunner.hpp.

◆ simFactory_

QuantLib::ext::shared_ptr<EngineFactory> simFactory_
protected

Definition at line 156 of file xvarunner.hpp.

◆ scenarioData_

QuantLib::RelinkableHandle<AggregationScenarioData> scenarioData_
protected

Definition at line 157 of file xvarunner.hpp.

◆ cube_

QuantLib::ext::shared_ptr<NPVCube> cube_
protected

Definition at line 158 of file xvarunner.hpp.

◆ nettingCube_

QuantLib::ext::shared_ptr<NPVCube> nettingCube_
protected

Definition at line 158 of file xvarunner.hpp.

◆ cubeInterpreter_

QuantLib::ext::shared_ptr<CubeInterpretation> cubeInterpreter_
protected

Definition at line 159 of file xvarunner.hpp.

◆ calculationType_

std::string calculationType_
protected

Definition at line 160 of file xvarunner.hpp.

◆ postProcess_

QuantLib::ext::shared_ptr<PostProcess> postProcess_
protected

Definition at line 161 of file xvarunner.hpp.

◆ bufferedPaths_

QuantLib::ext::shared_ptr<std::vector<std::vector<QuantLib::Path> > > bufferedPaths_
protected

Definition at line 163 of file xvarunner.hpp.