yieldtermstructures.hpp
Go to the documentation of this file.
1 /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 
3 /*
4  Copyright (C) 2005, 2006, 2007 Eric Ehlers
5  Copyright (C) 2006, 2007, 2009 Ferdinando Ametrano
6  Copyright (C) 2005 Plamen Neykov
7  Copyright (C) 2005 Aurelien Chanudet
8  Copyright (C) 2016 Stefano Fondi
9 
10  This file is part of QuantLib, a free-software/open-source library
11  for financial quantitative analysts and developers - http://quantlib.org/
12 
13  QuantLib is free software: you can redistribute it and/or modify it
14  under the terms of the QuantLib license. You should have received a
15  copy of the license along with this program; if not, please email
16  <quantlib-dev@lists.sf.net>. The license is also available online at
17  <http://quantlib.org/license.shtml>.
18 
19  This program is distributed in the hope that it will be useful, but WITHOUT
20  ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
21  FOR A PARTICULAR PURPOSE. See the license for more details.
22 */
23 
24 #ifndef qla_yieldtermstructures_hpp
25 #define qla_yieldtermstructures_hpp
26 
27 #include <qlo/termstructures.hpp>
28 
29 #include <ql/time/frequency.hpp>
30 #include <ql/compounding.hpp>
31 #include <ql/types.hpp>
32 #include <ql/math/interpolations/mixedinterpolation.hpp>
33 
34 namespace QuantLib {
35  class Calendar;
36  class DayCounter;
37  class Date;
38  class Quote;
39 
40  template<class TS>
41  class BootstrapHelper;
42 
43  typedef BootstrapHelper<YieldTermStructure> RateHelper;
44 
45  template <class T>
46  class Handle;
47 }
48 
49 namespace QuantLibAddin {
50 
51  class DiscountCurve : public YieldTermStructure {
52  public:
54  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
55  const std::vector<QuantLib::Date>& dates,
56  const std::vector<QuantLib::DiscountFactor>& dfs,
57  const QuantLib::DayCounter& dayCounter,
58  bool permanent);
59  };
60 
61  class ZeroCurve : public YieldTermStructure {
62  public:
63  ZeroCurve(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
64  const std::vector<QuantLib::Date>& dates,
65  const std::vector<QuantLib::Rate>& zeroRates,
66  const QuantLib::DayCounter& dayCounter,
67  bool permanent);
68  };
69 
70  class ForwardCurve : public YieldTermStructure {
71  public:
72  ForwardCurve(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
73  const std::vector<QuantLib::Date>& dates,
74  const std::vector<QuantLib::Rate>& forwardRates,
75  const QuantLib::DayCounter& dayCounter,
76  bool permanent);
77  };
78 
79  class FlatForward : public YieldTermStructure {
80  public:
81  FlatForward(const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
82  QuantLib::Natural nDays,
83  const QuantLib::Calendar& calendar,
84  const QuantLib::Handle<QuantLib::Quote>& forward,
85  const QuantLib::DayCounter& dayCounter,
86  QuantLib::Compounding compounding,
87  QuantLib::Frequency frequency,
88  bool permanent);
89  };
90 
91  class ForwardSpreadedTermStructure : public YieldTermStructure {
92  public:
94  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
97  bool permanent);
98  };
99 
100  class ImpliedTermStructure : public YieldTermStructure {
101  public:
103  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
105  const QuantLib::Date& referenceDate,
106  bool permanent);
107  };
108 
109  class InterpolatedYieldCurve : public YieldTermStructure {
110  public:
111  // placeholders for QuantLib types of the same name.
112  enum Traits { Discount,
115  };
138  };
140  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
141  const std::vector<QuantLib::Date>& dates,
142  const std::vector<QuantLib::Real>& data,
143  const QuantLib::Calendar& calendar,
144  const QuantLib::DayCounter& dayCounter,
145  const std::vector<QuantLib::Handle<QuantLib::Quote> >& jumps,
146  const std::vector<QuantLib::Date>& jumpDates,
147  const std::string& traitsID,
148  const std::string& interpolatorID,
149  const QuantLib::MixedInterpolation::Behavior behavior,
150  const QuantLib::Size n,
151  bool permanent = false);
152  const std::vector<QuantLib::Time>& times() const;
153  const std::vector<QuantLib::Date>& dates() const;
154  const std::vector<QuantLib::Real>& data() const;
155  const std::vector<QuantLib::Time>& jumpTimes() const;
156  const std::vector<QuantLib::Date>& jumpDates() const;
157  protected:
159  const boost::shared_ptr<ObjectHandler::ValueObject>& properties,
160  const std::string& traitsID,
161  const std::string& interpolatorID,
162  bool permanent);
164  };
165 
166 
167  // A pair indicating a combination of Traits / Interpolator.
168  typedef std::pair<InterpolatedYieldCurve::Traits, InterpolatedYieldCurve::Interpolator> InterpolatedYieldCurvePair;
169 
170  // Stream operator to write a InterpolatedYieldCurvePair to a stream - for logging / error handling.
171  std::ostream &operator<<(std::ostream &out,
172  InterpolatedYieldCurvePair tokenPair);
173 }
174 
175 #endif
std::pair< InterpolatedYieldCurve::Traits, InterpolatedYieldCurve::Interpolator > InterpolatedYieldCurvePair
Definition: yieldtermstructures.hpp:168
@ LogMixedLinearMonotonicCubicNaturalSpline
Definition: yieldtermstructures.hpp:135
Definition: yieldtermstructures.hpp:70
@ MixedLinearCubicNaturalSpline
Definition: yieldtermstructures.hpp:132
@ Linear
Definition: yieldtermstructures.hpp:118
std::string interpolatorID_
Definition: yieldtermstructures.hpp:163
@ LogCubicNaturalSpline
Definition: yieldtermstructures.hpp:121
InterpolatedYieldCurve(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &data, const QuantLib::Calendar &calendar, const QuantLib::DayCounter &dayCounter, const std::vector< QuantLib::Handle< QuantLib::Quote > > &jumps, const std::vector< QuantLib::Date > &jumpDates, const std::string &traitsID, const std::string &interpolatorID, const QuantLib::MixedInterpolation::Behavior behavior, const QuantLib::Size n, bool permanent=false)
@ KrugerLogCubic
Definition: yieldtermstructures.hpp:125
const std::vector< QuantLib::Date > & jumpDates() const
Definition: yieldtermstructures.hpp:100
DiscountCurve(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::DiscountFactor > &dfs, const QuantLib::DayCounter &dayCounter, bool permanent)
@ Parabolic
Definition: yieldtermstructures.hpp:128
@ MixedLinearMonotonicCubicNaturalSpline
Definition: yieldtermstructures.hpp:134
Definition: yieldtermstructures.hpp:91
@ KrugerCubic
Definition: yieldtermstructures.hpp:124
Definition: yieldtermstructures.hpp:109
const std::vector< QuantLib::Time > & times() const
Definition: yieldtermstructures.hpp:61
Traits
Definition: yieldtermstructures.hpp:112
ImpliedTermStructure(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Handle< QuantLib::YieldTermStructure > &hYTS, const QuantLib::Date &referenceDate, bool permanent)
@ Discount
Definition: yieldtermstructures.hpp:112
FlatForward(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, QuantLib::Natural nDays, const QuantLib::Calendar &calendar, const QuantLib::Handle< QuantLib::Quote > &forward, const QuantLib::DayCounter &dayCounter, QuantLib::Compounding compounding, QuantLib::Frequency frequency, bool permanent)
std::ostream & operator<<(std::ostream &out, InterpolatedYieldCurvePair tokenPair)
const std::vector< QuantLib::Date > & dates() const
std::string traitsID_
Definition: yieldtermstructures.hpp:163
ForwardSpreadedTermStructure(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const QuantLib::Handle< QuantLib::YieldTermStructure > &hYTS, const QuantLib::Handle< QuantLib::Quote > &spread, bool permanent)
@ LogMixedLinearCubicNaturalSpline
Definition: yieldtermstructures.hpp:133
const std::vector< QuantLib::Real > & data() const
Interpolator
Definition: yieldtermstructures.hpp:116
ZeroCurve(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Rate > &zeroRates, const QuantLib::DayCounter &dayCounter, bool permanent)
ForwardCurve(const boost::shared_ptr< ObjectHandler::ValueObject > &properties, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Rate > &forwardRates, const QuantLib::DayCounter &dayCounter, bool permanent)
@ MonotonicLogParabolic
Definition: yieldtermstructures.hpp:131
const std::vector< QuantLib::Time > & jumpTimes() const
@ ForwardFlat
Definition: yieldtermstructures.hpp:117
@ FritschButlandCubic
Definition: yieldtermstructures.hpp:126
@ BackwardFlat
Definition: yieldtermstructures.hpp:116
Definition: abcd.hpp:38
@ CubicNaturalSpline
Definition: yieldtermstructures.hpp:120
@ LogParabolic
Definition: yieldtermstructures.hpp:129
@ ZeroYield
Definition: yieldtermstructures.hpp:114
Definition: abcd.hpp:30
Definition: yieldtermstructures.hpp:51
@ LogMixedLinearKrugerCubic
Definition: yieldtermstructures.hpp:137
@ LogLinear
Definition: yieldtermstructures.hpp:119
Definition: yieldtermstructures.hpp:79
BootstrapHelper< YieldTermStructure > RateHelper
Definition: ratehelpers.hpp:40
@ ForwardRate
Definition: yieldtermstructures.hpp:113
@ MonotonicCubicNaturalSpline
Definition: yieldtermstructures.hpp:122
@ MonotonicLogCubicNaturalSpline
Definition: yieldtermstructures.hpp:123
@ MixedLinearKrugerCubic
Definition: yieldtermstructures.hpp:136
@ MonotonicParabolic
Definition: yieldtermstructures.hpp:130
@ FritschButlandLogCubic
Definition: yieldtermstructures.hpp:127