5/18 matlab 作業 103071470 石磊. asianhalton.m % asianhalton.m function...
TRANSCRIPT
5/18 Matlab作業103071470 石磊
AsianHalton.m
• % AsianHalton.m• function [Price,CI]=AsianHalton(S0,X,r,T,sigma,NSamples,NRepl)• Payoff=zeros(NRepl,1);• Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl);• Payoff=max(0,mean(Path(:,2:(NSamples+1)),2)-X);• [Price,VarPrice,CI]=normfit(exp(-r*T).*Payoff);• end
AsianHalton.m
• S0=50;• X=50;• r=0.1;• T=5/12;• sigma=0.4;• NSamples=5;• NRepl1=1000;• NRepl2=2000;• NRepl3=3000;• NRepl4=10000;• NRepl5=30000;
AsianHalton.m
• [AsianHalton1000,CI1000]=AsianHalton(S0,X,r,T,sigma,NSamples,NRepl1)• [AsianHalton2000,CI2000]=AsianHalton(S0,X,r,T,sigma,NSamples,NRe
pl2)• [AsianHalton3000,CI3000]=AsianHalton(S0,X,r,T,sigma,NSamples,NRe
pl3)• [AsianHalton10000,CI10000]=AsianHalton(S0,X,r,T,sigma,NSamples,N
Repl4)• [AsianHalton30000,CI30000]=AsianHalton(S0,X,r,T,sigma,NSamples,N
Repl5)
• AsianHalton1000 =• 4.0289
• CI1000 =• 3.6465• 4.4113
• AsianHalton2000 =• 3.9979
• CI2000 =• 3.7294• 4.2664
• AsianHalton3000 =• 3.9619
• CI3000 =• 3.7460• 4.1778
• AsianHalton10000 =• 3.9441
• CI10000 =• 3.8270• 4.0613
• AsianHalton30000 =• 3.9742
• CI30000 =• 3.9073• 4.0412
Asian options—MC:max(S(T)-A,0)
• function [ P,CI ] = AsianMCCallPATH(s0,r,T,sigma,NSamples,NRepl )• Payoff=zeros(NRepl,1);• for(i=1:NRepl)• Path=AssetPaths1(s0,r,sigma,T,NSamples,1);• Payoff(i)=max(0,Path(NSamples+1)-mean(Path(2:(NSamples+1))));• end• [P,aux,CI]=normfit(exp(-r*T)*Payoff);
Asian options—CV:max(S(T)-A,0)• function [ P,CI ] = AsianMCCVCallPATH( s0,r,T,sigma,NSamples,NRepl1,Npilot )• TryPath=AssetPaths1(s0,r,sigma,T,NSamples,Npilot);• Stocksum=sum(TryPath,2);• PP=mean(TryPath(:,2:(NSamples+1)),2);• TryPayoff=exp(-r*T)*max(TryPath(NSamples+1)-PP,0);• Matcov=cov(Stocksum,TryPayoff);• c=-Matcov(1,2)/var(Stocksum);• dt=T/NSamples;• ExpSum=s0*(1-exp((NSamples+1)*r*dt))/(1-exp(r*dt));• ControlVars=zeros(NRepl1,1);• for i=1:NRepl1• StockPath=AssetPaths1(s0,r,sigma,T,NSamples,1);• Payoff=exp(-r*T)*max(0,StockPath(NSamples+1)-mean(StockPath(2:(NSamples+1))));• ControlVars(i)=Payoff+c*(sum(StockPath)-ExpSum);• end• [P,aux,CI]=normfit(ControlVars);
AsianMC V.S. AsianMCCV
• S0=50;• r=0.1;• T=5/12;• sigma=0.4;• NSamples=5;• NRepl1=50000;• NRepl2=45000;• NPilot=5000;
AsianMC V.S. AsianMCCV
• rand('seed',0);• [PMC,CIMC]=AsianMCCallPATH(S0,r,T,sigma,NSamples,NRepl1);• rand('seed',0);• [PMCCV,CIMCCV]=AsianMCCVCallPATH(S0,r,T,sigma,NSamples,NRepl2,NPilot);• PMC• CIMC• CIMC(2)-CIMC(1)• PMCCV• CIMCCV• CIMCCV(2)-CIMCCV(1)
• PMC =• 2.9453
• CIMC =• 2.9049• 2.9858
• ans =• 0.0809
• PMCCV =• 2.8672
• CIMCCV =• 2.8052• 2.9291
• ans =• 0.1239
Lookback Option call-MC
• function [Price,CI]=LookbackCallMC(S0,r,T,sigma,NSamples,NRepl1 )• Payoff=ones(1,NRepl1); • for i=1:NRepl1• Path=AssetPaths1(S0,r,sigma,T,NSamples,1);• Payoff(i)=max(0,Path(NSamples+1)-min(Path(2:(NSamples+1))));• end• [Price,VarPrice,CI]=normfit(exp(-r*T).*Payoff);• end
Lookback Option put-MC
• function [Price,CI]=LookbackPutMC(S0,r,T,sigma,NSamples,NRepl1 )• Payoff=ones(1,NRepl1); • for i=1:NRepl1• Path=AssetPaths1(S0,r,sigma,T,NSamples,1);• Payoff(i)=max(0,max(Path(2:(NSamples+1)))-Path(NSamples+1));• end• [Price,VarPrice,CI]=normfit(exp(-r*T).*Payoff);• end
Lookback Option-MC
• r=0.1;• T=5/12;• sigma=0.4;• rand('seed',0)• NSamples=60;• NRepl=50000;• [CALLMC,CI]=LookbackCallMC(S0,r,T,sigma,NSamples,NRepl)• [PUTMC,CI]=LookbackPutMC(S0,r,T,sigma,NSamples,NRepl)
• CALLMC =• 9.5123
• CI =• 9.4306• 9.5940
• PUTMC =• 8.7896
• CI =• 8.7333• 8.8458
Lookback Option call-CV• function [Price,CI]=LookbackCallCV(S0,r,T,sigma,NSteps,NRepl,NPilot)• Payoff=zeros(NPilot,1);• StockVals=zeros(NPilot,1);• for i=1:NPilot• Path=AssetPaths1(S0,r,sigma,T,NSteps,1);• StockVals(i,1)=Path(1,end);• Payoff(i,1)=max(0,Path(1,NSteps+1)-min(Path(1,2:(NSteps+1))));• end• OptionVals=exp(-r*T).*Payoff;• MatCov=cov(StockVals,OptionVals);• VarY=S0^2*exp(2*r*T)*(exp(T*sigma^2)-1);• c=-MatCov(1,2)/VarY;• ExpY=S0*exp(r*T);
Lookback Option call-CV
• for i=1:NRepl• Path1=AssetPaths1(S0,r,sigma,T,NSteps,1);• NewStockVals(i,1)=Path1(1,end);• Payoff1(i,1)=max(0,Path1(1,NSteps+1)-min(Path1(1,2:(NSteps+1))));• end• NewOptionVals=exp(-r*T).*Payoff1;• ControlVars=NewOptionVals+c*(NewStockVals-ExpY);• [Price,VarPrice,CI]=normfit(ControlVars);
Lookback Option put-CV• function [Price,CI] = LookbackPutCV(S0,r,T,sigma,NSteps,NRepl,NPilot)• Payoff=zeros(NPilot,1);• StockVals=zeros(NPilot,1);• for i=1:NPilot• Path=AssetPaths1(S0,r,sigma,T,NSteps,1);• StockVals(i,1)=Path(1,end);• Payoff(i,1)=max(0,max(Path(1,:))-Path(1,NSteps+1));• end• OptionVals=exp(-r*T).*Payoff;• MatCov=cov(StockVals,OptionVals);• VarY=S0^2*exp(2*r*T)*(exp(T*sigma^2)-1);• c=-MatCov(1,2)/VarY;• ExpY=S0*exp(r*T);
Lookback Option put-CV
• for i=1:NRepl• Path1=AssetPaths1(S0,r,sigma,T,NSteps,1);• NewStockVals(i,1)=Path1(1,end);• Payoff1(i,1)=max(0,max(Path1(1,:))-Path1(1,NSteps+1));• end• NewOptionVals=exp(-r*T).*Payoff1;• ControlVars=NewOptionVals+c*(NewStockVals-ExpY);• [Price,VarPrice,CI]=normfit(ControlVars);
Lookback Option-CV
• r=0.1;• T=5/12;• sigma=0.4;• rand('seed',0)• NSteps=60;• NPilot=5000;• NRepl=45000;• [CALLCV,CI]=LookbackCallCV(S0,r,T,sigma,NSteps,NRepl,NPilot)• [PUTCV,CI]=LookbackPutCV(S0,r,T,sigma,NSteps,NRepl,NPilot)
• CALLCV =• 9.5309
• CI =• 9.4964• 9.5654
• PUTCV =• 8.8542
• CI =• 8.8095• 8.8989
Lookback Option call-HALTON
• function [Price,CI]=LookbackCallHalton(S0,r,T,sigma,NSamples,NRepl)• Payoff=zeros(1,NRepl);• Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl);• for i=1:NRepl• Payoff(i)=max(0,Path(i,NSamples+1)-min(Path(i,:)));• end• [Price,VarPrice,CI]=normfit(exp(-r*T)*Payoff);
Lookback Option put-HALTON
• function [Price,CI]=LookbackPutHalton(S0,r,T,sigma,NSamples,NRepl)• Payoff=zeros(1,NRepl);• Path=HaltonPaths(S0,r,sigma,T,NSamples,NRepl);• for i=1:NRepl• Payoff(i)=max(0,max(Path(i,:))-Path(i,NSamples+1));• end• [Price,VarPrice,CI]=normfit(exp(-r*T)*Payoff);
Lookback Option-HALTON
• r=0.1;• T=5/12;• sigma=0.4;• NSteps=60;• NRepl=50000;• [CALLHALTON,CI]= LookbackCallHalton(S0,r,T,sigma,NSamples,NRepl)• [PUTHALTON,CI]= LookbackPutHalton(S0,r,T,sigma,NSamples,NRepl)
• CALLHALTON =• 11.8867
• CI =• 10.8591• 12.9143
• PUTHALTON =• 8.3786
• CI =• 8.3147• 8.4424
Lookback Option call-AV
• function [Price,CI]=LookbackCallAV(S0,r,T,sigma,NSamples,NRepl)• Payoff=ones(1,NRepl);• for i=1:NRepl• [Path1,Path2]=AssetPathsAV(S0,r,sigma,T,NSamples,1);• Payoff1(i)=max(0,Path1(NSamples+1)-min(Path1(2:(NSamples+1))));• Payoff2(i)=max(0,Path2(NSamples+1)-min(Path2(2:(NSamples+1))));• Payoff(i)=0.5*(Payoff1(i)+Payoff2(i));• end• [Price,VarPrice,CI]=normfit(exp(-r*T).*Payoff);
Lookback Option put-AV
• function [Price,CI]=LookbackPutAV(S0,r,T,sigma,NSamples,NRepl)• Payoff=ones(1,NRepl);• for i=1:NRepl• [Path1,Path2]=AssetPathsAV(S0,r,sigma,T,NSamples,1);• Payoff1(i)=max(0,max(Path1(2:(NSamples+1)))-Path1(NSamples+1));• Payoff2(i)=max(0,max(Path2(2:(NSamples+1)))-Path2(NSamples+1));• Payoff(i)=0.5*(Payoff1(i)+Payoff2(i));• end• [Price,VarPrice,CI]=normfit(exp(-r*T).*Payoff);
Lookback Option-AV
• r=0.1;• T=5/12;• sigma=0.4;• rand('seed',0)• NSteps=60;• NRepl=25000;• [CALLAV,CI]= LookbackCallAV(S0,r,T,sigma,NSamples,NRepl)• [PUTAV,CI]= LookbackPutAV(S0,r,T,sigma,NSamples,NRepl)
• CALLAV =• 9.6009
• CI =• 9.5495• 9.6523
• PUTAV =• 8.7894
• CI =• 8.7561• 8.8227
MC CV HALTON AV
CALL 9.5123 9.5309 11.8867 9.6009
PUT 8.7896 8.8542 8.3786 8.7894