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

NPVSensiCube class stores NPVs resulting from risk factor shifts on an as of date. More...

#include <orea/cube/npvsensicube.hpp>

+ Inheritance diagram for NPVSensiCube:
+ Collaboration diagram for NPVSensiCube:

Public Member Functions

QuantLib::Size numDates () const override
 Number of dates in the NPVSensiCube is exactly one i.e. the as of date. More...
 
QuantLib::Size depth () const override
 The depth in the NPVSensiCube is exactly one. More...
 
Real get (QuantLib::Size id, QuantLib::Size sample) const
 Convenience method to get a value from the cube using id and sample only. More...
 
Real get (const std::string &id, QuantLib::Size sample) const
 Convenience method to get a value from the cube using id and sample only. More...
 
void set (QuantLib::Real value, QuantLib::Size id, QuantLib::Size sample)
 Convenience method to set a value in the cube using id and sample only. More...
 
void set (QuantLib::Real value, const std::string &id, QuantLib::Size sample)
 Convenience method to set a value in the cube using id and sample only. More...
 
Size getTradeIndex (const std::string &tradeId) const
 Return the index of the trade in the cube. More...
 
virtual std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs (Size tradeIdx) const =0
 
std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs (const std::string &tradeId) const
 
virtual std::set< QuantLib::Size > relevantScenarios () const =0
 
virtual Real get (Size id, Size date, Size sample, Size depth=0) const=0
 Get a value from the cube using index. More...
 
virtual Real get (const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0) const
 Get a value from the cube using trade id and date. More...
 
virtual void set (Real value, Size id, Size date, Size sample, Size depth=0)=0
 Set a value in the cube using index. More...
 
virtual void set (Real value, const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0)
 Set a value in the cube using trade id and date. More...
 
- Public Member Functions inherited from NPVCube
 NPVCube ()
 default ctor More...
 
 NPVCube (NPVCube &)=delete
 Do not allow cube copying. More...
 
NPVCubeoperator= (NPVCube const &)=delete
 
virtual ~NPVCube ()
 dtor More...
 
virtual Size numIds () const =0
 Return the length of each dimension. More...
 
virtual Size numDates () const =0
 
virtual Size samples () const =0
 
virtual Size depth () const =0
 
virtual const std::map< std::string, Size > & idsAndIndexes () const =0
 Get a map of id and their index position in this cube. More...
 
const std::set< std::string > ids () const
 Get a set of all ids in the cube. More...
 
virtual const std::vector< QuantLib::Date > & dates () const =0
 Get the vector of dates for this cube. More...
 
virtual QuantLib::Date asof () const =0
 Return the asof date (T0 date) More...
 
virtual Real getT0 (Size id, Size depth=0) const =0
 Get a T0 value from the cube using index. More...
 
virtual Real getT0 (const std::string &id, Size depth=0) const
 Get a T0 value from the cube using trade id. More...
 
virtual void setT0 (Real value, Size id, Size depth=0)=0
 Set a value in the cube using index. More...
 
virtual void setT0 (Real value, const std::string &id, Size depth=0)
 Set a value in the cube using trade id. More...
 
virtual Real get (Size id, Size date, Size sample, Size depth=0) const =0
 Get a value from the cube using index. More...
 
virtual void set (Real value, Size id, Size date, Size sample, Size depth=0)=0
 Set a value in the cube using index. More...
 
virtual Real get (const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0) const
 Get a value from the cube using trade id and date. More...
 
virtual void set (Real value, const std::string &id, const QuantLib::Date &date, Size sample, Size depth=0)
 Set a value in the cube using trade id and date. More...
 
virtual void remove (Size id)
 
virtual void remove (Size id, Size sample)
 
Size getTradeIndex (const std::string &id) const
 

Additional Inherited Members

- Protected Member Functions inherited from NPVCube
virtual Size index (const std::string &id) const
 
virtual Size index (const QuantLib::Date &date) const
 

Detailed Description

NPVSensiCube class stores NPVs resulting from risk factor shifts on an as of date.

This class is a restriction of the NPVCube to a grid of values where the ids are trade IDs and the samples are risk factor shifts

Definition at line 40 of file npvsensicube.hpp.

Member Function Documentation

◆ numDates()

QuantLib::Size numDates ( ) const
overridevirtual

Number of dates in the NPVSensiCube is exactly one i.e. the as of date.

Implements NPVCube.

Definition at line 46 of file npvsensicube.hpp.

46{ return 1; }

◆ depth()

QuantLib::Size depth ( ) const
overridevirtual

The depth in the NPVSensiCube is exactly one.

Implements NPVCube.

Definition at line 49 of file npvsensicube.hpp.

49{ return 1; }
+ Here is the caller graph for this function:

◆ get() [1/4]

Real get ( QuantLib::Size  id,
QuantLib::Size  sample 
) const

Convenience method to get a value from the cube using id and sample only.

Definition at line 52 of file npvsensicube.hpp.

52{ return this->get(id, 0, sample, 0); }
Real get(QuantLib::Size id, QuantLib::Size sample) const
Convenience method to get a value from the cube using id and sample only.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ get() [2/4]

Real get ( const std::string &  id,
QuantLib::Size  sample 
) const

Convenience method to get a value from the cube using id and sample only.

Definition at line 55 of file npvsensicube.hpp.

55{ return this->get(id, asof(), sample, 0); };
virtual QuantLib::Date asof() const =0
Return the asof date (T0 date)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set() [1/4]

void set ( QuantLib::Real  value,
QuantLib::Size  id,
QuantLib::Size  sample 
)

Convenience method to set a value in the cube using id and sample only.

Definition at line 58 of file npvsensicube.hpp.

58{ this->set(value, id, 0, sample, 0); }
void set(QuantLib::Real value, QuantLib::Size id, QuantLib::Size sample)
Convenience method to set a value in the cube using id and sample only.
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ set() [2/4]

void set ( QuantLib::Real  value,
const std::string &  id,
QuantLib::Size  sample 
)

Convenience method to set a value in the cube using id and sample only.

Definition at line 61 of file npvsensicube.hpp.

61 {
62 this->set(value, id, asof(), sample, 0);
63 }
+ Here is the call graph for this function:

◆ getTradeIndex()

Size getTradeIndex ( const std::string &  tradeId) const

Return the index of the trade in the cube.

Definition at line 66 of file npvsensicube.hpp.

66{ return index(tradeId); }
virtual Size index(const std::string &id) const
Definition: npvcube.hpp:121
+ Here is the call graph for this function:

◆ getTradeNPVs() [1/2]

virtual std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs ( Size  tradeIdx) const
pure virtual

Return a map for the trade ID at index tradeIdx where the map key is the index of the risk factor shift and the map value is the NPV under that shift

Implemented in JointNPVSensiCube.

+ Here is the caller graph for this function:

◆ getTradeNPVs() [2/2]

std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs ( const std::string &  tradeId) const

Return a map for the tradeId where the map key is the index of the risk factor shift and the map value is the NPV under that shift

Definition at line 76 of file npvsensicube.hpp.

76 {
77 return getTradeNPVs(index(tradeId));
78 }
virtual std::map< QuantLib::Size, QuantLib::Real > getTradeNPVs(Size tradeIdx) const =0
+ Here is the call graph for this function:

◆ relevantScenarios()

virtual std::set< QuantLib::Size > relevantScenarios ( ) const
pure virtual

Return the set of scenario indices with non-zero result

Implemented in JointNPVSensiCube, and SensiCube< T >.

◆ get() [3/4]

virtual Real get ( Size  id,
Size  date,
Size  sample,
Size  depth = 0 
) const
virtual

Get a value from the cube using index.

Implements NPVCube.

◆ get() [4/4]

virtual Real get ( const std::string &  id,
const QuantLib::Date &  date,
Size  sample,
Size  depth = 0 
) const
virtual

Get a value from the cube using trade id and date.

Reimplemented from NPVCube.

Definition at line 103 of file npvcube.hpp.

103 {
104 return get(index(id), index(date), sample, depth);
105 };
QuantLib::Size depth() const override
The depth in the NPVSensiCube is exactly one.

◆ set() [3/4]

virtual void set ( Real  value,
Size  id,
Size  date,
Size  sample,
Size  depth = 0 
)
virtual

Set a value in the cube using index.

Implements NPVCube.

◆ set() [4/4]

virtual void set ( Real  value,
const std::string &  id,
const QuantLib::Date &  date,
Size  sample,
Size  depth = 0 
)
virtual

Set a value in the cube using trade id and date.

Reimplemented from NPVCube.

Definition at line 107 of file npvcube.hpp.

107 {
108 set(value, index(id), index(date), sample, depth);
109 }