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

XVA Calculator base class. More...

#include <orea/aggregation/xvacalculator.hpp>

+ Inheritance diagram for ValueAdjustmentCalculator:
+ Collaboration diagram for ValueAdjustmentCalculator:

Public Member Functions

 ValueAdjustmentCalculator (const QuantLib::ext::shared_ptr< Portfolio > portfolio, const QuantLib::ext::shared_ptr< Market > market, const string &configuration, const string &baseCurrency, const string &dvaName, const string &fvaBorrowingCurve, const string &fvaLendingCurve, const bool applyDynamicInitialMargin, const QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > dimCalculator, const QuantLib::ext::shared_ptr< NPVCube > tradeExposureCube, const QuantLib::ext::shared_ptr< NPVCube > nettingSetExposureCube, const Size tradeEpeIndex=0, const Size tradeEneIndex=1, const Size nettingSetEpeIndex=1, const Size nettingSetEneIndex=2, const bool flipViewXVA=false, const string &flipViewBorrowingCurvePostfix="_BORROW", const string &flipViewLendingCurvePostfix="_LEND")
 
virtual ~ValueAdjustmentCalculator ()
 
virtual void build ()
 Compute cva along all paths and fill result structures. More...
 
virtual const vector< Date > & dates ()
 
virtual const Date asof ()
 
virtual const Real calculateCvaIncrement (const string &tid, const string &cid, const Date &d0, const Date &d1, const Real &rr)=0
 
virtual const Real calculateDvaIncrement (const string &tid, const Date &d0, const Date &d1, const Real &rr)=0
 
virtual const Real calculateNettingSetCvaIncrement (const string &nid, const string &cid, const Date &d0, const Date &d1, const Real &rr)=0
 
virtual const Real calculateNettingSetDvaIncrement (const string &nid, const Date &d0, const Date &d1, const Real &rr)=0
 
virtual const Real calculateFbaIncrement (const string &tid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
 
virtual const Real calculateFcaIncrement (const string &tid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
 
virtual const Real calculateNettingSetFbaIncrement (const string &nid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
 
virtual const Real calculateNettingSetFcaIncrement (const string &nid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
 
virtual const Real calculateNettingSetMvaIncrement (const string &nid, const string &cid, const Date &d0, const Date &d1, const Real &dcf)=0
 
const map< string, Real > & tradeCva ()
 CVA map for all the trades. More...
 
const map< string, Real > & tradeDva ()
 DVA map for all the trades. More...
 
const map< string, Real > & nettingSetCva ()
 CVA map for all the netting sets. More...
 
const map< string, Real > & nettingSetDva ()
 DVA map for all the netting sets. More...
 
const map< string, Real > & nettingSetSumCva ()
 Sum CVA map for all the netting sets. More...
 
const map< string, Real > & nettingSetSumDva ()
 Sum DVA map for all the netting sets. More...
 
const Real & tradeCva (const string &trade)
 CVA for the specified trade. More...
 
const Real & tradeDva (const string &trade)
 DVA for the specified trade. More...
 
const Real & tradeFba (const string &trade)
 FBA for the specified trade. More...
 
const Real & tradeFba_exOwnSp (const string &trade)
 FBA (excl own survival probability) for the specified trade. More...
 
const Real & tradeFba_exAllSp (const string &trade)
 FBA (excl all survival probability) for the specified trade. More...
 
const Real & tradeFca (const string &trade)
 FCA for the specified trade. More...
 
const Real & tradeFca_exOwnSp (const string &trade)
 FCA (excl own survival probability) for the specified trade. More...
 
const Real & tradeFca_exAllSp (const string &trade)
 FCA (excl all survival probability) for the specified trade. More...
 
const Real & tradeMva (const string &trade)
 MVA for the specified trade. More...
 
const Real & nettingSetSumCva (const string &nettingSet)
 Sum of trades' CVA for the specified netting set. More...
 
const Real & nettingSetSumDva (const string &nettingSet)
 Sum of trades' DVA for the specified netting set. More...
 
const Real & nettingSetCva (const string &nettingSet)
 CVA for the specified netting set. More...
 
const Real & nettingSetDva (const string &nettingSet)
 DVA for the specified netting set. More...
 
const Real & nettingSetFba (const string &nettingSet)
 FBA for the specified netting set. More...
 
const Real & nettingSetFba_exOwnSp (const string &nettingSet)
 FBA (excl own survival probability) for the specified netting set. More...
 
const Real & nettingSetFba_exAllSp (const string &nettingSet)
 FBA (excl all survival probability) for the specified netting set. More...
 
const Real & nettingSetFca (const string &nettingSet)
 FCA for the specified netting set. More...
 
const Real & nettingSetFca_exOwnSp (const string &nettingSet)
 FCA (excl own survival probability) for the specified netting set. More...
 
const Real & nettingSetFca_exAllSp (const string &nettingSet)
 FCA (excl all survival probability) for the specified netting set. More...
 
const Real & nettingSetMva (const string &nettingSet)
 MVA for the specified netting set. More...
 

Protected Attributes

QuantLib::ext::shared_ptr< Portfolioportfolio_
 
QuantLib::ext::shared_ptr< Marketmarket_
 
string configuration_
 
string baseCurrency_
 
string dvaName_
 
string fvaBorrowingCurve_
 
string fvaLendingCurve_
 
bool applyDynamicInitialMargin_
 
QuantLib::ext::shared_ptr< DynamicInitialMarginCalculatordimCalculator_
 
const QuantLib::ext::shared_ptr< NPVCubetradeExposureCube_
 
const QuantLib::ext::shared_ptr< NPVCubenettingSetExposureCube_
 
Size tradeEpeIndex_
 
Size tradeEneIndex_
 
Size nettingSetEpeIndex_
 
Size nettingSetEneIndex_
 
bool flipViewXVA_
 
string flipViewBorrowingCurvePostfix_
 
string flipViewLendingCurvePostfix_
 
map< string, string > nettingSetCpty_
 
map< string, Real > tradeCva_
 
map< string, Real > tradeDva_
 
map< string, Real > tradeFba_
 
map< string, Real > tradeFba_exOwnSp_
 
map< string, Real > tradeFba_exAllSp_
 
map< string, Real > tradeFca_
 
map< string, Real > tradeFca_exOwnSp_
 
map< string, Real > tradeFca_exAllSp_
 
map< string, Real > tradeMva_
 
map< string, Real > nettingSetSumCva_
 
map< string, Real > nettingSetSumDva_
 
map< string, Real > nettingSetCva_
 
map< string, Real > nettingSetDva_
 
map< string, Real > nettingSetFba_
 
map< string, Real > nettingSetFba_exOwnSp_
 
map< string, Real > nettingSetFba_exAllSp_
 
map< string, Real > nettingSetFca_
 
map< string, Real > nettingSetFca_exOwnSp_
 
map< string, Real > nettingSetFca_exAllSp_
 
map< string, Real > nettingSetMva_
 

Detailed Description

XVA Calculator base class.

Derived classes implement a constructor with the relevant additional input data and a build function that performs the XVA calculations for all netting sets and along all paths.

Definition at line 48 of file xvacalculator.hpp.

Constructor & Destructor Documentation

◆ ValueAdjustmentCalculator()

ValueAdjustmentCalculator ( const QuantLib::ext::shared_ptr< Portfolio portfolio,
const QuantLib::ext::shared_ptr< Market market,
const string &  configuration,
const string &  baseCurrency,
const string &  dvaName,
const string &  fvaBorrowingCurve,
const string &  fvaLendingCurve,
const bool  applyDynamicInitialMargin,
const QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator dimCalculator,
const QuantLib::ext::shared_ptr< NPVCube tradeExposureCube,
const QuantLib::ext::shared_ptr< NPVCube nettingSetExposureCube,
const Size  tradeEpeIndex = 0,
const Size  tradeEneIndex = 1,
const Size  nettingSetEpeIndex = 1,
const Size  nettingSetEneIndex = 2,
const bool  flipViewXVA = false,
const string &  flipViewBorrowingCurvePostfix = "_BORROW",
const string &  flipViewLendingCurvePostfix = "_LEND" 
)
Parameters
portfolioDriving portfolio consistent with the cube below
marketToday's market
configurationMarket configuration to be used
baseCurrencyBase currency amounts will be converted to
dvaNameOwn party name for DVA calculations
fvaBorrowingCurveFVA borrowing curve
fvaLendingCurveFVA lending curve
applyDynamicInitialMarginDeactivate initial margin calculation even if active at netting set level
dimCalculatorDynamic Initial Margin calculator
tradeExposureCubeStorage ofdefault NPVs, close-out NPVs, cash flows at trade level
nettingSetExposureCubeStorage of sensitivity vectors at netting set level
tradeEpeIndexIndex of the trade EPE storage in the internal exposure cube
tradeEneIndexIndex of the trade ENE storage in the internal exposure cube
nettingSetEpeIndexIndex of the netting set EPE storage in the internal exposure cube
nettingSetEneIndexIndex of the netting set ENE storage in the internal exposure cube
flipViewXVAFlag to indicate flipped xva calculation
flipViewBorrowingCurvePostfixPostfix for flipView borrowing curve for fva
flipViewLendingCurvePostfixPostfix for flipView lending curve for fva

Definition at line 36 of file xvacalculator.cpp.

51 : portfolio_(portfolio), market_(market), configuration_(configuration),
52 baseCurrency_(baseCurrency), dvaName_(dvaName),
53 fvaBorrowingCurve_(fvaBorrowingCurve), fvaLendingCurve_(fvaLendingCurve),
54 applyDynamicInitialMargin_(applyDynamicInitialMargin),
55 dimCalculator_(dimCalculator),
56 tradeExposureCube_(tradeExposureCube),
57 nettingSetExposureCube_(nettingSetExposureCube),
58 tradeEpeIndex_(tradeEpeIndex), tradeEneIndex_(tradeEneIndex), nettingSetEpeIndex_(nettingSetEpeIndex),
59 nettingSetEneIndex_(nettingSetEneIndex), flipViewXVA_(flipViewXVA),
60 flipViewBorrowingCurvePostfix_(flipViewBorrowingCurvePostfix), flipViewLendingCurvePostfix_(flipViewLendingCurvePostfix) {
61
62 QL_REQUIRE(portfolio_, "portfolio is null");
63
64 for (const auto& [tradeId, trade] : portfolio_->trades()) {
65 string nettingSetId = trade->envelope().nettingSetId();
66 if (nettingSetCpty_.find(nettingSetId) == nettingSetCpty_.end()) {
67 nettingSetCpty_[nettingSetId] = trade->envelope().counterparty();
68 }
69 }
70
71
72
73 QL_REQUIRE(tradeExposureCube_->numIds() == portfolio_->trades().size(),
74 "number of trades in tradeExposureCube and portfolio mismatch ("
75 << tradeExposureCube_->numIds() << " vs " << portfolio_->trades().size() << ")");
76
77 QL_REQUIRE(nettingSetExposureCube_->numIds() == nettingSetCpty_.size(),
78 "number of netting sets in nettingSetExposureCube and nettingSetCpty map mismatch ("
79 << nettingSetExposureCube_->numIds() << " vs " << nettingSetCpty_.size() << ")");
80
81 QL_REQUIRE(tradeExposureCube_->numDates() == nettingSetExposureCube_->numDates(),
82 "number of dates in tradeExposureCube and nettingSetExposureCube mismatch ("
83 << tradeExposureCube_->numDates() << " vs " << nettingSetExposureCube_->numDates() << ")");
84
85 for (Size i = 0; i < tradeExposureCube_->numDates(); i++) {
86 QL_REQUIRE(tradeExposureCube_->dates()[i] == nettingSetExposureCube_->dates()[i],
87 "date at " << i << " in tradeExposureCube and nettingSetExposureCube mismatch ("
88 << tradeExposureCube_->dates()[i] << " vs " << nettingSetExposureCube_->dates()[i] << ")");
89 }
90
91 QL_REQUIRE(tradeEpeIndex < tradeExposureCube_->depth(), "tradeEpeIndex("
92 << tradeEpeIndex << ") exceeds depth of tradeExposureCube("
93 << tradeExposureCube_->depth() << ")");
94
95 QL_REQUIRE(tradeEneIndex < tradeExposureCube_->depth(), "tradeEneIndex("
96 << tradeEneIndex << ") exceeds depth of tradeExposureCube("
97 << tradeExposureCube_->depth() << ")");
98
99 QL_REQUIRE(nettingSetEpeIndex < nettingSetExposureCube_->depth(), "nettingSetEpeIndex("
100 << nettingSetEpeIndex << ") exceeds depth of nettingSetExposureCube("
101 << nettingSetExposureCube_->depth() << ")");
102
103 QL_REQUIRE(nettingSetEneIndex < nettingSetExposureCube_->depth(), "nettingSetEneIndex("
104 << nettingSetEneIndex << ") exceeds depth of nettingSetExposureCube("
105 << nettingSetExposureCube_->depth() << ")");
106
107}
QuantLib::ext::shared_ptr< Market > market_
QuantLib::ext::shared_ptr< Portfolio > portfolio_
QuantLib::ext::shared_ptr< DynamicInitialMarginCalculator > dimCalculator_
const QuantLib::ext::shared_ptr< NPVCube > nettingSetExposureCube_
const QuantLib::ext::shared_ptr< NPVCube > tradeExposureCube_

◆ ~ValueAdjustmentCalculator()

virtual ~ValueAdjustmentCalculator ( )
virtual

Definition at line 89 of file xvacalculator.hpp.

89{}

Member Function Documentation

◆ build()

void build ( )
virtual

Compute cva along all paths and fill result structures.

Definition at line 273 of file xvacalculator.cpp.

273 {
274 const auto& numDates = dates().size();
275 const auto& today = asof();
276
277 Handle<YieldTermStructure> borrowingCurve, lendingCurve, oisCurve;
278 if (baseCurrency_ != "")
279 oisCurve = market_->discountCurve(baseCurrency_, configuration_);
280
281 string origDvaName = dvaName_;
282 // Trade XVA
283 for (const auto& [tid, trade] : portfolio_->trades()) {
284 try {
285 LOG("Update XVA for trade " << tid
286 << (flipViewXVA_ ? ", inverted (flipViewXVA = Y)"
287 : ", regular (flipViewXVA = N)"));
288 string cid;
289 if (flipViewXVA_) {
290 cid = origDvaName;
291 dvaName_ = trade->envelope().counterparty();
294 } else {
295 cid = trade->envelope().counterparty();
296 }
297 if (fvaBorrowingCurve_ != "")
298 borrowingCurve = market_->yieldCurve(fvaBorrowingCurve_, configuration_);
299 if (fvaLendingCurve_ != "")
300 lendingCurve = market_->yieldCurve(fvaLendingCurve_, configuration_);
301
302 if (!borrowingCurve.empty() || !lendingCurve.empty()) {
303 QL_REQUIRE(baseCurrency_ != "", "baseCurrency required for FVA calculation");
304 }
305 string nid = trade->envelope().nettingSetId();
306 Real cvaRR = market_->recoveryRate(cid, configuration_)->value();
307 Real dvaRR = 0.0;
308 if (dvaName_ != "")
309 dvaRR = market_->recoveryRate(dvaName_, configuration_)->value();
310
311 tradeCva_[tid] = 0.0;
312 tradeDva_[tid] = 0.0;
313 tradeFca_[tid] = 0.0;
314 tradeFca_exOwnSp_[tid] = 0.0;
315 tradeFca_exAllSp_[tid] = 0.0;
316 tradeFba_[tid] = 0.0;
317 tradeFba_exOwnSp_[tid] = 0.0;
318 tradeFba_exAllSp_[tid] = 0.0;
319 tradeMva_[tid] = 0.0;
320 for (Size j = 0; j < numDates; ++j) {
321
322 // CVA / DVA
323 Date d0 = j == 0 ? today : dates()[j - 1];
324 Date d1 = dates()[j];
325 Real cvaIncrement = calculateCvaIncrement(tid, cid, d0, d1, cvaRR);
326 Real dvaIncrement = dvaName_ != "" ? calculateDvaIncrement(tid, d0, d1, dvaRR) : 0;
327 tradeCva_[tid] += cvaIncrement;
328 tradeDva_[tid] += dvaIncrement;
329
330 // FCA
331 if (!borrowingCurve.empty()) {
332 Real dcf = borrowingCurve->discount(d0) / borrowingCurve->discount(d1) -
333 oisCurve->discount(d0) / oisCurve->discount(d1);
334 Real fcaIncrement = calculateFcaIncrement(tid, cid, dvaName_, d0, d1, dcf);
335 Real fcaIncrement_exOwnSP = calculateFcaIncrement(tid, cid, "", d0, d1, dcf);
336 Real fcaIncrement_exAllSP = calculateFcaIncrement(tid, "", "", d0, d1, dcf);
337 tradeFca_[tid] += fcaIncrement;
338 tradeFca_exOwnSp_[tid] += fcaIncrement_exOwnSP;
339 tradeFca_exAllSp_[tid] += fcaIncrement_exAllSP;
340 }
341
342 // FBA
343 if (!lendingCurve.empty()) {
344 Real dcf = lendingCurve->discount(d0) / lendingCurve->discount(d1) -
345 oisCurve->discount(d0) / oisCurve->discount(d1);
346 Real fbaIncrement = calculateFbaIncrement(tid, cid, dvaName_, d0, d1, dcf);
347 Real fbaIncrement_exOwnSP = calculateFbaIncrement(tid, cid, "", d0, d1, dcf);
348 Real fbaIncrement_exAllSP = calculateFbaIncrement(tid, "", "", d0, d1, dcf);
349 tradeFba_[tid] += fbaIncrement;
350 tradeFba_exOwnSp_[tid] += fbaIncrement_exOwnSP;
351 tradeFba_exAllSp_[tid] += fbaIncrement_exAllSP;
352 }
353 }
354 if (nettingSetSumCva_.find(nid) == nettingSetSumCva_.end()) {
355 nettingSetSumCva_[nid] = 0.0;
356 nettingSetSumDva_[nid] = 0.0;
357 }
358 nettingSetSumCva_[nid] += tradeCva_[tid];
359 nettingSetSumDva_[nid] += tradeDva_[tid];
360 } catch (const std::exception& e) {
361 StructuredAnalyticsErrorMessage("ValueAdjustmentCalculator", "Error processing trade.", e.what(),
362 {{"tradeId", tid}})
363 .log();
364 }
365 }
366
367 // Netting Set XVA
368 for (const auto& pair : nettingSetCpty_) {
369 string nid = pair.first;
370 LOG("Update XVA for netting set "
371 << nid << (flipViewXVA_ ? ", inverted (flipViewXVA = Y)" : ", regular (flipViewXVA = N)"));
372 try {
373 string cid;
374 if (flipViewXVA_) {
375 cid = origDvaName;
376 dvaName_ = pair.second;
379 } else {
380 cid = pair.second;
381 }
382 Real cvaRR = market_->recoveryRate(cid, configuration_)->value();
383 Real dvaRR = 0.0;
384 if (dvaName_ != "") {
385 dvaRR = market_->recoveryRate(dvaName_, configuration_)->value();
386 }
387 if (fvaBorrowingCurve_ != "")
388 borrowingCurve = market_->yieldCurve(fvaBorrowingCurve_, configuration_);
389 if (fvaLendingCurve_ != "")
390 lendingCurve = market_->yieldCurve(fvaLendingCurve_, configuration_);
391
392 if (!borrowingCurve.empty() || !lendingCurve.empty()) {
393 QL_REQUIRE(baseCurrency_ != "", "baseCurrency required for FVA calculation");
394 }
395
396 nettingSetCva_[nid] = 0.0;
397 nettingSetDva_[nid] = 0.0;
398 nettingSetFca_[nid] = 0.0;
399 nettingSetFca_exOwnSp_[nid] = 0.0;
400 nettingSetFca_exAllSp_[nid] = 0.0;
401 nettingSetFba_[nid] = 0.0;
402 nettingSetFba_exOwnSp_[nid] = 0.0;
403 nettingSetFba_exAllSp_[nid] = 0.0;
404 nettingSetMva_[nid] = 0.0;
405 for (Size j = 0; j < numDates; ++j) {
406 // CVA / DVA
407 Date d0 = j == 0 ? today : dates()[j - 1];
408 Date d1 = dates()[j];
409 Real cvaIncrement = calculateNettingSetCvaIncrement(nid, cid, d0, d1, cvaRR);
410 Real dvaIncrement = dvaName_ != "" ? calculateNettingSetDvaIncrement(nid, d0, d1, dvaRR) : 0;
411 nettingSetCva_[nid] += cvaIncrement;
412 nettingSetDva_[nid] += dvaIncrement;
413
414 // FCA
415 if (!borrowingCurve.empty()) {
416 Real dcf = borrowingCurve->discount(d0) / borrowingCurve->discount(d1) -
417 oisCurve->discount(d0) / oisCurve->discount(d1);
418 Real fcaIncrement = calculateNettingSetFcaIncrement(nid, cid, dvaName_, d0, d1, dcf);
419 Real fcaIncrement_exOwnSP = calculateNettingSetFcaIncrement(nid, cid, "", d0, d1, dcf);
420 Real fcaIncrement_exAllSP = calculateNettingSetFcaIncrement(nid, "", "", d0, d1, dcf);
421 nettingSetFca_[nid] += fcaIncrement;
422 nettingSetFca_exOwnSp_[nid] += fcaIncrement_exOwnSP;
423 nettingSetFca_exAllSp_[nid] += fcaIncrement_exAllSP;
424
425 // MVA
426 if (dimCalculator_) {
427 Real mvaIncrement = calculateNettingSetMvaIncrement(nid, cid, d0, d1, dcf);
428 nettingSetMva_[nid] += mvaIncrement;
429 }
430 }
431
432 // FBA
433 if (!lendingCurve.empty()) {
434 Real dcf = lendingCurve->discount(d0) / lendingCurve->discount(d1) -
435 oisCurve->discount(d0) / oisCurve->discount(d1);
436 Real fbaIncrement = calculateNettingSetFbaIncrement(nid, cid, dvaName_, d0, d1, dcf);
437 Real fbaIncrement_exOwnSP = calculateNettingSetFbaIncrement(nid, cid, "", d0, d1, dcf);
438 Real fbaIncrement_exAllSP = calculateNettingSetFbaIncrement(nid, "", "", d0, d1, dcf);
439 nettingSetFba_[nid] += fbaIncrement;
440 nettingSetFba_exOwnSp_[nid] += fbaIncrement_exOwnSP;
441 nettingSetFba_exAllSp_[nid] += fbaIncrement_exAllSP;
442 }
443 }
444 } catch (const std::exception& e) {
445 StructuredAnalyticsErrorMessage("ValueAdjustmentCalculator", "Error processing netting set.", e.what(),
446 {{"nettingSetId", nid}})
447 .log();
448 }
449 }
450}
virtual const Real calculateNettingSetCvaIncrement(const string &nid, const string &cid, const Date &d0, const Date &d1, const Real &rr)=0
virtual const Real calculateFcaIncrement(const string &tid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
virtual const Real calculateDvaIncrement(const string &tid, const Date &d0, const Date &d1, const Real &rr)=0
virtual const Real calculateNettingSetDvaIncrement(const string &nid, const Date &d0, const Date &d1, const Real &rr)=0
virtual const Real calculateNettingSetFcaIncrement(const string &nid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
virtual const Real calculateFbaIncrement(const string &tid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
virtual const vector< Date > & dates()
virtual const Real calculateCvaIncrement(const string &tid, const string &cid, const Date &d0, const Date &d1, const Real &rr)=0
virtual const Real calculateNettingSetFbaIncrement(const string &nid, const string &cid, const string &dvaName, const Date &d0, const Date &d1, const Real &dcf)=0
virtual const Real calculateNettingSetMvaIncrement(const string &nid, const string &cid, const Date &d0, const Date &d1, const Real &dcf)=0
#define LOG(text)
RandomVariable log(RandomVariable x)
+ Here is the call graph for this function:

◆ dates()

virtual const vector< Date > & dates ( )
virtual

Definition at line 94 of file xvacalculator.hpp.

94{ return tradeExposureCube_->dates(); };
+ Here is the caller graph for this function:

◆ asof()

virtual const Date asof ( )
virtual

Definition at line 96 of file xvacalculator.hpp.

96{ return market_->asofDate(); };
+ Here is the caller graph for this function:

◆ calculateCvaIncrement()

virtual const Real calculateCvaIncrement ( const string &  tid,
const string &  cid,
const Date &  d0,
const Date &  d1,
const Real &  rr 
)
pure virtual

Implemented in DynamicCreditXvaCalculator, and StaticCreditXvaCalculator.

+ Here is the caller graph for this function:

◆ calculateDvaIncrement()

virtual const Real calculateDvaIncrement ( const string &  tid,
const Date &  d0,
const Date &  d1,
const Real &  rr 
)
pure virtual

Implemented in DynamicCreditXvaCalculator, and StaticCreditXvaCalculator.

+ Here is the caller graph for this function:

◆ calculateNettingSetCvaIncrement()

virtual const Real calculateNettingSetCvaIncrement ( const string &  nid,
const string &  cid,
const Date &  d0,
const Date &  d1,
const Real &  rr 
)
pure virtual

◆ calculateNettingSetDvaIncrement()

virtual const Real calculateNettingSetDvaIncrement ( const string &  nid,
const Date &  d0,
const Date &  d1,
const Real &  rr 
)
pure virtual

◆ calculateFbaIncrement()

virtual const Real calculateFbaIncrement ( const string &  tid,
const string &  cid,
const string &  dvaName,
const Date &  d0,
const Date &  d1,
const Real &  dcf 
)
pure virtual

Implemented in DynamicCreditXvaCalculator, and StaticCreditXvaCalculator.

+ Here is the caller graph for this function:

◆ calculateFcaIncrement()

virtual const Real calculateFcaIncrement ( const string &  tid,
const string &  cid,
const string &  dvaName,
const Date &  d0,
const Date &  d1,
const Real &  dcf 
)
pure virtual

Implemented in DynamicCreditXvaCalculator, and StaticCreditXvaCalculator.

+ Here is the caller graph for this function:

◆ calculateNettingSetFbaIncrement()

virtual const Real calculateNettingSetFbaIncrement ( const string &  nid,
const string &  cid,
const string &  dvaName,
const Date &  d0,
const Date &  d1,
const Real &  dcf 
)
pure virtual

◆ calculateNettingSetFcaIncrement()

virtual const Real calculateNettingSetFcaIncrement ( const string &  nid,
const string &  cid,
const string &  dvaName,
const Date &  d0,
const Date &  d1,
const Real &  dcf 
)
pure virtual

◆ calculateNettingSetMvaIncrement()

virtual const Real calculateNettingSetMvaIncrement ( const string &  nid,
const string &  cid,
const Date &  d0,
const Date &  d1,
const Real &  dcf 
)
pure virtual

◆ tradeCva() [1/2]

const map< string, Real > & tradeCva ( )

CVA map for all the trades.

Definition at line 109 of file xvacalculator.cpp.

109 {
110 return tradeCva_;
111}

◆ tradeDva() [1/2]

const map< string, Real > & tradeDva ( )

DVA map for all the trades.

Definition at line 113 of file xvacalculator.cpp.

113 {
114 return tradeDva_;
115}

◆ nettingSetCva() [1/2]

const map< string, Real > & nettingSetCva ( )

CVA map for all the netting sets.

Definition at line 117 of file xvacalculator.cpp.

117 {
118 return nettingSetCva_;
119}

◆ nettingSetDva() [1/2]

const map< string, Real > & nettingSetDva ( )

DVA map for all the netting sets.

Definition at line 121 of file xvacalculator.cpp.

121 {
122 return nettingSetDva_;
123}

◆ nettingSetSumCva() [1/2]

const map< string, Real > & nettingSetSumCva ( )

Sum CVA map for all the netting sets.

Definition at line 125 of file xvacalculator.cpp.

125 {
126 return nettingSetSumCva_;
127}

◆ nettingSetSumDva() [1/2]

const map< string, Real > & nettingSetSumDva ( )

Sum DVA map for all the netting sets.

Definition at line 129 of file xvacalculator.cpp.

129 {
130 return nettingSetSumDva_;
131}

◆ tradeCva() [2/2]

const Real & tradeCva ( const string &  trade)

CVA for the specified trade.

Definition at line 133 of file xvacalculator.cpp.

133 {
134 if (tradeCva_.find(trade) != tradeCva_.end())
135 return tradeCva_[trade];
136 else
137 QL_FAIL("trade " << trade << " not found in expected CVA results");
138}

◆ tradeDva() [2/2]

const Real & tradeDva ( const string &  trade)

DVA for the specified trade.

Definition at line 140 of file xvacalculator.cpp.

140 {
141 if (tradeDva_.find(trade) != tradeDva_.end())
142 return tradeDva_[trade];
143 else
144 QL_FAIL("trade " << trade << " not found in expected DVA results");
145}

◆ tradeFba()

const Real & tradeFba ( const string &  trade)

FBA for the specified trade.

Definition at line 147 of file xvacalculator.cpp.

147 {
148 if (tradeFba_.find(trade) != tradeFba_.end())
149 return tradeFba_[trade];
150 else
151 QL_FAIL("trade " << trade << " not found in expected FBA results");
152}

◆ tradeFba_exOwnSp()

const Real & tradeFba_exOwnSp ( const string &  trade)

FBA (excl own survival probability) for the specified trade.

Definition at line 154 of file xvacalculator.cpp.

154 {
155 if (tradeFba_exOwnSp_.find(trade) != tradeFba_exOwnSp_.end())
156 return tradeFba_exOwnSp_[trade];
157 else
158 QL_FAIL("trade " << trade << " not found in expected FBA ex own sp results");
159}

◆ tradeFba_exAllSp()

const Real & tradeFba_exAllSp ( const string &  trade)

FBA (excl all survival probability) for the specified trade.

Definition at line 161 of file xvacalculator.cpp.

161 {
162 if (tradeFba_exAllSp_.find(trade) != tradeFba_exAllSp_.end())
163 return tradeFba_exAllSp_[trade];
164 else
165 QL_FAIL("trade " << trade << " not found in expected FBA ex all sp results");
166}

◆ tradeFca()

const Real & tradeFca ( const string &  trade)

FCA for the specified trade.

Definition at line 168 of file xvacalculator.cpp.

168 {
169 if (tradeFca_.find(trade) != tradeFca_.end())
170 return tradeFca_[trade];
171 else
172 QL_FAIL("trade " << trade << " not found in expected FCA results");
173}

◆ tradeFca_exOwnSp()

const Real & tradeFca_exOwnSp ( const string &  trade)

FCA (excl own survival probability) for the specified trade.

Definition at line 175 of file xvacalculator.cpp.

175 {
176 if (tradeFca_exOwnSp_.find(trade) != tradeFca_exOwnSp_.end())
177 return tradeFca_exOwnSp_[trade];
178 else
179 QL_FAIL("trade " << trade << " not found in expected FCA ex own sp results");
180}

◆ tradeFca_exAllSp()

const Real & tradeFca_exAllSp ( const string &  trade)

FCA (excl all survival probability) for the specified trade.

Definition at line 182 of file xvacalculator.cpp.

182 {
183 if (tradeFca_exAllSp_.find(trade) != tradeFca_exAllSp_.end())
184 return tradeFca_exAllSp_[trade];
185 else
186 QL_FAIL("trade " << trade << " not found in expected FCA ex all sp results");
187}

◆ tradeMva()

const Real & tradeMva ( const string &  trade)

MVA for the specified trade.

Definition at line 189 of file xvacalculator.cpp.

189 {
190 if (tradeMva_.find(trade) != tradeMva_.end())
191 return tradeMva_[trade];
192 else
193 QL_FAIL("trade " << trade << " not found in expected MVA results");
194}

◆ nettingSetSumCva() [2/2]

const Real & nettingSetSumCva ( const string &  nettingSet)

Sum of trades' CVA for the specified netting set.

Definition at line 196 of file xvacalculator.cpp.

196 {
197 if (nettingSetSumCva_.find(nettingSet) != nettingSetSumCva_.end())
198 return nettingSetSumCva_[nettingSet];
199 else
200 QL_FAIL("netting set " << nettingSet << " not found in expected CVA results");
201}

◆ nettingSetSumDva() [2/2]

const Real & nettingSetSumDva ( const string &  nettingSet)

Sum of trades' DVA for the specified netting set.

Definition at line 203 of file xvacalculator.cpp.

203 {
204 if (nettingSetSumDva_.find(nettingSet) != nettingSetSumDva_.end())
205 return nettingSetSumDva_[nettingSet];
206 else
207 QL_FAIL("netting set " << nettingSet << " not found in expected DVA results");
208}

◆ nettingSetCva() [2/2]

const Real & nettingSetCva ( const string &  nettingSet)

CVA for the specified netting set.

Definition at line 210 of file xvacalculator.cpp.

210 {
211 if (nettingSetCva_.find(nettingSet) != nettingSetCva_.end())
212 return nettingSetCva_[nettingSet];
213 else
214 QL_FAIL("netting set " << nettingSet << " not found in expected CVA results");
215}

◆ nettingSetDva() [2/2]

const Real & nettingSetDva ( const string &  nettingSet)

DVA for the specified netting set.

Definition at line 217 of file xvacalculator.cpp.

217 {
218 if (nettingSetDva_.find(nettingSet) != nettingSetDva_.end())
219 return nettingSetDva_[nettingSet];
220 else
221 QL_FAIL("netting set " << nettingSet << " not found in expected DVA results");
222}

◆ nettingSetFba()

const Real & nettingSetFba ( const string &  nettingSet)

FBA for the specified netting set.

Definition at line 224 of file xvacalculator.cpp.

224 {
225 if (nettingSetFba_.find(nettingSet) != nettingSetFba_.end())
226 return nettingSetFba_[nettingSet];
227 else
228 QL_FAIL("netting set " << nettingSet << " not found in expected FBA results");
229}

◆ nettingSetFba_exOwnSp()

const Real & nettingSetFba_exOwnSp ( const string &  nettingSet)

FBA (excl own survival probability) for the specified netting set.

Definition at line 231 of file xvacalculator.cpp.

231 {
232 if (nettingSetFba_exOwnSp_.find(nettingSet) != nettingSetFba_exOwnSp_.end())
233 return nettingSetFba_exOwnSp_[nettingSet];
234 else
235 QL_FAIL("netting set " << nettingSet << " not found in expected FBA ex own sp results");
236}

◆ nettingSetFba_exAllSp()

const Real & nettingSetFba_exAllSp ( const string &  nettingSet)

FBA (excl all survival probability) for the specified netting set.

Definition at line 238 of file xvacalculator.cpp.

238 {
239 if (nettingSetFba_exAllSp_.find(nettingSet) != nettingSetFba_exAllSp_.end())
240 return nettingSetFba_exAllSp_[nettingSet];
241 else
242 QL_FAIL("netting set " << nettingSet << " not found in expected FBA ex all sp results");
243}

◆ nettingSetFca()

const Real & nettingSetFca ( const string &  nettingSet)

FCA for the specified netting set.

Definition at line 245 of file xvacalculator.cpp.

245 {
246 if (nettingSetFca_.find(nettingSet) != nettingSetFca_.end())
247 return nettingSetFca_[nettingSet];
248 else
249 QL_FAIL("netting set " << nettingSet << " not found in expected FBA results");
250}

◆ nettingSetFca_exOwnSp()

const Real & nettingSetFca_exOwnSp ( const string &  nettingSet)

FCA (excl own survival probability) for the specified netting set.

Definition at line 252 of file xvacalculator.cpp.

252 {
253 if (nettingSetFca_exOwnSp_.find(nettingSet) != nettingSetFca_exOwnSp_.end())
254 return nettingSetFca_exOwnSp_[nettingSet];
255 else
256 QL_FAIL("netting set " << nettingSet << " not found in expected FBA ex own sp results");
257}

◆ nettingSetFca_exAllSp()

const Real & nettingSetFca_exAllSp ( const string &  nettingSet)

FCA (excl all survival probability) for the specified netting set.

Definition at line 259 of file xvacalculator.cpp.

259 {
260 if (nettingSetFca_exAllSp_.find(nettingSet) != nettingSetFca_exAllSp_.end())
261 return nettingSetFca_exAllSp_[nettingSet];
262 else
263 QL_FAIL("netting set " << nettingSet << " not found in expected FBA ex all sp results");
264}

◆ nettingSetMva()

const Real & nettingSetMva ( const string &  nettingSet)

MVA for the specified netting set.

Definition at line 266 of file xvacalculator.cpp.

266 {
267 if (nettingSetMva_.find(nettingSet) != nettingSetMva_.end())
268 return nettingSetMva_[nettingSet];
269 else
270 QL_FAIL("netting set " << nettingSet << " not found in expected MVA results");
271}

Member Data Documentation

◆ portfolio_

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

Definition at line 196 of file xvacalculator.hpp.

◆ market_

QuantLib::ext::shared_ptr<Market> market_
protected

Definition at line 197 of file xvacalculator.hpp.

◆ configuration_

string configuration_
protected

Definition at line 198 of file xvacalculator.hpp.

◆ baseCurrency_

string baseCurrency_
protected

Definition at line 199 of file xvacalculator.hpp.

◆ dvaName_

string dvaName_
protected

Definition at line 200 of file xvacalculator.hpp.

◆ fvaBorrowingCurve_

string fvaBorrowingCurve_
protected

Definition at line 201 of file xvacalculator.hpp.

◆ fvaLendingCurve_

string fvaLendingCurve_
protected

Definition at line 202 of file xvacalculator.hpp.

◆ applyDynamicInitialMargin_

bool applyDynamicInitialMargin_
protected

Definition at line 203 of file xvacalculator.hpp.

◆ dimCalculator_

QuantLib::ext::shared_ptr<DynamicInitialMarginCalculator> dimCalculator_
protected

Definition at line 204 of file xvacalculator.hpp.

◆ tradeExposureCube_

const QuantLib::ext::shared_ptr<NPVCube> tradeExposureCube_
protected

Definition at line 205 of file xvacalculator.hpp.

◆ nettingSetExposureCube_

const QuantLib::ext::shared_ptr<NPVCube> nettingSetExposureCube_
protected

Definition at line 206 of file xvacalculator.hpp.

◆ tradeEpeIndex_

Size tradeEpeIndex_
protected

Definition at line 207 of file xvacalculator.hpp.

◆ tradeEneIndex_

Size tradeEneIndex_
protected

Definition at line 208 of file xvacalculator.hpp.

◆ nettingSetEpeIndex_

Size nettingSetEpeIndex_
protected

Definition at line 209 of file xvacalculator.hpp.

◆ nettingSetEneIndex_

Size nettingSetEneIndex_
protected

Definition at line 210 of file xvacalculator.hpp.

◆ flipViewXVA_

bool flipViewXVA_
protected

Definition at line 211 of file xvacalculator.hpp.

◆ flipViewBorrowingCurvePostfix_

string flipViewBorrowingCurvePostfix_
protected

Definition at line 212 of file xvacalculator.hpp.

◆ flipViewLendingCurvePostfix_

string flipViewLendingCurvePostfix_
protected

Definition at line 213 of file xvacalculator.hpp.

◆ nettingSetCpty_

map<string, string> nettingSetCpty_
protected

Definition at line 215 of file xvacalculator.hpp.

◆ tradeCva_

map<string, Real> tradeCva_
protected

Definition at line 217 of file xvacalculator.hpp.

◆ tradeDva_

map<string, Real> tradeDva_
protected

Definition at line 218 of file xvacalculator.hpp.

◆ tradeFba_

map<string, Real> tradeFba_
protected

Definition at line 219 of file xvacalculator.hpp.

◆ tradeFba_exOwnSp_

map<string, Real> tradeFba_exOwnSp_
protected

Definition at line 220 of file xvacalculator.hpp.

◆ tradeFba_exAllSp_

map<string, Real> tradeFba_exAllSp_
protected

Definition at line 221 of file xvacalculator.hpp.

◆ tradeFca_

map<string, Real> tradeFca_
protected

Definition at line 222 of file xvacalculator.hpp.

◆ tradeFca_exOwnSp_

map<string, Real> tradeFca_exOwnSp_
protected

Definition at line 223 of file xvacalculator.hpp.

◆ tradeFca_exAllSp_

map<string, Real> tradeFca_exAllSp_
protected

Definition at line 224 of file xvacalculator.hpp.

◆ tradeMva_

map<string, Real> tradeMva_
protected

Definition at line 225 of file xvacalculator.hpp.

◆ nettingSetSumCva_

map<string, Real> nettingSetSumCva_
protected

Definition at line 228 of file xvacalculator.hpp.

◆ nettingSetSumDva_

map<string, Real> nettingSetSumDva_
protected

Definition at line 229 of file xvacalculator.hpp.

◆ nettingSetCva_

map<string, Real> nettingSetCva_
protected

Definition at line 230 of file xvacalculator.hpp.

◆ nettingSetDva_

map<string, Real> nettingSetDva_
protected

Definition at line 231 of file xvacalculator.hpp.

◆ nettingSetFba_

map<string, Real> nettingSetFba_
protected

Definition at line 232 of file xvacalculator.hpp.

◆ nettingSetFba_exOwnSp_

map<string, Real> nettingSetFba_exOwnSp_
protected

Definition at line 233 of file xvacalculator.hpp.

◆ nettingSetFba_exAllSp_

map<string, Real> nettingSetFba_exAllSp_
protected

Definition at line 234 of file xvacalculator.hpp.

◆ nettingSetFca_

map<string, Real> nettingSetFca_
protected

Definition at line 235 of file xvacalculator.hpp.

◆ nettingSetFca_exOwnSp_

map<string, Real> nettingSetFca_exOwnSp_
protected

Definition at line 236 of file xvacalculator.hpp.

◆ nettingSetFca_exAllSp_

map<string, Real> nettingSetFca_exAllSp_
protected

Definition at line 237 of file xvacalculator.hpp.

◆ nettingSetMva_

map<string, Real> nettingSetMva_
protected

Definition at line 238 of file xvacalculator.hpp.