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

#include <orea/simm/simmresults.hpp>

+ Collaboration diagram for SimmResults:

Public Types

typedef CrifRecord::ProductClass ProductClass
 
typedef SimmConfiguration::RiskClass RiskClass
 
typedef SimmConfiguration::MarginType MarginType
 
typedef std::tuple< ProductClass, RiskClass, MarginType, std::string > Key
 

Public Member Functions

 SimmResults (const std::string &resultCcy="", const std::string &calcCcy="")
 
void add (const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string &b, QuantLib::Real im, const std::string &resultCurrency, const std::string &calculationCurrency, const bool overwrite)
 
void add (const Key &key, QuantLib::Real im, const std::string &resultCurrency, const std::string &calculationCurrency, const bool overwrite)
 
void convert (const QuantLib::ext::shared_ptr< ore::data::Market > &market, const std::string &currency)
 Convert SIMM amounts to a different currency. More...
 
void convert (QuantLib::Real fxSpot, const std::string &currency)
 
QuantLib::Real get (const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string b) const
 
bool has (const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string b) const
 
bool empty () const
 Return true if the container is empty, otherwise false. More...
 
void clear ()
 Clear the results from the container. More...
 
const std::map< Key, QuantLib::Real > & data () const
 Return the map containing the results. More...
 
std::map< Key, QuantLib::Real > & data ()
 
std::string & resultCurrency ()
 
const std::string & resultCurrency () const
 
std::string & calculationCurrency ()
 
const std::string & calculationCurrency () const
 

Private Attributes

std::map< Key, QuantLib::Real > data_
 
std::string resultCcy_
 
std::string calcCcy_
 

Detailed Description

A container for SIMM results broken down by product class, risk class and margin type.

Definition at line 38 of file simmresults.hpp.

Member Typedef Documentation

◆ ProductClass

Definition at line 40 of file simmresults.hpp.

◆ RiskClass

Definition at line 41 of file simmresults.hpp.

◆ MarginType

Definition at line 42 of file simmresults.hpp.

◆ Key

typedef std::tuple<ProductClass, RiskClass, MarginType, std::string> Key

Definition at line 43 of file simmresults.hpp.

Constructor & Destructor Documentation

◆ SimmResults()

SimmResults ( const std::string &  resultCcy = "",
const std::string &  calcCcy = "" 
)

Definition at line 45 of file simmresults.hpp.

46 : resultCcy_(resultCcy), calcCcy_(calcCcy){};

Member Function Documentation

◆ add() [1/2]

void add ( const CrifRecord::ProductClass pc,
const SimmConfiguration::RiskClass rc,
const SimmConfiguration::MarginType mt,
const std::string &  b,
QuantLib::Real  im,
const std::string &  resultCurrency,
const std::string &  calculationCurrency,
const bool  overwrite 
)

Add initial margin value im to the results container for the given combination of SIMM product class, risk class and margin type

Remarks
If there is already a result in the container for that combination, it is overwritten if overwrite=true. Otherwise, the amounts are added together. Can check this using the has method before adding.

◆ add() [2/2]

void add ( const Key key,
QuantLib::Real  im,
const std::string &  resultCurrency,
const std::string &  calculationCurrency,
const bool  overwrite 
)

Definition at line 47 of file simmresults.cpp.

48 {
49 // Add the value as long as the currencies are matching. If the SimmResults container does not yet have
50 // a currency, we set it to be that of the incoming value
51 if (resultCcy_.empty())
53 else
54 QL_REQUIRE(resultCurrency == resultCcy_,
55 "Cannot add value to SimmResults with a different result currency ("
56 << resultCurrency << "). Expected " << resultCcy_ << ".");
57
58 if (calcCcy_.empty())
60 else
61 QL_REQUIRE(calculationCurrency == calcCcy_,
62 "Cannot add value to SimmResults in a different calculation currency ("
63 << calculationCurrency << "). Expected " << calcCcy_ << ".");
64
65 const bool hasResults = data_.find(key) != data_.end();
66 if (hasResults && !overwrite)
67 data_[key] += im;
68 else
69 data_[key] = im;
70 }
std::string & calculationCurrency()
Definition: simmresults.hpp:98
std::string & resultCurrency()
Definition: simmresults.hpp:95
std::map< Key, QuantLib::Real > data_
+ Here is the call graph for this function:

◆ convert() [1/2]

void convert ( const QuantLib::ext::shared_ptr< ore::data::Market > &  market,
const std::string &  currency 
)

Convert SIMM amounts to a different currency.

Definition at line 73 of file simmresults.cpp.

73 {
74 // Get corresponding FX spot rate
75 Real fxSpot = market->fxRate(resultCcy_ + currency)->value();
76
77 convert(fxSpot, currency);
78}
void convert(const QuantLib::ext::shared_ptr< ore::data::Market > &market, const std::string &currency)
Convert SIMM amounts to a different currency.
Definition: simmresults.cpp:73
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ convert() [2/2]

void convert ( QuantLib::Real  fxSpot,
const std::string &  currency 
)
+ Here is the call graph for this function:

◆ get()

Real get ( const CrifRecord::ProductClass pc,
const SimmConfiguration::RiskClass rc,
const SimmConfiguration::MarginType mt,
const std::string  b 
) const

Get the initial margin value from the results container for the given combination of SIMM product class, risk class and margin type

Warning:
returns QuantLib::Null<QuantLib::Real> if there is no initial margin value in the results for the given combination. Can avoid this by first checking the results using the has method.

Definition at line 97 of file simmresults.cpp.

98 {
99 if (has(pc, rc, mt, b)) {
100 return data_.at(make_tuple(pc, rc, mt, b));
101 } else {
102 return Null<Real>();
103 }
104}
bool has(const CrifRecord::ProductClass &pc, const SimmConfiguration::RiskClass &rc, const SimmConfiguration::MarginType &mt, const std::string b) const
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has()

bool has ( const CrifRecord::ProductClass pc,
const SimmConfiguration::RiskClass rc,
const SimmConfiguration::MarginType mt,
const std::string  b 
) const

Check if there is an initial margin value in the results container for the given combination of SIMM product class, risk class and margin type

Definition at line 106 of file simmresults.cpp.

107 {
108 return data_.count(make_tuple(pc, rc, mt, b)) > 0;
109}
+ Here is the caller graph for this function:

◆ empty()

bool empty ( ) const

Return true if the container is empty, otherwise false.

Definition at line 111 of file simmresults.cpp.

111{ return data_.empty(); }

◆ clear()

void clear ( )

Clear the results from the container.

Definition at line 113 of file simmresults.cpp.

113{ data_.clear(); }

◆ data() [1/2]

const std::map< Key, QuantLib::Real > & data ( ) const

Return the map containing the results.

Definition at line 92 of file simmresults.hpp.

92{ return data_; }

◆ data() [2/2]

std::map< Key, QuantLib::Real > & data ( )

Definition at line 93 of file simmresults.hpp.

93{ return data_; }

◆ resultCurrency() [1/2]

std::string & resultCurrency ( )

Definition at line 95 of file simmresults.hpp.

95{ return resultCcy_; }
+ Here is the caller graph for this function:

◆ resultCurrency() [2/2]

const std::string & resultCurrency ( ) const

Definition at line 96 of file simmresults.hpp.

96{ return resultCcy_; }

◆ calculationCurrency() [1/2]

std::string & calculationCurrency ( )

Definition at line 98 of file simmresults.hpp.

98{ return calcCcy_; }
+ Here is the caller graph for this function:

◆ calculationCurrency() [2/2]

const std::string & calculationCurrency ( ) const

Definition at line 99 of file simmresults.hpp.

99{ return calcCcy_; }

Member Data Documentation

◆ data_

std::map<Key, QuantLib::Real> data_
private

Definition at line 102 of file simmresults.hpp.

◆ resultCcy_

std::string resultCcy_
private

Definition at line 103 of file simmresults.hpp.

◆ calcCcy_

std::string calcCcy_
private

Definition at line 104 of file simmresults.hpp.