00001 #include "../Interface/main.h" 00002 #include "../PartI/rainbowoption.h" 00003 #include"../PartB/YieldCurve.h" 00004 00005 #include<iostream> 00006 #include<valarray> 00007 using namespace std; 00008 00013 bool mainrainbowoptions(void){ 00014 cout<<"Test Rainbows with S1=100, S2=120, K=110, vols at 0.20, rates at 0.10 for 1 Year - correl at 0.5"<<endl; 00015 Date start=Date(); 00016 start.setDateToToday(); 00017 Real exp=1.0;//1Y option 00018 Real Strike=110; 00019 yieldCurve yc=yieldCurve(0.1); 00020 volsurface v1=volsurface(0.2); 00021 volsurface v2=volsurface(0.2); 00022 valarray<volsurface> vols(2); 00023 vols[0]=v1; 00024 vols[1]=v2; 00025 Real Spot1=100; 00026 Real Spot2=120; 00027 Real Mult=1; 00028 Real Correl12=0.5; 00029 Real weight1=1; 00030 Real weight2=1; 00031 bool outputmsg=false; 00032 00033 Real tempPrice=0.0; 00034 00035 /* Types (MonteCarlo, ClosedForm ) 00036 SpreadOptionMax, AssetsBasketMax, BestOf2AssetsCash, WorstOf2AssetsCash, BetterOf2Assets, 00037 WorseOf2Assets, Max2AssetsCall, Min2AssetsCall, Max2AssetsPut, Min2AssetsPut 00038 */ 00039 RainbowOption rb1=RainbowOption(SpreadOptionMax,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00040 RainbowOption rb2;// used for specific producs to adjust the strike 00041 00042 // no closed form 00043 cout<<"No closed form solution for these"<<endl; 00044 //this one will be used for spread to have a reasonnable strike for the spread 00045 rb2=RainbowOption(SpreadOptionMax,start,exp,0.0,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00046 00047 tempPrice=rb2.getPrice(); 00048 cout<<"Price2SpreadOptionMaxByMC - (Strike = 0.0) : "<<tempPrice<<endl; 00049 cout<<"delta 1: "<<rb2.getPartialDelta(1)<<endl; 00050 cout<<"delta 2: "<<rb2.getPartialDelta(2)<<endl; 00051 cout<<"gamma 1: "<<rb2.getPartialGamma(1)<<endl; 00052 cout<<"gamma 2: "<<rb2.getPartialGamma(2)<<endl; 00053 cout<<"vega 1: "<<rb2.getPartialVega(1)<<endl; 00054 cout<<"vega 2: "<<rb2.getPartialVega(2)<<endl; 00055 cout<<"correl risk : "<<rb2.getCorrelRisk()<<endl; 00056 cout<<"Rho : "<<rb2.getRho()<<endl; 00057 00058 rb1.setRainbowType(AssetsBasketMax); 00059 tempPrice=rb1.getPrice(); 00060 cout<<"Price2AssetsBasketMaxByMC : "<<tempPrice<<endl; 00061 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00062 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00063 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00064 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00065 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00066 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00067 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00068 cout<<"Rho : "<<rb1.getRho()<<endl; 00069 00070 //did not find closed form, should be one 00071 cout<<"\nWorstOf2AssetsCash"<<endl; 00072 rb1.setRainbowType(WorstOf2AssetsCash); 00073 tempPrice=rb1.getPrice(); 00074 cout<<"PriceWorstOf2AssetsCashByMC : "<<tempPrice<<endl; 00075 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00076 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00077 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00078 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00079 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00080 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00081 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00082 cout<<"Rho : "<<rb1.getRho()<<endl; 00083 00084 //comparisons 00085 cout<<"\nCompare Best Of 2 Assets plus cash"<<endl; 00086 rb1.setRainbowType(BestOf2AssetsCash); 00087 tempPrice=rb1.getPrice(MonteCarlo); 00088 cout<<"PriceBestOf2AssetsCashByMC 1: "<<tempPrice<<endl; 00089 tempPrice=rb1.getPrice(ClosedForm); 00090 cout<<"PriceByClosedForm_BestOf2_plusCash : "<<tempPrice<<endl; 00091 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00092 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00093 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00094 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00095 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00096 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00097 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00098 cout<<"Rho : "<<rb1.getRho()<<endl; 00099 00100 cout<<"\nCompare Max Of 2 Assets Call"<<endl; 00101 rb1.setRainbowType(Max2AssetsCall); 00102 tempPrice=rb1.getPrice(MonteCarlo); 00103 cout<<"PriceMax2AssetsByMCCall : "<<tempPrice<<endl; 00104 tempPrice=rb1.getPrice(ClosedForm); 00105 cout<<"PriceByClosedForm_MaxOf2_call : "<<tempPrice<<endl; 00106 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00107 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00108 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00109 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00110 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00111 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00112 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00113 cout<<"Rho : "<<rb1.getRho()<<endl; 00114 00115 cout<<"\nCompare Min Of 2 Assets Call"<<endl; 00116 rb1.setRainbowType(Min2AssetsCall); 00117 tempPrice=rb1.getPrice(MonteCarlo); 00118 cout<<"PriceMin2AssetsByMCCall : "<<tempPrice<<endl; 00119 tempPrice=rb1.getPrice(ClosedForm); 00120 cout<<"PriceByClosedForm_MinOf2_call : "<<tempPrice<<endl; 00121 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00122 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00123 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00124 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00125 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00126 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00127 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00128 cout<<"Rho : "<<rb1.getRho()<<endl; 00129 00130 cout<<"\nCompare Max Of 2 Assets Put"<<endl; 00131 rb1.setRainbowType(Max2AssetsPut); 00132 tempPrice=rb1.getPrice(MonteCarlo); 00133 cout<<"PriceMax2AssetsByMCPut : "<<tempPrice<<endl; 00134 tempPrice=rb1.getPrice(ClosedForm); 00135 cout<<"PriceByClosedForm_MaxOf2_put : "<<tempPrice<<endl; 00136 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00137 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00138 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00139 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00140 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00141 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00142 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00143 cout<<"Rho : "<<rb1.getRho()<<endl; 00144 00145 cout<<"\nCompare Min Of 2 Assets Put"<<endl; 00146 rb1.setRainbowType(Min2AssetsPut); 00147 tempPrice=rb1.getPrice(MonteCarlo); 00148 cout<<"PriceMin2AssetsByMCPut : "<<tempPrice<<endl; 00149 tempPrice=rb1.getPrice(ClosedForm); 00150 cout<<"PriceByClosedForm_MinOf2_put : "<<tempPrice<<endl; 00151 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00152 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00153 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00154 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00155 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00156 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00157 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00158 cout<<"Rho : "<<rb1.getRho()<<endl; 00159 00160 cout<<"\nCompare Better of 2"<<endl; 00161 rb1.setRainbowType(BetterOf2Assets); 00162 tempPrice=rb1.getPrice(MonteCarlo); 00163 cout<<"PriceByMc_BetterOf2Assets : "<<tempPrice<<endl; 00164 tempPrice=rb1.getPrice(ClosedForm); 00165 cout<<"PriceByClosedForm_BetterOf2 : "<<tempPrice<<endl; 00166 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00167 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00168 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00169 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00170 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00171 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00172 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00173 cout<<"Rho : "<<rb1.getRho()<<endl; 00174 00175 cout<<"\nCompare Worse of 2"<<endl; 00176 rb1.setRainbowType(WorseOf2Assets); 00177 tempPrice=rb1.getPrice(MonteCarlo); 00178 cout<<"PriceByMc_WorseOf2Assets : "<<tempPrice<<endl; 00179 tempPrice=rb1.getPrice(ClosedForm); 00180 cout<<"PriceByClosedForm_WorseOf2 : "<<tempPrice<<endl; 00181 cout<<"delta 1: "<<rb1.getPartialDelta(1)<<endl; 00182 cout<<"delta 2: "<<rb1.getPartialDelta(2)<<endl; 00183 cout<<"gamma 1: "<<rb1.getPartialGamma(1)<<endl; 00184 cout<<"gamma 2: "<<rb1.getPartialGamma(2)<<endl; 00185 cout<<"vega 1: "<<rb1.getPartialVega(1)<<endl; 00186 cout<<"vega 2: "<<rb1.getPartialVega(2)<<endl; 00187 cout<<"vega 1: "<<rb1.getPartialVega(1,MonteCarlo)<<endl; 00188 cout<<"vega 2: "<<rb1.getPartialVega(2,MonteCarlo)<<endl; 00189 cout<<"correl risk : "<<rb1.getCorrelRisk()<<endl; 00190 cout<<"Rho : "<<rb1.getRho()<<endl; 00191 00192 00193 00194 00195 // to generate set of prices for the differences 00196 // 5 hours to run ... 00197 00198 // 00199 // Real S1,S2,K,vol1,vol2,correl; 00200 // Real price,d1,d2,g1,g2,v1,v2,rho,corr,theta; 00201 // yieldCurve yctest=yieldCurve(0.05); 00202 // volsurface vs1,vs2; 00203 // valarray<volsurface> vols(2); 00204 // Date start=Date(); 00205 // start.setDateToToday(); 00206 // Real exp=2.0;//1Y option 00207 // 00208 // RainbowOption rb2; 00209 // ofstream myfile; 00210 // myfile.open ("c:/resRainbow.txt"); 00211 // myfile<<"2Y Rainbow Options with 0.05 rate to maturity, one spot at 100 - Results\n"; 00212 // myfile<<"S1,S2,K,correl,vol1,vol2,Type,Method,Price,delta1,delta2,gamma1,gamma2,Vega1,Vega2,Rho,Correl,Theta\n"; 00213 // 00214 // for(S1=80;S1<=120;S1+=20){ 00215 // for(S2=100;S2<=100;S2+=10){//symetry so only one oscillation should be enough 00216 // for(K=80;K<130;K+=20){ 00217 // for(correl=-1;correl<=1;correl+=0.5){ 00218 // for(vol1=0.1;vol1<0.4;vol1+=0.1){ 00219 // for(vol2=0.2;vol2<=0.2;vol2+=0.1){//symetry 00220 // vs1=volsurface(vol1); 00221 // vs2=volsurface(vol2); 00222 // vols[0]=vs1; 00223 // vols[1]=vs2; 00225 // rb2=RainbowOption(BestOf2AssetsCash,start,exp,K,yctest,vols,S1,S2,1,correl,1,1,false); 00226 // 00227 // price=rb2.getPrice(MonteCarlo); 00228 // d1=rb2.getPartialDelta(1,MonteCarlo); 00229 // d2=rb2.getPartialDelta(2,MonteCarlo); 00230 // g1=rb2.getPartialGamma(1,MonteCarlo); 00231 // g2=rb2.getPartialGamma(2,MonteCarlo); 00232 // v1=rb2.getPartialVega(1,MonteCarlo); 00233 // v2=rb2.getPartialVega(2,MonteCarlo); 00234 // corr=rb2.getCorrelRisk(MonteCarlo); 00235 // rho=rb2.getRho(MonteCarlo); 00236 // theta=rb2.getTheta(MonteCarlo); 00237 // 00238 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"BOCash"<<","<<"MC"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00239 // 00240 // price=rb2.getPrice(ClosedForm); 00241 // d1=rb2.getPartialDelta(1,ClosedForm); 00242 // d2=rb2.getPartialDelta(2,ClosedForm); 00243 // g1=rb2.getPartialGamma(1,ClosedForm); 00244 // g2=rb2.getPartialGamma(2,ClosedForm); 00245 // v1=rb2.getPartialVega(1,ClosedForm); 00246 // v2=rb2.getPartialVega(2,ClosedForm); 00247 // corr=rb2.getCorrelRisk(ClosedForm); 00248 // rho=rb2.getRho(ClosedForm); 00249 // theta=rb2.getTheta(ClosedForm); 00250 // 00251 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"BOCash"<<","<<"CF"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00252 // 00253 // rb2.setRainbowType(Max2AssetsCall); 00254 // 00255 // price=rb2.getPrice(MonteCarlo); 00256 // d1=rb2.getPartialDelta(1,MonteCarlo); 00257 // d2=rb2.getPartialDelta(2,MonteCarlo); 00258 // g1=rb2.getPartialGamma(1,MonteCarlo); 00259 // g2=rb2.getPartialGamma(2,MonteCarlo); 00260 // v1=rb2.getPartialVega(1,MonteCarlo); 00261 // v2=rb2.getPartialVega(2,MonteCarlo); 00262 // corr=rb2.getCorrelRisk(MonteCarlo); 00263 // rho=rb2.getRho(MonteCarlo); 00264 // theta=rb2.getTheta(MonteCarlo); 00265 // 00266 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"MaxCall"<<","<<"MC"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00267 // 00268 // price=rb2.getPrice(ClosedForm); 00269 // d1=rb2.getPartialDelta(1,ClosedForm); 00270 // d2=rb2.getPartialDelta(2,ClosedForm); 00271 // g1=rb2.getPartialGamma(1,ClosedForm); 00272 // g2=rb2.getPartialGamma(2,ClosedForm); 00273 // v1=rb2.getPartialVega(1,ClosedForm); 00274 // v2=rb2.getPartialVega(2,ClosedForm); 00275 // corr=rb2.getCorrelRisk(ClosedForm); 00276 // rho=rb2.getRho(ClosedForm); 00277 // theta=rb2.getTheta(ClosedForm); 00278 // 00279 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"MaxCall"<<","<<"CF"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00281 // rb2.setRainbowType(Min2AssetsPut); 00282 // 00283 // price=rb2.getPrice(MonteCarlo); 00284 // d1=rb2.getPartialDelta(1,MonteCarlo); 00285 // d2=rb2.getPartialDelta(2,MonteCarlo); 00286 // g1=rb2.getPartialGamma(1,MonteCarlo); 00287 // g2=rb2.getPartialGamma(2,MonteCarlo); 00288 // v1=rb2.getPartialVega(1,MonteCarlo); 00289 // v2=rb2.getPartialVega(2,MonteCarlo); 00290 // corr=rb2.getCorrelRisk(MonteCarlo); 00291 // rho=rb2.getRho(MonteCarlo); 00292 // theta=rb2.getTheta(MonteCarlo); 00293 // 00294 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"MinPut"<<","<<"MC"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00295 // 00296 // price=rb2.getPrice(ClosedForm); 00297 // d1=rb2.getPartialDelta(1,ClosedForm); 00298 // d2=rb2.getPartialDelta(2,ClosedForm); 00299 // g1=rb2.getPartialGamma(1,ClosedForm); 00300 // g2=rb2.getPartialGamma(2,ClosedForm); 00301 // v1=rb2.getPartialVega(1,ClosedForm); 00302 // v2=rb2.getPartialVega(2,ClosedForm); 00303 // corr=rb2.getCorrelRisk(ClosedForm); 00304 // rho=rb2.getRho(ClosedForm); 00305 // theta=rb2.getTheta(ClosedForm); 00306 // 00307 // myfile <<S1<<","<<S2<<","<<K<<","<<correl<<","<<vol1<<","<<vol2<<","<<"MinPut"<<","<<"CF"<<","<<price<<","<<d1<<","<<d2<<","<<g1<<","<<g2<<","<<v1<<","<<v2<<","<<rho<<","<<corr<<","<<theta<<"\n"; 00308 // 00309 // } 00310 // } 00311 // } 00312 // } 00313 // } 00314 // } 00315 // myfile.close(); 00316 00317 00318 // output greeks and price vs strike - All with closed form, else it is a pain 00319 //ofstream myfile; 00320 //myfile.open ("c:/resRainbowPerStrike.txt"); 00321 00322 //myfile<<"Test Rainbows with S1=100, S2=100, vols at 0.20, rates at 0.10 for 1 Year"<<"\n"; 00323 //Date start=Date(); 00324 //start.setDateToToday(); 00325 //Real exp=1.0;//1Y option 00326 //Real Strike;; 00327 //yieldCurve yc=yieldCurve(0.1); 00328 //volsurface v1=volsurface(0.2); 00329 //volsurface v2=volsurface(0.2); 00330 //valarray<volsurface> vols(2); 00331 //vols[0]=v1; 00332 //vols[1]=v2; 00333 //Real Spot1=100; 00334 //Real Spot2=100; 00335 //Real Mult=1; 00336 //Real Correl12=0.5; 00337 //Real weight1=1; 00338 //Real weight2=1; 00339 //bool outputmsg=false; 00340 00341 //Real tempPrice=0.0; 00342 00344 // BestOf2AssetsCash, WorstOf2AssetsCash, BetterOf2Assets, 00345 // Max2AssetsCall, Min2AssetsCall, Max2AssetsPut, Min2AssetsPut 00346 //*/ 00347 //RainbowOption rb1; 00348 //myfile<<"Strike,Price,Delta,Gamma,Vega,Correl,Rho\n"; 00349 //myfile<<"BOCash"; 00350 //for(Strike=50;Strike<=150;Strike+=5){ 00351 // rb1=RainbowOption(BestOf2AssetsCash,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00352 // myfile<<Strike<<","<<rb1.getPrice(); 00353 // myfile<<","<<rb1.getPartialDelta(1); 00354 // myfile<<","<<rb1.getPartialGamma(1); 00355 // myfile<<","<<rb1.getPartialVega(1); 00356 // myfile<<","<<rb1.getCorrelRisk(); 00357 // myfile<<","<<rb1.getRho(); 00358 // myfile<<"\n"; 00359 //} 00360 //myfile<<"Better"; 00361 //for(Strike=50;Strike<=150;Strike+=5){ 00362 // rb1=RainbowOption(BetterOf2Assets,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00363 // myfile<<Strike<<","<<rb1.getPrice(); 00364 // myfile<<","<<rb1.getPartialDelta(1); 00365 // myfile<<","<<rb1.getPartialGamma(1); 00366 // myfile<<","<<rb1.getPartialVega(1); 00367 // myfile<<","<<rb1.getCorrelRisk(); 00368 // myfile<<","<<rb1.getRho(); 00369 // myfile<<"\n"; 00370 //} 00371 //myfile<<"Worse"; 00372 //for(Strike=50;Strike<=150;Strike+=5){ 00373 // rb1=RainbowOption(WorseOf2Assets,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00374 // myfile<<Strike<<","<<rb1.getPrice(); 00375 // myfile<<","<<rb1.getPartialDelta(1); 00376 // myfile<<","<<rb1.getPartialGamma(1); 00377 // myfile<<","<<rb1.getPartialVega(1); 00378 // myfile<<","<<rb1.getCorrelRisk(); 00379 // myfile<<","<<rb1.getRho(); 00380 // myfile<<"\n"; 00381 //} 00382 //myfile<<"MaxCall"; 00383 //for(Strike=50;Strike<=150;Strike+=5){ 00384 // rb1=RainbowOption(Max2AssetsCall,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00385 // myfile<<Strike<<","<<rb1.getPrice(); 00386 // myfile<<","<<rb1.getPartialDelta(1); 00387 // myfile<<","<<rb1.getPartialGamma(1); 00388 // myfile<<","<<rb1.getPartialVega(1); 00389 // myfile<<","<<rb1.getCorrelRisk(); 00390 // myfile<<","<<rb1.getRho(); 00391 // myfile<<"\n"; 00392 //} 00393 //myfile<<"MinCall"; 00394 //for(Strike=50;Strike<=150;Strike+=5){ 00395 // rb1=RainbowOption(Min2AssetsCall,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00396 // myfile<<Strike<<","<<rb1.getPrice(); 00397 // myfile<<","<<rb1.getPartialDelta(1); 00398 // myfile<<","<<rb1.getPartialGamma(1); 00399 // myfile<<","<<rb1.getPartialVega(1); 00400 // myfile<<","<<rb1.getCorrelRisk(); 00401 // myfile<<","<<rb1.getRho(); 00402 // myfile<<"\n"; 00403 //} 00404 //myfile<<"MaxPut"; 00405 //for(Strike=50;Strike<=150;Strike+=5){ 00406 // rb1=RainbowOption(Max2AssetsPut,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00407 // myfile<<Strike<<","<<rb1.getPrice(); 00408 // myfile<<","<<rb1.getPartialDelta(1); 00409 // myfile<<","<<rb1.getPartialGamma(1); 00410 // myfile<<","<<rb1.getPartialVega(1); 00411 // myfile<<","<<rb1.getCorrelRisk(); 00412 // myfile<<","<<rb1.getRho(); 00413 // myfile<<"\n"; 00414 //} 00415 //myfile<<"MinPut"; 00416 //for(Strike=50;Strike<=150;Strike+=5){ 00417 // rb1=RainbowOption(Min2AssetsPut,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00418 // myfile<<Strike<<","<<rb1.getPrice(); 00419 // myfile<<","<<rb1.getPartialDelta(1); 00420 // myfile<<","<<rb1.getPartialGamma(1); 00421 // myfile<<","<<rb1.getPartialVega(1); 00422 // myfile<<","<<rb1.getCorrelRisk(); 00423 // myfile<<","<<rb1.getRho(); 00424 // myfile<<"\n"; 00425 //} 00426 //myfile.close(); 00427 00428 // for Jason 00429 //Date start=Date(); 00430 //start.setDateToToday(); 00431 //Real exp=1.0;//1Y option 00432 //Real Strike=100; 00433 //yieldCurve yc=yieldCurve(0.0457296); 00434 //volsurface v1=volsurface(0.2); 00435 //volsurface v2=volsurface(0.2); 00436 //valarray<volsurface> vols(2); 00437 //vols[0]=v1; 00438 //vols[1]=v2; 00439 //Real Spot1=100; 00440 //Real Spot2=105; 00441 //Real Mult=1; 00442 //Real Correl12=0.4; 00443 //Real weight1=0.5; 00444 //Real weight2=0.5; 00445 //bool outputmsg=false; 00446 00447 //Real tempPrice=0.0; 00448 00449 //RainbowOption rb1=RainbowOption(SpreadOptionMax,start,exp,Strike,yc,vols,Spot1,Spot2,Mult,Correl12,weight1,weight2,outputmsg); 00450 00452 //cout<<"\nWorstOf2AssetsCash<<endl; 00453 //rb1.setRainbowType(WorstOf2AssetsCash); 00454 //tempPrice=rb1.getPrice(); 00455 //cout<<"PriceWorstOf2AssetsCashByMC : "<<tempPrice<<endl; 00456 00458 //cout<<"\nCompare Best Of 2 Assets plus cash"<<endl; 00459 //rb1.setRainbowType(BestOf2AssetsCash); 00460 //tempPrice=rb1.getPrice(MonteCarlo); 00461 //cout<<"PriceBestOf2AssetsCashByMC 1: "<<tempPrice<<endl; 00462 00463 //cout<<"\nCompare Max Of 2 Assets Call"<<endl; 00464 //rb1.setRainbowType(Max2AssetsCall); 00465 //tempPrice=rb1.getPrice(MonteCarlo); 00466 //cout<<"PriceMax2AssetsByMCCall : "<<tempPrice<<endl; 00467 00468 //cout<<"\nCompare Min Of 2 Assets Call"<<endl; 00469 //rb1.setRainbowType(Min2AssetsCall); 00470 //tempPrice=rb1.getPrice(MonteCarlo); 00471 //cout<<"PriceMin2AssetsByMCCall : "<<tempPrice<<endl; 00472 00473 //cout<<"\nCompare Max Of 2 Assets Put"<<endl; 00474 //rb1.setRainbowType(Max2AssetsPut); 00475 //tempPrice=rb1.getPrice(MonteCarlo); 00476 //cout<<"PriceMax2AssetsByMCPut : "<<tempPrice<<endl; 00477 00478 //cout<<"\nCompare Min Of 2 Assets Put"<<endl; 00479 //rb1.setRainbowType(Min2AssetsPut); 00480 //tempPrice=rb1.getPrice(MonteCarlo); 00481 //cout<<"PriceMin2AssetsByMCPut : "<<tempPrice<<endl; 00482 // 00483 //cout<<"\nCompare Better of 2"<<endl; 00484 //rb1.setRainbowType(BetterOf2Assets); 00485 //tempPrice=rb1.getPrice(MonteCarlo); 00486 //cout<<"PriceByMc_BetterOf2Assets : "<<tempPrice<<endl; 00487 00488 //cout<<"\nCompare Worse of 2"<<endl; 00489 //rb1.setRainbowType(WorseOf2Assets); 00490 //tempPrice=rb1.getPrice(MonteCarlo); 00491 //cout<<"PriceByMc_WorseOf2Assets : "<<tempPrice<<endl; 00492 00493 return false; 00494 }