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

#include <ored/scripting/paylog.hpp>

+ Collaboration diagram for PayLog:

Public Member Functions

void write (RandomVariable value, const Filter &filter, const Date &obs, const Date &pay, const std::string &ccy, const Size legNo, const std::string &cashflowType, const Size slot=0)
 
void consolidateAndSort ()
 
Size size () const
 
const std::vector< RandomVariable > & amounts () const
 
const std::vector< Date > & dates () const
 
const std::vector< std::string > & currencies () const
 
const std::vector< Size > & legNos () const
 
const std::vector< std::string > & cashflowTypes () const
 

Private Attributes

std::vector< Size > slots_
 
std::vector< RandomVariableamounts_
 
std::vector< Date > dates_
 
std::vector< std::string > currencies_
 
std::vector< Size > legNos_
 
std::vector< std::string > cashflowTypes_
 

Detailed Description

Definition at line 36 of file paylog.hpp.

Member Function Documentation

◆ write()

void write ( RandomVariable  value,
const Filter filter,
const Date &  obs,
const Date &  pay,
const std::string &  ccy,
const Size  legNo,
const std::string &  cashflowType,
const Size  slot = 0 
)

Definition at line 25 of file paylog.cpp.

26 {
27
28 // if a slot is given, we erase the results that we already have for this slot
29
30 if (slot != 0) {
31 for (Size i = 0; i < slots_.size(); ++i) {
32 if (slot == slots_[i]) {
34 }
35 }
36 }
37
38 // determine the index where the result belongs, i.e. look for an existing entry for the given
39 // pay date, ccy, legNo, cashflowType and slot
40
41 Size idx = Null<Size>();
42 for (Size i = 0; i < slots_.size(); ++i) {
43 if (dates_[i] == pay && currencies_[i] == ccy && legNos_[i] == legNo && cashflowTypes_[i] == cashflowType &&
44 (slot == slots_[i]))
45 idx = i;
46 }
47
48 // if we did not find a slot, we create one
49
50 if (idx == Null<Size>()) {
51 slots_.push_back(slot);
52 amounts_.push_back(RandomVariable(value.size(), 0.0));
53 dates_.push_back(pay);
54 currencies_.push_back(ccy);
55 legNos_.push_back(legNo);
56 cashflowTypes_.push_back(cashflowType);
57 idx = slots_.size() - 1;
58 }
59
60 // add the value
61
63}
std::vector< std::string > cashflowTypes_
Definition: paylog.hpp:59
std::vector< Size > slots_
Definition: paylog.hpp:54
std::vector< Date > dates_
Definition: paylog.hpp:56
std::vector< RandomVariable > amounts_
Definition: paylog.hpp:55
std::vector< Size > legNos_
Definition: paylog.hpp:58
std::vector< std::string > currencies_
Definition: paylog.hpp:57
SafeStack< ValueType > value
SafeStack< Filter > filter
RandomVariable applyInverseFilter(RandomVariable x, const Filter &f)
RandomVariable applyFilter(RandomVariable x, const Filter &f)
+ Here is the call graph for this function:

◆ consolidateAndSort()

void consolidateAndSort ( )

Definition at line 65 of file paylog.cpp.

65 {
66
67 // Create set of (legNo, payDate, payCcy, cfType), index in amounts / dates / ... vectors.
68 // This will also create the sorting we want. Ignore slots from here on.
69
70 std::set<std::tuple<Size, Date, std::string, std::string, Size>> dates;
71 for (Size i = 0; i < slots_.size(); ++i) {
72 dates.insert(std::make_tuple(legNos_[i], dates_[i], currencies_[i], cashflowTypes_[i], i));
73 }
74
75 // build consolidated and sorted vector
76
77 std::vector<Date> resultDates;
78 std::vector<std::string> resultCurrencies;
79 std::vector<Size> resultLegNos;
80 std::vector<std::string> resultCashflowTypes;
81 std::vector<RandomVariable> resultAmounts;
82 Date lastDate = Null<Date>();
83 std::string lastCurrency;
84 Size lastLegNo = Null<Size>();
85 std::string lastCashflowType;
86 for (auto const& d : dates) {
87 if (std::get<1>(d) == lastDate && std::get<2>(d) == lastCurrency && std::get<0>(d) == lastLegNo &&
88 std::get<3>(d) == lastCashflowType)
89 resultAmounts.back() += amounts_[std::get<4>(d)];
90 else {
91 resultAmounts.push_back(amounts_[std::get<4>(d)]);
92 resultDates.push_back(std::get<1>(d));
93 resultCurrencies.push_back(std::get<2>(d));
94 resultLegNos.push_back(std::get<0>(d));
95 resultCashflowTypes.push_back(std::get<3>(d));
96 }
97 lastDate = std::get<1>(d);
98 lastCurrency = std::get<2>(d);
99 lastLegNo = std::get<0>(d);
100 lastCashflowType = std::get<3>(d);
101 }
102
103 // overwrite the existing members
104
105 amounts_ = std::move(resultAmounts);
106 dates_ = std::move(resultDates);
107 currencies_ = std::move(resultCurrencies);
108 legNos_ = std::move(resultLegNos);
109 cashflowTypes_ = std::move(resultCashflowTypes);
110
111 // reset slots
112
113 slots_ = std::vector<Size>(amounts_.size(), 0);
114}
const std::vector< Date > & dates() const
Definition: paylog.hpp:48
+ Here is the call graph for this function:

◆ size()

Size size ( ) const

Definition at line 46 of file paylog.hpp.

46{ return slots_.size(); }

◆ amounts()

const std::vector< RandomVariable > & amounts ( ) const

Definition at line 47 of file paylog.hpp.

47{ return amounts_; }

◆ dates()

const std::vector< Date > & dates ( ) const

Definition at line 48 of file paylog.hpp.

48{ return dates_; }
+ Here is the caller graph for this function:

◆ currencies()

const std::vector< std::string > & currencies ( ) const

Definition at line 49 of file paylog.hpp.

49{ return currencies_; }

◆ legNos()

const std::vector< Size > & legNos ( ) const

Definition at line 50 of file paylog.hpp.

50{ return legNos_; }

◆ cashflowTypes()

const std::vector< std::string > & cashflowTypes ( ) const

Definition at line 51 of file paylog.hpp.

51{ return cashflowTypes_; }

Member Data Documentation

◆ slots_

std::vector<Size> slots_
private

Definition at line 54 of file paylog.hpp.

◆ amounts_

std::vector<RandomVariable> amounts_
private

Definition at line 55 of file paylog.hpp.

◆ dates_

std::vector<Date> dates_
private

Definition at line 56 of file paylog.hpp.

◆ currencies_

std::vector<std::string> currencies_
private

Definition at line 57 of file paylog.hpp.

◆ legNos_

std::vector<Size> legNos_
private

Definition at line 58 of file paylog.hpp.

◆ cashflowTypes_

std::vector<std::string> cashflowTypes_
private

Definition at line 59 of file paylog.hpp.