00001 #include "../PartA/BlackScholes/OptionStrategy.h"
00002 #include "../PartK/VarianceSwap.h"
00003
00004 #include<iostream>
00005 #include<valarray>
00006 using namespace std;
00007
00008
00009 bool mainvarianceswap(void) {
00010
00011
00012 Real spot=100,strike1=90,strike2=110,vol1=0.2,vol2=0.22,vol3=0.21,mat=1.,rate=0.02;
00013 OptionStrategy* Strategy=new OptionStrategy();
00014 Strategy->addLongButterflySpread(spot,vol1,true,vol2,true,vol3,true,rate,strike1,strike2,mat,10);
00015
00016
00017 Real Kmin=200,Kmax=3500,step=10,Mat=1./12,SpotVix=1200,Fwd,ratevix=0.043,volvix=0.33;
00018 Real strike,result;
00019 Fwd=SpotVix*exp(ratevix/12);
00020 OptionStrategy* optionsVix=new OptionStrategy();
00021 unsigned int i=0;
00022 valarray<BlackScholes> bs;
00023 bs.resize(Natural((Kmax-Kmin)/step+1));
00024 while (Kmin+i*step<=Kmax) {
00025 strike=Kmin+i*step;
00026 if (strike<=Fwd)
00027 bs[i]=BlackScholes(SpotVix,volvix,true,ratevix,strike,Mat,Put);
00028 else
00029 bs[i]=BlackScholes(SpotVix,volvix,true,ratevix,strike,Mat,Call);
00030 optionsVix->addOneBlackScholesObject(&bs[i],1);
00031 i++;
00032 }
00033 VarianceSwap* vix=new VarianceSwap(optionsVix,Mat,Fwd);
00034 result=100*vix->getPrice();
00035 cout<<"The price of vix index is : "<<result<<" for a forward price of "<<Fwd<<" and vol of "<<volvix<<" and rate of "<<ratevix<<endl;
00036
00037
00038 VarianceSwap myvarswap=VarianceSwap(Strategy,1.,100);
00039 Real price=myvarswap.getPrice();
00040 cout<<"The price of the variance swap is " << myvarswap.getPrice() <<endl;
00041 if (price>0.015 && price <0.02) return true;
00042 else return false;
00043 }