Main Page | Namespace List | Class Hierarchy | Class List | File List | Class Members | File Members

yieldCurve.h

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef yieldCurve_h
00003 #define yieldCurve_h
00004 
00005 #include "../common/types.h"
00006 #include "../common/date.h"
00007 #include "../common/interpolator.h" 
00008 #include "../common/matrix.h" 
00009 #include "..\common\utils.h"
00010 #include <string>
00011 #include <math.h>
00012 #include <algorithm>
00013 #include<time.h>
00014 
00015 using namespace std;
00016 
00017 #define YC_NAME_STRLEN 128
00018 #define YC_DEFAULT_NUMER_POINTS 15
00019 #define YC_MAX_NUMBER_POINTS 50
00020 
00024 enum interestComposition {
00025                 Discrete,               // 
00026                 Continuous              //
00027 };
00028         
00029 enum TypeOfRate {
00030         // Zero Coupon rate
00031      Cash,
00032          // rate quoted on a sawp rate basis : for maturity T = fixed rate so that the annualy compounded swap is 0
00033      Swap 
00034 };
00035 
00036 
00037 class yieldPoint
00038 {
00039 public:
00040 
00042         yieldPoint(void);
00043 
00050         yieldPoint(Real r,Real T,TypeOfRate type=Cash,DayCountConvention dayCount=ACT_360);
00051 
00053         ~yieldPoint(void);
00054 
00056         Real    getRate()     { return _rate;}
00057 
00059         Real    getMaturity() { return _maturity;}
00060 
00062         TypeOfRate     getType()     { return _type;}
00063 
00065         DayCountConvention getDayCount() { return _dayCount;}
00066 
00068         void     setRate(Real r)     { _rate = r;}
00069 
00071         void     setMaturity(Real m) { _maturity = m;}
00072 
00074         void     setType(TypeOfRate t)     { _type = t;}
00075 
00077         void     setDayCount(DayCountConvention d) { _dayCount = d;}
00078 
00079         static char *TypeAsString(TypeOfRate t);
00080 
00081 
00082         private:
00083                 Real    _rate;
00084                 Real    _maturity;
00085                 TypeOfRate     _type;
00086                 DayCountConvention _dayCount;
00087 };
00088 
00089 
00090 static const Real defaultshiftfactorForShortRate = 0.0001 ;//1 bp
00091 
00092 class yieldCurve
00093 {
00099         friend ostream& operator << (ostream &os, const yieldCurve& c);
00100         friend ostream& operator << (ostream &os, const yieldCurve* c) {
00101                 return os << *c;
00102         }
00103 
00104         public:
00106                 yieldCurve(void);
00107             
00111                 yieldCurve(Real flatRate);
00112         
00114                 void assignFlatRate(Real r=0.0);
00115 
00117                 void assignZCBrateAtIndex(Real rate,Natural i);
00118 
00120                 yieldCurve shiftZCBRateCurve(Real shift=defaultshiftfactorForShortRate);
00121 
00123                 yieldCurve rotateZCBRateCurve(Real moveInShortestRate=defaultshiftfactorForShortRate,Real maturityOfRotation=7);
00124             
00129                 yieldCurve(valarray<yieldPoint> yieldPoints,char *name = "unnamed");
00130 
00131                 ~yieldCurve(void);
00132 
00137                 virtual Real spotRate(Real maturity) const;
00138 
00142                 virtual valarray<Real> getMaturitiesInTheMarketCurve() const;
00143 
00147                 virtual valarray<Real> getMaturitiesInTheZCBCurve() const;
00148 
00153                 virtual Real spotRate(Date maturityDate) const;
00154 
00159                 virtual Real discountFactor(Real maturity,interestComposition composition=Continuous);
00160             
00165                 virtual Real discountFactor(Date maturityDate,interestComposition composition=Continuous);
00166 
00167 
00172                 virtual Real forwardDiscountFactor(Real forwardstart,Real lengthofcontractafterstart,interestComposition composition=Continuous);
00173             
00174 
00180                 virtual Real forwardRate(Real forwardStart,Real effectiveLengthOfTheContractAfterStart,interestComposition composition=Continuous);
00181 
00187                 virtual Real forwardRate(Date forwardStart,Date forwardEnd,interestComposition composition=Continuous);
00188 
00190                 virtual yieldCurve forwardZCBCurve(Real forwardStart);
00191             
00192                 char *getName() {return &_name[0];}
00193                 
00194                 virtual bool operator==(const yieldCurve& yours);
00195 
00196                 virtual bool operator!=(const yieldCurve& yours);
00197 
00198         private :
00199                 valarray<yieldPoint> _marketRates;     
00200                 valarray<yieldPoint> _zcbRates; 
00201                 char _name[YC_NAME_STRLEN];   
00202 
00205                 yieldPoint getPointAtMaturity(Real maturity);
00206 
00208                 void sortMarketRatesByMaturity();
00209 
00211                 void sortCashSwap();
00212 
00214                 valarray<yieldPoint> getSwapRates();
00215 
00216 
00221                 valarray<yieldPoint> getSequentSwapRates();
00222 
00231                 void computeZCBRatesBootstrap();
00232 
00239                 valarray<Real> SequentDiscountFactorsByInvertSwapMatrix();
00240 
00241 };
00242 
00243 
00244 #endif
00245 
00246 

Note: Generated nightly - reload for latest version
Generated on Thu Dec 22 23:12:37 2005 for terreneuve by doxygen 1.3.6