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

#include <orea/simm/imscheduleresults.hpp>

+ Collaboration diagram for IMScheduleResults:

Public Member Functions

 IMScheduleResults (const std::string &ccy="")
 
void add (const CrifRecord::ProductClass &pc, const std::string &calculationCurrency, const QuantLib::Real grossIM, const QuantLib::Real grossRC, const QuantLib::Real netRC, const QuantLib::Real ngr, const QuantLib::Real scheduleIM)
 
IMScheduleResult get (const CrifRecord::ProductClass &pc) const
 Convert Schedule IM amounts to a different currency. More...
 
bool has (const CrifRecord::ProductClass &pc) 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< CrifRecord::ProductClass, IMScheduleResult > & data () const
 Return the map containing the results. More...
 
const std::string & currency () const
 
std::string & currency ()
 

Private Attributes

std::map< CrifRecord::ProductClass, IMScheduleResultdata_
 
std::string ccy_
 

Detailed Description

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

Definition at line 53 of file imscheduleresults.hpp.

Constructor & Destructor Documentation

◆ IMScheduleResults()

IMScheduleResults ( const std::string &  ccy = "")

Definition at line 55 of file imscheduleresults.hpp.

Member Function Documentation

◆ add()

void add ( const CrifRecord::ProductClass pc,
const std::string &  calculationCurrency,
const QuantLib::Real  grossIM,
const QuantLib::Real  grossRC,
const QuantLib::Real  netRC,
const QuantLib::Real  ngr,
const QuantLib::Real  scheduleIM 
)

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

Remarks
If there is already a result in the container for that combination, it is overwritten. Can check this using the has method before adding.

Definition at line 33 of file imscheduleresults.cpp.

34 {
35
36 // Add the value as long as the currencies are matching. If the IMScheduleResults container does not yet have
37 // a currency, we set it to be that of the incoming value
38 if (ccy_.empty())
39 ccy_ = calculationCcy;
40 else
41 QL_REQUIRE(calculationCcy == ccy_, "Cannot add value to IMScheduleResults in a different currency ("
42 << calculationCcy << "). Expected " << ccy_ << ".");
43
44 if (has(pc)) {
45 QL_REQUIRE(grossIM != Null<Real>(), "IMScheduleResults: Gross IM cannot be null.");
46 data_[pc].grossIM += grossIM;
47 } else {
48 IMScheduleResult result = IMScheduleResult(grossIM, grossRC, netRC, ngr, scheduleIM);
49 data_[pc] = result;
50 }
51}
bool has(const CrifRecord::ProductClass &pc) const
std::map< CrifRecord::ProductClass, IMScheduleResult > data_
+ Here is the call graph for this function:

◆ get()

IMScheduleResult get ( const CrifRecord::ProductClass pc) const

Convert Schedule IM amounts to a different currency.

Get the initial margin value from the results container for the given combination of Schedule 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 77 of file imscheduleresults.cpp.

77 {
78 if (has(pc))
79 return data_.at(pc);
80 else
81 return IMScheduleResult(QuantLib::Null<Real>(), QuantLib::Null<Real>(), QuantLib::Null<Real>(),
82 QuantLib::Null<Real>(), QuantLib::Null<Real>());
83}
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ has()

bool has ( const CrifRecord::ProductClass pc) const

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

Definition at line 85 of file imscheduleresults.cpp.

85{ return data_.count(pc) > 0; }
+ Here is the caller graph for this function:

◆ empty()

bool empty ( ) const

Return true if the container is empty, otherwise false.

Definition at line 87 of file imscheduleresults.cpp.

87{ return data_.empty(); }

◆ clear()

void clear ( )

Clear the results from the container.

Definition at line 89 of file imscheduleresults.cpp.

89{ data_.clear(); }

◆ data()

const std::map< CrifRecord::ProductClass, IMScheduleResult > & data ( ) const

Return the map containing the results.

Definition at line 95 of file imscheduleresults.hpp.

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

◆ currency() [1/2]

const std::string & currency ( ) const

Definition at line 97 of file imscheduleresults.hpp.

97{ return ccy_; }
+ Here is the caller graph for this function:

◆ currency() [2/2]

std::string & currency ( )

Definition at line 99 of file imscheduleresults.hpp.

99{ return ccy_; }

Member Data Documentation

◆ data_

std::map<CrifRecord::ProductClass, IMScheduleResult> data_
private

Definition at line 102 of file imscheduleresults.hpp.

◆ ccy_

std::string ccy_
private

Definition at line 103 of file imscheduleresults.hpp.