00001 #pragma once 00002 #ifndef convertiblebond_h 00003 #define convertiblebond_h 00004 00005 #include "../common/types.h" 00006 #include "../PartH/bond.h" 00007 #include "../PartC/asset.h" 00008 #include "./binomialTree.h" 00009 #include <iostream> 00010 #include <valarray> 00011 using namespace std; 00012 00013 // bond component defaults 00014 #define CB_DEFAULT_FACEAMOUNT 100 00015 #define CB_DEFAULT_MATURITY 1 00016 #define CB_DEFAULT_DAYCOUNT ACT_360 00017 #define CB_DEFAULT_RATE 0.05 00018 #define CB_DEFAULT_SPREAD 0.02 00019 00020 // stock component defaults 00021 #define CB_DEFAULT_SO 100 00022 #define CB_DEFAULT_SIGMA 0.30 00023 00024 // binomial tree defaults 00025 #define CB_DEFAULT_STEPS 4 00026 00027 // convertible component defaults 00028 #define CB_DEFAULT_RATIO 10 00029 #define CB_DEFAULT_CALLPRICE TN_INFINITY 00030 #define CB_DEFAULT_PUTPRICE 0 00031 00032 class convertiblebond : public riskybond { 00033 public: 00034 friend ostream& operator << (ostream &os, convertiblebond& cb); 00035 friend ostream& operator << (ostream &os, convertiblebond* cb) { 00036 return os << *cb; 00037 }; 00038 00041 convertiblebond( 00042 asset Stock, 00043 riskybond Bond, 00044 Real conversionRatio = CB_DEFAULT_RATIO, 00045 Natural nSteps = CB_DEFAULT_STEPS, 00046 Real callPrice = CB_DEFAULT_CALLPRICE, 00047 Real putPrice = CB_DEFAULT_PUTPRICE); 00048 virtual ~convertiblebond(void); 00049 virtual Real fairvalue(Date today); 00050 virtual Real fairvalue() {return fairvalue(_issue);}; 00051 00052 inline Real adjustedConversionRatio() const { 00053 return _conversionRatio / getFaceAmount() * 100; 00054 }; 00055 Real parity(void) const {return _conversionRatio * _stock.getPrice();}; 00056 Real delta(void) const {return delta(_issue);}; 00057 Real delta(Date today) const; 00058 Real parityDelta(void) const {return parityDelta(_issue);}; 00059 Real parityDelta(Date today) const {return delta(today)/adjustedConversionRatio();}; 00060 convertiblebond shiftedcbond(Real shift); 00061 Real rho(Date today) {return interestRateDelta(today);}; 00062 Real rho() {return rho(_issue);}; 00063 Real interestRateDelta(void) const {return interestRateDelta(_issue);}; 00064 Real interestRateDelta(Date today) const; 00065 Real gamma(void) const {return gamma(_issue);}; 00066 Real gamma(Date today) const; 00067 Real parityGamma(void) const {return parityGamma(_issue);}; 00068 Real parityGamma(Date today) const { 00069 return gamma(today)/pow(adjustedConversionRatio(), 2); 00070 }; 00071 00072 Natural getSteps(void) const {return _n;}; 00073 00074 protected: 00075 mutable binomialTree *_bt; 00076 mutable bool _btCached; 00077 00078 private: 00079 asset _stock; 00080 riskybond _bond; 00081 00082 Natural _n; 00083 Real _callPrice; 00084 Real _putPrice; 00085 Real _conversionRatio; 00086 00087 00088 mutable Real _price; 00089 mutable bool _priceCached; 00090 mutable Date _datepriceCached; 00091 00092 mutable Real _delta; 00093 mutable bool _deltaCached; 00094 mutable Date _datedeltaCached; 00095 00096 mutable Real _interestRateDelta; 00097 mutable bool _interestRateDeltaCached; 00098 mutable Date _dateinterestRateDeltaCached; 00099 00100 mutable Real _gamma; 00101 mutable bool _gammaCached; 00102 mutable Date _dategammaCached; 00103 00104 void 00105 copyObj(const convertiblebond &rhs); 00106 }; 00107 00108 #endif