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

#include <ored/portfolio/schedule.hpp>

+ Collaboration diagram for ScheduleBuilder:

Public Member Functions

void add (QuantLib::Schedule &schedule, const ScheduleData &scheduleData)
 
void makeSchedules (const QuantLib::Date &openEndDateReplacement=QuantLib::Null< QuantLib::Date >())
 

Private Attributes

map< string, pair< ScheduleData, QuantLib::Schedule & > > schedules_
 

Detailed Description

Definition at line 256 of file schedule.hpp.

Member Function Documentation

◆ add()

void add ( QuantLib::Schedule &  schedule,
const ScheduleData scheduleData 
)

Definition at line 209 of file schedule.cpp.

209 {
210 string name = data.name();
211 schedules_.insert(pair<string, pair<ScheduleData, Schedule&>>({name, {data, schedule}}));
212}
map< string, pair< ScheduleData, QuantLib::Schedule & > > schedules_
Definition: schedule.hpp:274
@ data
Definition: log.hpp:77
string name
+ Here is the caller graph for this function:

◆ makeSchedules()

void makeSchedules ( const QuantLib::Date &  openEndDateReplacement = QuantLib::Null<QuantLib::Date>())

Definition at line 214 of file schedule.cpp.

214 {
215 map<string, Schedule> builtSchedules;
216 map<string, ScheduleData> derivedSchedules;
217
218 // First, we build all the rules-based and dates-based schedules
219 for (auto& s : schedules_) {
220 string schName = s.first;
221 ScheduleData& schData = s.second.first;
222 Schedule& sch = s.second.second;
223
224 if (!schData.hasDerived()) {
225 sch = makeSchedule(schData, openEndDateReplacement);
226 builtSchedules[schName] = sch;
227 } else {
228 derivedSchedules[schName] = schData;
229 }
230 }
231
232 // We then keep looping through the list of derived schedules and building these from the list of built schedules.
233 bool calculated;
234 while (derivedSchedules.size() > 0) {
235 calculated = false;
236 for (auto& ds : derivedSchedules) {
237 string dsName = ds.first;
238 ScheduleData& dsSchedData = ds.second;
239 vector<string> baseNames = dsSchedData.baseScheduleNames();
240 for (string& bn : baseNames) {
241 QL_REQUIRE(builtSchedules.find(bn) != builtSchedules.end(), "Could not find base schedule \" " << bn << "\" for derived schedule \" " << dsName << "\"");
242 }
243 Schedule schedule;
244 schedule = makeSchedule(dsSchedData, openEndDateReplacement, builtSchedules);
245 schedules_.find(dsName)->second.second = schedule;
246 builtSchedules[dsName] = schedule;
247 derivedSchedules.erase(dsName);
248 calculated = true;
249 break;
250 }
251
252 // If we go through the whole list without having built a schedule, then assume that we cannot build them
253 // anymore.
254 if (!calculated) {
255 for (auto& ds : derivedSchedules)
256 ALOG("makeSchedules(): could not find base schedule \"" << ds.first << "\"");
257 QL_FAIL("makeSchedules(): failed to build at least one derived schedule");
258 break;
259 }
260 }
261}
#define ALOG(text)
Logging Macro (Level = Alert)
Definition: log.hpp:544
Schedule makeSchedule(const ScheduleDates &data)
Definition: schedule.cpp:263
+ Here is the call graph for this function:
+ Here is the caller graph for this function:

Member Data Documentation

◆ schedules_

map<string, pair<ScheduleData, QuantLib::Schedule&> > schedules_
private

Definition at line 274 of file schedule.hpp.