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

Class for streaming SensitivityRecords from csv file. More...

#include <orea/engine/sensitivityreportstream.hpp>

+ Inheritance diagram for SensitivityReportStream:
+ Collaboration diagram for SensitivityReportStream:

Public Member Functions

 SensitivityReportStream (const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &report)
 Constructor. More...
 
virtual ~SensitivityReportStream ()
 
SensitivityRecord next () override
 Returns the next SensitivityRecord in the stream. More...
 
void reset () override
 Resets the stream so that SensitivityRecord objects can be streamed again. More...
 
- Public Member Functions inherited from SensitivityStream
virtual ~SensitivityStream ()
 Destructor. More...
 
virtual SensitivityRecord next ()=0
 Returns the next SensitivityRecord in the stream. More...
 
virtual void reset ()=0
 Resets the stream so that SensitivityRecord objects can be streamed again. More...
 

Private Member Functions

SensitivityRecord processRecord (const std::vector< ore::data::Report::ReportType > &entries) const
 Create a record from a collection of strings. More...
 

Private Attributes

QuantLib::ext::shared_ptr< ore::data::InMemoryReportreport_
 
QuantLib::Size row_ = 0
 

Detailed Description

Class for streaming SensitivityRecords from csv file.

Definition at line 35 of file sensitivityreportstream.hpp.

Constructor & Destructor Documentation

◆ SensitivityReportStream()

SensitivityReportStream ( const QuantLib::ext::shared_ptr< ore::data::InMemoryReport > &  report)

Constructor.

Definition at line 38 of file sensitivityreportstream.hpp.

38: report_(report) {}
QuantLib::ext::shared_ptr< ore::data::InMemoryReport > report_

◆ ~SensitivityReportStream()

virtual ~SensitivityReportStream ( )
virtual

Definition at line 39 of file sensitivityreportstream.hpp.

39{} // Declare virtual destructor

Member Function Documentation

◆ next()

SensitivityRecord next ( )
overridevirtual

Returns the next SensitivityRecord in the stream.

Implements SensitivityStream.

Definition at line 37 of file sensitivityreportstream.cpp.

37 {
38 row_++;
39 if (row_ <= report_->rows()) {
40 vector<Report::ReportType> entries;
41 for (Size i = 0; i < report_->columns(); i++) {
42 entries.push_back(report_->data(i).at(row_ - 1));
43 }
44 return processRecord(entries);
45 }
46
47 // If we get to here, no more lines to process so return empty record
48 return SensitivityRecord();
49}
SensitivityRecord processRecord(const std::vector< ore::data::Report::ReportType > &entries) const
Create a record from a collection of strings.
+ Here is the call graph for this function:

◆ reset()

void reset ( )
overridevirtual

Resets the stream so that SensitivityRecord objects can be streamed again.

Implements SensitivityStream.

Definition at line 51 of file sensitivityreportstream.cpp.

51 {
52 row_ = 0;
53}

◆ processRecord()

SensitivityRecord processRecord ( const std::vector< ore::data::Report::ReportType > &  entries) const
private

Create a record from a collection of strings.

Definition at line 55 of file sensitivityreportstream.cpp.

55 {
56
57 QL_REQUIRE(entries.size() == 10, "On row number " << row_ << ": A sensitivity record needs 10 entries");
58
59 SensitivityRecord sr;
60 sr.tradeId = QuantLib::ext::get<std::string>(entries[0]);
61 sr.isPar = parseBool(QuantLib::ext::get<std::string>(entries[1]));
62
63 auto p = deconstructFactor(QuantLib::ext::get<std::string>(entries[2]));
64 sr.key_1 = p.first;
65 sr.desc_1 = p.second;
66 sr.shift_1 = QuantLib::ext::get<Real>(entries[3]);
67
68 p = deconstructFactor(QuantLib::ext::get<std::string>(entries[4]));
69 sr.key_2 = p.first;
70 sr.desc_2 = p.second;
71 sr.shift_2 = QuantLib::ext::get<Real>(entries[5]);
72
73 sr.currency = QuantLib::ext::get<std::string>(entries[6]);
74 sr.baseNpv = QuantLib::ext::get<Real>(entries[7]);
75 sr.delta = QuantLib::ext::get<Real>(entries[8]);
76 sr.gamma = QuantLib::ext::get<Real>(entries[9]);
77
78 return sr;
79}
bool parseBool(const string &s)
pair< RiskFactorKey, string > deconstructFactor(const string &factor)
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ report_

QuantLib::ext::shared_ptr<ore::data::InMemoryReport> report_
private

Definition at line 47 of file sensitivityreportstream.hpp.

◆ row_

QuantLib::Size row_ = 0
private

Definition at line 49 of file sensitivityreportstream.hpp.