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

Exposure allocator base class. More...

#include <orea/aggregation/exposureallocator.hpp>

+ Inheritance diagram for ExposureAllocator:
+ Collaboration diagram for ExposureAllocator:

Public Types

enum class  AllocationMethod {
  None , Marginal , RelativeFairValueGross , RelativeFairValueNet ,
  RelativeXVA
}
 

Public Member Functions

 ExposureAllocator (const QuantLib::ext::shared_ptr< Portfolio > &portfolio, const QuantLib::ext::shared_ptr< NPVCube > &tradeExposureCube, const QuantLib::ext::shared_ptr< NPVCube > &nettedExposureCube, const Size allocatedTradeEpeIndex=2, const Size allocatedTradeEneIndex=3, const Size tradeEpeIndex=0, const Size tradeEneIndex=1, const Size nettingSetEpeIndex=1, const Size nettingSetEneIndex=2)
 
virtual ~ExposureAllocator ()
 
const QuantLib::ext::shared_ptr< NPVCube > & exposureCube ()
 
virtual void build ()
 Compute exposures along all paths and fill result structures. More...
 

Protected Member Functions

virtual Real calculateAllocatedEpe (const string &tid, const string &nid, const Date &date, const Size sample)=0
 
virtual Real calculateAllocatedEne (const string &tid, const string &nid, const Date &date, const Size sample)=0
 

Protected Attributes

QuantLib::ext::shared_ptr< Portfolioportfolio_
 
QuantLib::ext::shared_ptr< NPVCubetradeExposureCube_
 
QuantLib::ext::shared_ptr< NPVCubenettedExposureCube_
 
Size tradeEpeIndex_
 
Size tradeEneIndex_
 
Size allocatedTradeEpeIndex_
 
Size allocatedTradeEneIndex_
 
Size nettingSetEpeIndex_
 
Size nettingSetEneIndex_
 
map< string, Real > nettingSetValueToday_
 
map< string, Real > nettingSetPositiveValueToday_
 
map< string, Real > nettingSetNegativeValueToday_
 

Detailed Description

Exposure allocator 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 42 of file exposureallocator.hpp.

Member Enumeration Documentation

◆ AllocationMethod

enum class AllocationMethod
strong

Constructor & Destructor Documentation

◆ ExposureAllocator()

ExposureAllocator ( const QuantLib::ext::shared_ptr< Portfolio > &  portfolio,
const QuantLib::ext::shared_ptr< NPVCube > &  tradeExposureCube,
const QuantLib::ext::shared_ptr< NPVCube > &  nettedExposureCube,
const Size  allocatedTradeEpeIndex = 2,
const Size  allocatedTradeEneIndex = 3,
const Size  tradeEpeIndex = 0,
const Size  tradeEneIndex = 1,
const Size  nettingSetEpeIndex = 1,
const Size  nettingSetEneIndex = 2 
)

Definition at line 30 of file exposureallocator.cpp.

37 : portfolio_(portfolio), tradeExposureCube_(tradeExposureCube),
38 nettedExposureCube_(nettedExposureCube),
39 tradeEpeIndex_(tradeEpeIndex), tradeEneIndex_(tradeEneIndex),
40 allocatedTradeEpeIndex_(allocatedTradeEpeIndex), allocatedTradeEneIndex_(allocatedTradeEneIndex),
41 nettingSetEpeIndex_(nettingSetEpeIndex), nettingSetEneIndex_(nettingSetEneIndex) {}
QuantLib::ext::shared_ptr< NPVCube > tradeExposureCube_
QuantLib::ext::shared_ptr< NPVCube > nettedExposureCube_
QuantLib::ext::shared_ptr< Portfolio > portfolio_

◆ ~ExposureAllocator()

virtual ~ExposureAllocator ( )
virtual

Definition at line 61 of file exposureallocator.hpp.

61{}

Member Function Documentation

◆ exposureCube()

const QuantLib::ext::shared_ptr< NPVCube > & exposureCube ( )

Definition at line 62 of file exposureallocator.hpp.

62{ return tradeExposureCube_; }

◆ build()

void build ( )
virtual

Compute exposures along all paths and fill result structures.

Definition at line 43 of file exposureallocator.cpp.

43 {
44 LOG("Compute allocated trade exposures");
45
46 for (const auto& [nettingSetId, idx] : nettedExposureCube_->idsAndIndexes()) {
47
48 for (const auto & [tid, trade] : portfolio_->trades()) {
49 string nid = trade->envelope().nettingSetId();
50 if (nid != nettingSetId)
51 continue;
52
53
54 for (Date date : tradeExposureCube_->dates()) {
55 for (Size k = 0; k < tradeExposureCube_->samples(); ++k) {
56 tradeExposureCube_->set(calculateAllocatedEpe(tid, nid, date, k),
57 tid, date, k, allocatedTradeEpeIndex_);
58 tradeExposureCube_->set(calculateAllocatedEne(tid, nid, date, k),
59 tid, date, k, allocatedTradeEneIndex_);
60 }
61 }
62 }
63 }
64 LOG("Completed calculating allocated trade exposures");
65}
virtual Real calculateAllocatedEpe(const string &tid, const string &nid, const Date &date, const Size sample)=0
virtual Real calculateAllocatedEne(const string &tid, const string &nid, const Date &date, const Size sample)=0
#define LOG(text)
+ Here is the call graph for this function:

◆ calculateAllocatedEpe()

virtual Real calculateAllocatedEpe ( const string &  tid,
const string &  nid,
const Date &  date,
const Size  sample 
)
protectedpure virtual

◆ calculateAllocatedEne()

virtual Real calculateAllocatedEne ( const string &  tid,
const string &  nid,
const Date &  date,
const Size  sample 
)
protectedpure virtual

Member Data Documentation

◆ portfolio_

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

Definition at line 70 of file exposureallocator.hpp.

◆ tradeExposureCube_

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

Definition at line 71 of file exposureallocator.hpp.

◆ nettedExposureCube_

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

Definition at line 72 of file exposureallocator.hpp.

◆ tradeEpeIndex_

Size tradeEpeIndex_
protected

Definition at line 73 of file exposureallocator.hpp.

◆ tradeEneIndex_

Size tradeEneIndex_
protected

Definition at line 74 of file exposureallocator.hpp.

◆ allocatedTradeEpeIndex_

Size allocatedTradeEpeIndex_
protected

Definition at line 75 of file exposureallocator.hpp.

◆ allocatedTradeEneIndex_

Size allocatedTradeEneIndex_
protected

Definition at line 76 of file exposureallocator.hpp.

◆ nettingSetEpeIndex_

Size nettingSetEpeIndex_
protected

Definition at line 77 of file exposureallocator.hpp.

◆ nettingSetEneIndex_

Size nettingSetEneIndex_
protected

Definition at line 78 of file exposureallocator.hpp.

◆ nettingSetValueToday_

map<string, Real> nettingSetValueToday_
protected

Definition at line 79 of file exposureallocator.hpp.

◆ nettingSetPositiveValueToday_

map<string, Real> nettingSetPositiveValueToday_
protected

Definition at line 79 of file exposureallocator.hpp.

◆ nettingSetNegativeValueToday_

map<string, Real> nettingSetNegativeValueToday_
protected

Definition at line 79 of file exposureallocator.hpp.