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

rainbowoption.h

Go to the documentation of this file.
00001 #pragma once
00002 #ifndef rainbowoption_h
00003 #define rainbowoption_h
00004 
00005 #include "../common/types.h"
00006 #include "../common/matrix.h" 
00007 #include "../common/date.h" 
00008 #include "..\PartB\yieldCurve.h"
00009 #include "..\PartE\volsurface.h"
00010 #include <valarray> 
00011 
00012 #include"../PartA/MonteCarlo1/MersenneTwister.h"
00013 #include"../PartA/MonteCarlo1/GaussianProcess.h"
00014 #include"../PartA/MonteCarlo1/PayOff.h"
00015 #include"../PartA/MonteCarlo1/Random.h"
00016 #include"../PartA/MonteCarlo1/Drift.h"
00017 #include"../PartA/MonteCarlo1/MCEngine.h"
00018 #include"../PartA/MonteCarlo1/PayOff.h"
00019 
00020 #include "../PartA/BlackScholes/BlackScholes.h"
00021 
00022 #define RO_DEFAULT_STRIKE 100
00023 #define RO_DEFAULT_VOL 0.15
00024 #define RO_DEFAULT_RATE 0.02
00025 #define RO_DEFAULT_MATURITY 1
00026 #define RO_DEFAULT_NB_ASSETS 2
00027 #define RO_DEFAULT_MULTIPLIER 1
00028 
00029 #define RO_NPATHS 100000
00030 #define RO_SEED 100000000
00031 
00032 #define EPSILON 0.00000001
00033 #define GREEKAPPROX 0.01
00034 
00035 using namespace std;
00041 enum priceType {
00042         MonteCarlo,             // 
00043         ClosedForm              //
00044 };
00045 
00046 enum rainbowType {
00047         SpreadOptionMax,
00048         AssetsBasketMax,
00049         BestOf2AssetsCash,
00050         WorstOf2AssetsCash,
00051         BetterOf2Assets,
00052         WorseOf2Assets,
00053         Max2AssetsCall,
00054         Min2AssetsCall,
00055         Max2AssetsPut,
00056         Min2AssetsPut
00057 };
00058 
00059 class RainbowOption
00060 {
00061 public:
00069         RainbowOption(void);
00070 
00074         RainbowOption(rainbowType type,Date startDate,Real expiry,Real Strike,yieldCurve yc,valarray<volsurface> vols,valarray <Real> spots=valarray<Real>(RO_DEFAULT_STRIKE,RO_DEFAULT_NB_ASSETS),Real Multiplier=RO_DEFAULT_MULTIPLIER,Matrix Correl = IdentityMatrix(RO_DEFAULT_NB_ASSETS),valarray<Real> weights=valarray<Real>(1/(Real)RO_DEFAULT_NB_ASSETS,RO_DEFAULT_NB_ASSETS),bool outputMsgs=false);
00075 
00080         RainbowOption(rainbowType type,Date start,Real exp,Real Strike,yieldCurve yc,valarray<volsurface> vols,Real Spot1,Real Spot2,Real Mult=RO_DEFAULT_MULTIPLIER,Real Correl12=0,Real weight1=0.5,Real weight2=0.5,bool outputMsgs=false);
00081         ~RainbowOption(void);
00082 
00087         Real getPrice(priceType priceMethod=ClosedForm,LongNatural nPaths=RO_NPATHS);
00088 
00090         Real getPartialDelta(Natural security,priceType priceMethod=ClosedForm);
00091 
00093         Real getPartialGamma(Natural security,priceType priceMethod=ClosedForm);
00094 
00096         Real getPartialVega(Natural security,priceType priceMethod=ClosedForm);
00097 
00099         Real getDelta(priceType priceMethod=ClosedForm);
00100 
00102         Real getGamma(priceType priceMethod=ClosedForm);
00103 
00105         Real getVega(priceType priceMethod=ClosedForm);
00106 
00108         Real getCorrelRisk(priceType priceMethod=ClosedForm);
00109 
00111         Real getRho(priceType priceMethod=ClosedForm);
00112 
00114         Real getTheta(priceType priceMethod=ClosedForm);
00115 
00116         rainbowType getRainbowType(){return _type;}
00117         void setRainbowType(rainbowType newType){_type=newType;}
00118 
00119 private:
00120         // MC Prices
00121         /*1 */Real PriceByMc_2SpreadOptionMax(LongNatural nPaths=RO_NPATHS);
00122         /*2 */Real PriceByMc_2AssetsBasketMax(LongNatural nPaths=RO_NPATHS);
00123         /*3 */Real PriceByMc_BestOf2AssetsCash(LongNatural nPaths=RO_NPATHS);
00124         /*4 */Real PriceByMc_WorstOf2AssetsCash(LongNatural nPaths=RO_NPATHS);
00125         /*5 */Real PriceByMc_BetterOf2Assets(LongNatural nPaths=RO_NPATHS);
00126         /*6 */Real PriceByMc_WorseOf2Assets(LongNatural nPaths=RO_NPATHS);
00127         /*7 */Real PriceByMc_Max2AssetsCall(LongNatural nPaths=RO_NPATHS);
00128         /*8 */Real PriceByMc_Min2AssetsCall(LongNatural nPaths=RO_NPATHS);
00129         /*9 */Real PriceByMc_Max2AssetsPut(LongNatural nPaths=RO_NPATHS);
00130         /*10*/Real PriceByMc_Min2AssetsPut(LongNatural nPaths=RO_NPATHS);
00131 
00132         // Closed forms
00133         /*1 */ // no Spread - see Rubinstein
00134         /*2 */ // no Basket - see Rubinstein
00135         /*3 */Real PriceByClosedForm_BestOf2_plusCash();
00136         /*4 */ // no worse of + cash
00137         /*5 */Real PriceByClosedForm_BetterOf2();
00138         /*6 */Real PriceByClosedForm_WorseOf2();
00139         /*7 */Real PriceByClosedForm_MaxOf2_call();
00140         /*8 */Real PriceByClosedForm_MinOf2_call();
00141         /*9 */Real PriceByClosedForm_MaxOf2_put();
00142         /*10*/Real PriceByClosedForm_MinOf2_put();
00143 
00144 
00145 
00146 private:
00147         // output messages ?
00148         bool _outputMsgs;
00149 
00150         // general members
00151         Date _startDate;
00152         Real _expiryInYears;
00153         Natural _NumberOfAssets;
00154         Real _Strike;
00155         valarray <Real> _spots;   
00156         Real _Multiplier;
00157         valarray <Real> _weights;   
00158         Matrix _CorrelationMatrix; // useless for 2 assets, but if we have an eye on more than 2, will be useful
00159         valarray<Real> _volatilities;
00160         valarray<volsurface> _volatilitiesSurfaces; // need to store these 2, as for the spread, the vol is NOT from the strike. say ATM
00161         yieldCurve _yc; // no quanto so risk free rate is unique.
00162 
00163         rainbowType _type;
00164 
00165 
00166         void reassignVolsAtThemoney();
00167         void reassignVolsAtThestrike();
00168 
00169         // for MC Pricing
00170         PayOff _thePayOff;
00171         Real _DFTomaturity;
00172         valarray<Drift> _Drifts;
00173         Random *_pRandom;
00174         MCEngine _MCEngine;
00175         Real _gaussianSample;
00176         valarray<Real> _TerminalPoints;
00177         valarray<GaussianProcess> _pHazardRateProcesses;
00178 
00179         void instanciateMCVariables();
00180         LongNatural _seed;
00181 
00182         //For closed form solutions for 2 assets
00183         Real sigmaA;
00184         void compute_sigmaA();
00185         Real rho1;
00186         void compute_rho1();
00187         Real rho2;
00188         void compute_rho2();
00189         Real d1;
00190         void compute_d1();
00191         Real d2;
00192         void compute_d2();
00193         Real d3;
00194         void compute_d3();
00195         Real d4;
00196         void compute_d4();
00197         Real A;
00198         void compute_A();
00199         Real B;
00200         void compute_B();
00201         Real C;
00202         void compute_C();
00203 
00204         bool haveClosedFormVariablesBeenComputed;
00205         void compute_ClosedFormsParameters();
00206 
00207 
00208 };
00209 #endif
00210 

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