00001 #pragma once 00002 #ifndef asset_h 00003 #define asset_h 00004 00005 #include "../common/types.h" 00006 #include "../common/date.h" 00007 #include "../PartB/yieldCurve.h" 00008 00009 #define ASSET_DEFAULT_VOL 0.20 00010 00011 using namespace std; 00012 00019 class flowSchedule 00020 { 00021 private: 00022 Date _dateOfFlowPayment; 00023 Real _FlowAmountInPercent; 00024 BusinessDayConvention _businessDayConventionOnPaymentDate; 00025 00026 public: 00028 flowSchedule(void); 00029 00030 ~flowSchedule(void); 00031 00033 flowSchedule(Date date,Real percent,BusinessDayConvention bd=Unadjusted); 00034 00036 void setDate(Date date) {_dateOfFlowPayment =date;} 00037 00039 void setAmount(Real percent) {_FlowAmountInPercent =percent;} 00040 00042 void setBusDayConv(BusinessDayConvention bd) {_businessDayConventionOnPaymentDate =bd;} 00043 00045 Date getDate() {return _dateOfFlowPayment ;} 00046 00048 Real getAmount() {return _FlowAmountInPercent;} 00049 00051 BusinessDayConvention getBusDayConv() {return _businessDayConventionOnPaymentDate;} 00052 }; 00053 00054 class asset 00055 { 00056 private: 00057 Real _currentPrice; 00058 yieldCurve _yc; 00059 bool _areDividendsAsGrowingRate; 00060 Real _dividendGrowingRate; 00061 valarray<flowSchedule> _announcedDividendFlows; 00062 Currency _denomCur; 00063 Real _volatility; 00064 public: 00066 asset(void); 00067 00077 asset(Real price,yieldCurve yc,bool areDividendsAsRate=true,Real divRate=0.0,valarray<flowSchedule> flowsc=valarray<flowSchedule>(),Currency ccy=USD,Real volatility = ASSET_DEFAULT_VOL); 00078 00079 asset(Real price, Real volatility = ASSET_DEFAULT_VOL); 00080 00082 Real getDelta() {return 1.0;} 00083 00085 Real getRho(Real T) ; 00086 00088 void setPrice(Real p) {_currentPrice =p;} 00089 00091 void setYieldCurve(yieldCurve yc) {_yc =yc;} 00092 00094 void setDivAsRate(Real rate=0.0); 00095 00097 void setDivFlows(flowSchedule fc) {_announcedDividendFlows=fc;} 00098 00100 void setCcy(Currency ccy) {_denomCur=ccy;} 00101 00103 void setVolatility(Real volatility) {_volatility = volatility;} 00104 00106 Real getPrice() const {return _currentPrice ;} 00107 00109 yieldCurve getYieldCurve() {return _yc ;} 00110 00112 bool areDivAsRate() {return _areDividendsAsGrowingRate;} 00113 00115 Real getRate() {return _dividendGrowingRate;} 00116 00118 valarray<flowSchedule> getFlowSchedule() {return _announcedDividendFlows;} 00119 00121 Currency GetCurrencyFormat() {return _denomCur;} 00122 00124 Real GetVolatility() const {return _volatility;} 00125 00127 virtual Real Price(); 00128 00130 Real forwardPrice(Date maturityDate); 00131 00133 Real forwardPrice(Real T); 00134 ~asset(void); 00135 }; 00136 #endif