#include <orea/simm/crifloader.hpp>
Public Member Functions | |
CrifLoader (const boost::shared_ptr< SimmConfiguration > &configuration, std::map< QuantLib::Size, std::set< std::string >> additionalHeaders=std::map< QuantLib::Size, std::set< std::string >>(), bool updateMapper=false, bool aggregateTrades=true) | |
virtual | ~CrifLoader () |
virtual void | add (CrifRecord crifRecord, const bool onDiffAmountCcy=false) |
Add a single CRIF record. | |
void | loadFromFile (const std::string &fileName, char eol='\n', char delim='\t', char quoteChar='\0', char escapeChar='\\') |
void | loadFromString (const std::string &csvBuffer, char eol='\n', char delim='\t', char quoteChar='\0', char escapeChar='\\') |
Load CRIF records in string format. | |
void | loadFromStream (std::istream &stream, char eol='\n', char delim='\t', char quoteChar='\0', char escapeChar='\\') |
Core CRIF loader from generic istream. | |
const SimmNetSensitivities | netRecords (const bool includeSimmParams=false) const |
Return the netted CRIF records for use in a SIMM calculation. | |
const SimmNetSensitivities & | simmParameters () const |
Return the SIMM parameters for use in calculating additional margin in SIMM. | |
const bool | hasCrifRecords () const |
const bool | hasSimmParameters () const |
void | setCrifRecords (const SimmNetSensitivities &crifRecords) |
void | setSimmParameters (const SimmNetSensitivities &simmParameters) |
const std::set< std::string > & | portfolioIds () const |
Give back the set of portfolio IDs that have been loaded. | |
const std::set< ore::data::NettingSetDetails > & | nettingSetDetails () const |
void | clear () |
Reset loader to initial state. | |
bool | hasNettingSetDetails () const |
Check if netting set details are used anywhere, instead of just the netting set ID. | |
void | aggregate () |
Aggregate all existing records. | |
void | fillAmountUsd (const boost::shared_ptr< ore::data::Market > market) |
const boost::shared_ptr< SimmConfiguration > & | simmConfiguration () |
SIMM configuration getter. | |
Static Public Attributes | |
static std::map< QuantLib::Size, std::set< std::string > > | requiredHeaders |
Map giving required CRIF file headers and their allowable alternatives. | |
static std::map< QuantLib::Size, std::set< std::string > > | optionalHeaders |
Map giving optional CRIF file headers and their allowable alternatives. | |
Protected Member Functions | |
virtual void | processHeader (const std::vector< std::string > &headers) |
Process the elements of a header line of a CRIF file. | |
virtual bool | process (const std::vector< std::string > &entries, QuantLib::Size maxIndex, QuantLib::Size currentLine) |
Protected Attributes | |
boost::shared_ptr< SimmConfiguration > | configuration_ |
Simm configuration that is used during loading of CRIF records. | |
std::map< QuantLib::Size, std::set< std::string > > | additionalHeaders_ |
Defines accepted column headers, beyond required and optional headers, see crifloader.cpp. | |
bool | updateMapper_ |
bool | aggregateTrades_ |
SimmNetSensitivities | crifRecords_ |
Netted CRIF records that can subsequently be used in a SIMM calculation. | |
SimmNetSensitivities | simmParameters_ |
SIMM parameters for additional margin, provided in the same format as CRIF records. | |
std::set< std::string > | portfolioIds_ |
Set of portfolio IDs that have been loaded. | |
std::set< ore::data::NettingSetDetails > | nettingSetDetails_ |
std::map< QuantLib::Size, QuantLib::Size > | columnIndex_ |
A class for loading CRIF records. The records are aggregated and stored in a SimmNetSensitivities object so that they can later be used in a SIMM calculation
CrifLoader | ( | const boost::shared_ptr< SimmConfiguration > & | configuration, |
std::map< QuantLib::Size, std::set< std::string >> | additionalHeaders = std::map<QuantLib::Size, std::set<std::string>>() , |
||
bool | updateMapper = false , |
||
bool | aggregateTrades = true |
||
) |
Constructor We set the trade ID to an empty string if we are going to be netting at portfolio level. This is the default. To override this the flag keepTradeId
may be set to true.
|
virtual |
Destructor
void loadFromFile | ( | const std::string & | fileName, |
char | eol = '\n' , |
||
char | delim = '\t' , |
||
char | quoteChar = '\0' , |
||
char | escapeChar = '\\' |
||
) |
Load CRIF records from a CRIF file.
The Risk Data Standards document outlines what character should be used to separate columns, delim
, and end lines, eol
. These parameters have the correct defaults here but can be changed.
The quoteChar
allows one specify a character that can be used to enclose strings in the CRIF file. If this character is not \0
, then an attempt is made to strip this character from the each column.
void fillAmountUsd | ( | const boost::shared_ptr< ore::data::Market > | market | ) |
For each CRIF record in netRecords_, checks if amountCurrency and amount are defined and uses these to populate the record's amountUsd
|
protectedvirtual |
Process a line of a CRIF file and return true if valid line or false if an invalid line
|
protected |
If true, the SIMM configuration's bucket mapper is updated during the CRIF loading with the mapping from SIMM qualifier to SIMM bucket. This is useful when consuming CRIF files from elsewhere in that it allows for using the mapping that is already present in the external file.
|
protected |
If true, aggregate over trade ids
|
protected |
Internal map from known index of CRIF record member to file column For example, give trade ID an index of 0 and find the column index of trade ID in the CRIF file e.g. n. The map entry would be [0, n]