calendar.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_CALENDAR_HPP
2 #define JULIAN_CALENDAR_HPP
3 
4 #include <dates/date.hpp>
5 #include <iostream>
6 #include <dates/tenor.hpp>
7 #include <dates/timeUnit.hpp>
8 #include <vector>
9 #include <utils/smartPointer.hpp>
13 
14 
15 
16 namespace julian {
30  class Calendar {
31  public:
32  Calendar();
33  Calendar(DayRollingConvention, int, const std::vector<Date>&, const std::vector<Date>& ,const std::vector<SmartPointer<Holiday> >&, bool end_of_month,const SmartPointer<SettlementDateConvention>&);
34 
35  bool isBusinessDay(const Date&) const;
36  bool isHoliday(const Date&) const;
37  bool isWeekend(const Date&) const;
38  Date adjust(const Date&) const;
39 
40  int businessDaysBetween(const Date&, const Date&) const;
41  int numberOfHolidaysBetween(const Date&, const Date&) const;
42  Date workingDays(const Date&, int) const;
43 
44  Date getSpot(const Date&) const;
45  Date getON(const Date&) const;
46  Date getTN(const Date&)const;
47 
48  Date expiryDate(const Date& d, const Tenor& t) const;
49  Date settlementDate(const Date& d, const Tenor& t) const;
50 
51  int getSpotLag() const;
52  bool isEndOfMonth(const Date&) const;
53  Date getLastWorkingDateOfMonth(const Date&) const;
54 
55  ~Calendar(){};
56 
57  friend std::ostream& operator<<(std::ostream&, Calendar&);
58  friend class boost::serialization::access;
59  private:
60 
63  template<class Archive>
64  void serialize(Archive & ar, const unsigned int){
65  ar & BOOST_SERIALIZATION_NVP(spot_lag_);
66  ar & BOOST_SERIALIZATION_NVP(day_rolling_convention_);
67  ar & BOOST_SERIALIZATION_NVP(end_of_month_);
68  ar & BOOST_SERIALIZATION_NVP(business_days_);
69  ar & BOOST_SERIALIZATION_NVP(holidays_dates_);
70  ar & BOOST_SERIALIZATION_NVP(holidays_);
71  ar & BOOST_SERIALIZATION_NVP(settlement_);
72  }
73 
74  int spot_lag_;
77  std::vector<Date> business_days_;
78  std::vector<Date> holidays_dates_;
79  std::vector<SmartPointer<Holiday> > holidays_;
81  };
82 }
83 
84 #endif
Date settlementDate(const Date &d, const Tenor &t) const
Calculates settlement date.
Definition: calendar.cpp:213
File contains template of deep-coping smart pointer.
bool isBusinessDay(const Date &) const
Method returns true if a given date is business day and false otherwise.
Definition: calendar.cpp:44
std::vector< SmartPointer< Holiday > > holidays_
Vector of holidays objects (see Holiday).
Definition: calendar.hpp:79
Definition: cadHoliday.cpp:3
File contains definition of SettlementFromSpot class.
Class implements calendar object.
Definition: calendar.hpp:30
Template of deep-coping smart pointer.
Definition: smartPointer.hpp:14
Date adjust(const Date &) const
Method adjusts a date according to a given day rolling convention.
Definition: calendar.cpp:118
Date workingDays(const Date &, int) const
Method returns nth working day from a given date.
Definition: calendar.cpp:187
File contains definition of date class.
SmartPointer< SettlementDateConvention > settlement_
This variable holds object defining settlement date convention.
Definition: calendar.hpp:80
Date getON(const Date &) const
Method returns next working day of a calendar&#39;s date.
Definition: calendar.cpp:175
DayRollingConvention day_rolling_convention_
Variable defines the day rolling convention.
Definition: calendar.hpp:75
std::vector< Date > business_days_
Vector of dates that are recognized as working dates.
Definition: calendar.hpp:77
Date getTN(const Date &) const
Method returns second working day from a calendar&#39;s date.
Definition: calendar.cpp:181
Calendar()
Constructor.
Definition: calendar.cpp:34
Date expiryDate(const Date &d, const Tenor &t) const
Definition: calendar.cpp:240
Class implements a date object.
Definition: date.hpp:27
bool end_of_month_
Boolean variable defining if end of month convention is applied.
Definition: calendar.hpp:76
File contains definition of tenor class.
std::vector< Date > holidays_dates_
Vector of dates that are recognized as holidays.
Definition: calendar.hpp:78
friend std::ostream & operator<<(std::ostream &, Calendar &)
Definition: calendar.cpp:250
int spot_lag_
This integer define how many working days is between today date and spot date.
Definition: calendar.hpp:74
File contains interface of settlement convention.
int businessDaysBetween(const Date &, const Date &) const
Method returns number of business days between date1 and date2.
Definition: calendar.cpp:91
bool isHoliday(const Date &) const
Method returns true if a given date is holiday and false otherwise.
Definition: calendar.cpp:55
Date getLastWorkingDateOfMonth(const Date &) const
Definition: calendar.cpp:299
Class implements a tenor object.
Definition: tenor.hpp:23
File contains definition of Holiday class.
bool isWeekend(const Date &) const
Method returns true if a given date is a Saturday or Sunday and false otherwise.
Definition: calendar.cpp:82
DayRollingConvention
Definition: timeUnit.hpp:117
void serialize(Archive &ar, const unsigned int)
interface used by Boost serialization library
Definition: calendar.hpp:64
int getSpotLag() const
Definition: calendar.cpp:310
int numberOfHolidaysBetween(const Date &, const Date &) const
Method returns number of holidays between date1 and date2.
Definition: calendar.cpp:104
File contain time units and other useful enumerations.
Date getSpot(const Date &) const
Method returns spot date for a given date.
Definition: calendar.cpp:168
bool isEndOfMonth(const Date &) const
Definition: calendar.cpp:288