interpolatedCurve.hpp
Go to the documentation of this file.
1 #ifndef JULIAN_IRINTERPOLATEDCURVE_HPP
2 #define JULIAN_IRINTERPOLATEDCURVE_HPP
3 
4 #include <dates/_all_dates.hpp>
5 #include <vector>
11 #include <iostream>
12 #include <utils/smartPointer.hpp>
13 #include <utils/utils.hpp>
14 
15 namespace julian {
16 namespace ir {
17 
42  class InterpolatedCurve: public Curve {
43  public:
45  InterpolatedCurve(Date today,std::vector<Date> dates,std::vector<double> dfs, InterestRate rate_,
46  SmartPointer<Interpolator> interpolator,SmartPointer<Extrapolator> extrapolator,Calendar calendar,double fx_spot);
47  InterpolatedCurve(CurveSettings settings, std::vector<Date> dates, std::vector<double> df);
48 
49  double DF(Date) const override;
50  double DF(Date,Date) const override;
51  double DF(Tenor) const override;
52  double DF(Tenor,Tenor) const override;
53 
54  double capitalization(Date) const override;
55  double capitalization(Tenor) const override;
56  double capitalization(Date,Date) const override;
57  double capitalization(Tenor,Tenor) const override;
58 
59  double coupon(Date) const override;
60  double coupon(Tenor) const override;
61  double coupon(Date,Date) const override;
62  double coupon(Tenor,Tenor) const override;
63 
64  double rate(Date) const override;
65  double rate(Tenor) const override;
66  double rate(Date,InterestRate) const override;
67  double rate(Tenor,InterestRate) const override;
68 
69  double fwdRate(Date,Date) const override;
70  double fwdRate(Tenor,Tenor) const override;
71  double fwdRate(Date,Tenor) const override;
72  double fwdRate(Date,Date,InterestRate) const override;
73  double fwdRate(Tenor,Tenor,InterestRate) const override;
74  double fwdRate(Date,Tenor,InterestRate) const override;
75 
76  std::vector<double> getDFs() const;
77  std::vector<double> getDFs(std::vector<Date>) const;
78  std::vector<double> getRates() const;
79  std::vector<double> getRates(InterestRate) const;
80  std::vector<double> getFwdRates() const;
81  std::vector<double> getFwdRates(InterestRate) const;
82  std::vector<Date> getDates() const;
83 
84  Calendar getCalendar() const;
88  CurveSettings getSettings() const;
89  Date getValuationDate() const override;
90  Date getSpotDate() const;
91  int getSize() const;
92  double getFxSpot() const;
93 
94  void setDates(std::vector<Date>);
95  void setDates(Tenor);
96  void setDFs(std::vector<double>);
97  void setRates(std::vector<double>);
98  void setFwdRates(std::vector<double>);
99  void setFxSpot(double);
100 
101  double calculateYF(Date,Date) const;
102  virtual InterpolatedCurve* clone() const override;
103 
104  friend std::ostream& operator<<(std::ostream&, InterpolatedCurve&);
105  friend class boost::serialization::access;
106  private:
107  template<class Archive>
108  void serialize(Archive & ar, const unsigned int);
110  std::vector<Date> dates_;
111  std::vector<double> dfs_;
116  double fx_spot_;
117  };
118 
121  template<class Archive>
122  void InterpolatedCurve::serialize(Archive & ar, const unsigned int){
123  boost::serialization::base_object<Curve>(*this);
124  ar & BOOST_SERIALIZATION_NVP(today_);
125  ar & BOOST_SERIALIZATION_NVP(dates_);
126  ar & BOOST_SERIALIZATION_NVP(dfs_);
127  ar & BOOST_SERIALIZATION_NVP(rate_);
128  ar & BOOST_SERIALIZATION_NVP(interpolator_);
129  ar & BOOST_SERIALIZATION_NVP(extrapolator_);
130  ar & BOOST_SERIALIZATION_NVP(calendar_);
131  ar & BOOST_SERIALIZATION_NVP(fx_spot_);
132  }
133 } // namespace ir
134 } // namespace julian
135 #endif
void setDates(std::vector< Date >)
change nodal dates of the curve
Definition: interpolatedCurve.cpp:436
Date today_
Today represent the date on which the curve is valid.
Definition: interpolatedCurve.hpp:109
InterestRate getInterestRate() const
get interest rate convention
Definition: interpolatedCurve.cpp:378
double calculateYF(Date, Date) const
calculate year fraction
Definition: interpolatedCurve.cpp:546
SmartPointer< Interpolator > interpolator_
The interpolator encapsulates the concept of interpolation - getting the DF for dates that are not no...
Definition: interpolatedCurve.hpp:113
File contains template of deep-coping smart pointer.
Contains headers of all files with definitions of classes gathered in dates calendar and holidays mod...
std::vector< Date > getDates() const
get dates vector
Definition: interpolatedCurve.cpp:408
std::vector< double > getFwdRates() const
get forward rates
Definition: interpolatedCurve.cpp:303
File contains definition of interface of interest rate curve interpolator.
Definition: cadHoliday.cpp:3
Class implements calendar object.
Definition: calendar.hpp:30
double rate(Date) const override
get zero coupon rate
Definition: interpolatedCurve.cpp:178
Date getValuationDate() const override
get today dates
Definition: interpolatedCurve.cpp:392
int getSize() const
returns the number of nodal dates.
Definition: interpolatedCurve.cpp:416
Template of deep-coping smart pointer.
Definition: smartPointer.hpp:14
virtual InterpolatedCurve * clone() const override
Virtual copy constructor.
Definition: interpolatedCurve.cpp:559
void setFwdRates(std::vector< double >)
set forward rate
Definition: interpolatedCurve.cpp:491
void setDFs(std::vector< double >)
set discount factors
Definition: interpolatedCurve.cpp:472
File contains small programming tools.
void serialize(Archive &ar, const unsigned int)
interface used by Boost serialization library
Definition: interpolatedCurve.hpp:122
std::vector< double > getDFs() const
get discount factors
Definition: interpolatedCurve.cpp:273
InterestRate rate_
The rate encapsulates the concept interest rate (year fraction and compounding).
Definition: interpolatedCurve.hpp:112
InterpolatedCurve()
Default constructor.
Definition: interpolatedCurve.cpp:21
void setFxSpot(double)
set fx spot for the curve
Definition: interpolatedCurve.cpp:428
friend std::ostream & operator<<(std::ostream &, InterpolatedCurve &)
Overloads stream operator.
Definition: interpolatedCurve.cpp:508
void setRates(std::vector< double >)
set zero coupon rates
Definition: interpolatedCurve.cpp:480
File contains definition of interface of interest rate curve extrapolator.
SmartPointer< Extrapolator > extrapolator_
The extrapolator encapsulates the concept of extrapolating the curve outside the interval defined by ...
Definition: interpolatedCurve.hpp:114
The object models the interest rate curve.
Definition: interpolatedCurve.hpp:42
Structure holding settings of ir::InterpolatedCurve.
Definition: curveSettings.hpp:26
double fx_spot_
Fx Spots allows to calculate two-currency instruments (Fx Forwards and CIRS).
Definition: interpolatedCurve.hpp:116
SmartPointer< Interpolator > getInterpolator() const
get interpolator
Definition: interpolatedCurve.cpp:362
Calendar calendar_
Thanks to calendar outputs of the curve (DFs, ZCRs, etc) can be calculated only on the basis of provi...
Definition: interpolatedCurve.hpp:115
double coupon(Date) const override
get coupon
Definition: interpolatedCurve.cpp:146
double fwdRate(Date, Date) const override
get forward rate
Definition: interpolatedCurve.cpp:210
std::vector< double > dfs_
InterpolatedCurve is represented by values of discount factors for each date.
Definition: interpolatedCurve.hpp:111
double getFxSpot() const
get FxSpot
Definition: interpolatedCurve.cpp:538
Class implements a date object.
Definition: date.hpp:27
File contains definition of structure holding settings of ir::InterpolatedCurve.
SmartPointer< Extrapolator > getExtrapolator() const
get extrapolator
Definition: interpolatedCurve.cpp:370
Class implements a tenor object.
Definition: tenor.hpp:23
Calendar getCalendar() const
get calendar
Definition: interpolatedCurve.cpp:354
The class implements the concept of interest rate.
Definition: interestRate.hpp:25
The class interfaces interest rate curves.
Definition: irCurve.hpp:22
double DF(Date) const override
get DF
Definition: interpolatedCurve.cpp:70
Date getSpotDate() const
get spot date
Definition: interpolatedCurve.cpp:400
File contains interface of interest rate curves.
std::vector< double > getRates() const
get zero coupon rates
Definition: interpolatedCurve.cpp:281
double capitalization(Date) const override
get capitalization
Definition: interpolatedCurve.cpp:114
File contains definition of InterestRate class.
CurveSettings getSettings() const
Returns settings of curve.
Definition: interpolatedCurve.cpp:554
std::vector< Date > dates_
This vector represents grid dates of the curve.
Definition: interpolatedCurve.hpp:110