21#include <ql/errors.hpp>
27 const QuantLib::Handle<AggregationScenarioData>& aggregationScenarioData,
28 const QuantLib::ext::shared_ptr<DateGrid>& dateGrid,
const Size storeCreditStateNPVs,
29 const bool flipViewXVA)
30 : storeFlows_(storeFlows), withCloseOutLag_(withCloseOutLag), aggregationScenarioData_(aggregationScenarioData),
31 dateGrid_(dateGrid), storeCreditStateNPVs_(storeCreditStateNPVs), flipViewXVA_(flipViewXVA) {
40 QL_REQUIRE(
dateGrid_ !=
nullptr,
"CubeInterpretation: dateGrid is required when withCloseOutLag is true");
76 Size sampleIdx, Size depth)
const {
78 return -cube->get(tradeIdx, dateIdx, sampleIdx, depth);
80 return cube->get(tradeIdx, dateIdx, sampleIdx, depth);
85 Size sampleIdx)
const {
90 Size sampleIdx)
const {
99 Size sampleIdx)
const {
102 Real aggMporFlowsVal = 0.0;
105 }
catch (std::exception& e) {
106 DLOG(
"Unable to retrieve MPOR flows for trade " << tradeIdx <<
", date " << dateIdx <<
", sample " << sampleIdx
107 <<
"; " << e.what());
109 return aggMporFlowsVal;
113 Size sampleIdx)
const {
116 Real aggMporFlowsVal = 0.0;
119 }
catch (std::exception& e) {
120 DLOG(
"Unable to retrieve MPOR flows for trade " << tradeIdx <<
", date " << dateIdx <<
", sample " << sampleIdx
121 <<
"; " << e.what());
123 return aggMporFlowsVal;
127 Size sampleIdx)
const {
132 Size sampleIdx,
const std::string& qualifier)
const {
134 "CubeInterpretation::getDefaultAggregationScenarioData(): no aggregation scenario data given");
139 Size sampleIdx,
const std::string& qualifier)
const {
142 "close out aggr scen data only available for numeraire");
147 "aggregation scenario data given");
154 QuantLib::Date dd =
dateGrid_->valuationDates()[dateIdx];
155 QuantLib::Date cd =
dateGrid_->closeOutDates()[dateIdx];
156 QL_REQUIRE(cd > dd,
"close-out date (" << cd <<
") must be greater than default date (" << dd <<
") at index "
160 return cube->dates()[dateIdx + 1] - cube->dates()[dateIdx];
Real getMporFlows(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx) const
Retrieve the aggregate value of Margin Period of Risk cashflows from the Cube.
Size getMporCalendarDays(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size dateIdx) const
Number of Calendar Days between a given default date and corresponding close-out date.
Size storeCreditStateNPVs_
Size mporFlowsIndex() const
const QuantLib::ext::shared_ptr< DateGrid > & dateGrid() const
Size defaultDateNpvIndex() const
indices in depth direction, might be Null<Size>() if not applicable
const QuantLib::Handle< AggregationScenarioData > & aggregationScenarioData() const
Real getMporPositiveFlows(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx) const
Retrieve the aggregate value of Margin Period of Risk positive cashflows from the Cube.
Real getDefaultAggregationScenarioData(const AggregationScenarioDataType &dataType, Size dateIdx, Size sampleIdx, const std::string &qualifier="") const
Retrieve a (default date) simulated risk factor value from AggregationScenarioData.
Size closeOutDateNpvIndex_
Real getCloseOutAggregationScenarioData(const AggregationScenarioDataType &dataType, Size dateIdx, Size sampleIdx, const std::string &qualifier="") const
Retrieve a (default date) simulated risk factor value from AggregationScenarioData.
Size creditStateNPVsIndex_
Real getDefaultNpv(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx) const
Retrieve the default date NPV from the Cube.
bool storeFlows() const
inspectors
Real getMporNegativeFlows(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx) const
Retrieve the aggregate value of Margin Period of Risk negative cashflows from the Cube.
CubeInterpretation(const bool storeFlows, const bool withCloseOutLag, const QuantLib::Handle< AggregationScenarioData > &aggregationScenarioData=QuantLib::Handle< AggregationScenarioData >(), const QuantLib::ext::shared_ptr< DateGrid > &dateGrid=nullptr, const Size storeCreditStateNPVs=0, const bool flipViewXVA=false)
Size closeOutDateNpvIndex() const
Real getCloseOutNpv(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx) const
Retrieve the close-out date NPV from the Cube.
QuantLib::ext::shared_ptr< DateGrid > dateGrid_
Size requiredNpvCubeDepth() const
npv cube depth that is at least required to work with this interpretation
Size creditStateNPVsIndex() const
QuantLib::Handle< AggregationScenarioData > aggregationScenarioData_
bool withCloseOutLag() const
Size storeCreditStateNPVs() const
Size defaultDateNpvIndex_
Real getGenericValue(const QuantLib::ext::shared_ptr< NPVCube > &cube, Size tradeIdx, Size dateIdx, Size sampleIdx, Size depth) const
Retrieve an arbitrary value from the Cube (user needs to know the precise location within depth axis)
class describing the layout of an npv cube and aggregation scenario data
AggregationScenarioDataType