* * MCPRICEEUROPE.RPF * Monte Carlo option pricing * * RATS User's Guide, Example from Section 16.5. * compute expire=5.0/12.0,strike=52.0,price=50.0,rate=.1,sigma=.40 compute hdrift=(rate-.5*sigma^2)*expire compute hsigma=sigma*sqrt(expire) compute ndraws=10000 * compute total=0.0,total2=0.0 do draw=1,ndraws compute payoff=exp(-rate*expire)*%max(0,price*exp(hdrift+%ran(hsigma))-strike) compute total=total+payoff compute total2=total2+payoff^2 end do draw compute mcvalue=total/ndraws compute mcvar =(total2/ndraws-mcvalue^2)/ndraws disp "Value by Monte Carlo" total/ndraws 'Std Dev' sqrt(mcvar) * compute d1=(log(price/strike)+expire*(rate+.5*sigma^2))/\$ (sigma*sqrt(expire)) compute d2=d1-sigma*sqrt(expire) * compute value=price*%cdf(d1)-strike*exp(-rate*expire)*%cdf(d2) disp "Value by Black-Scholes" value * * Antithetic acceleration * compute total=0.0,total2=0.0 do draw=1,ndraws compute u=%ran(hsigma) compute payoff1=exp(-rate*expire)*%max(0,price*exp(hdrift+u)-strike) compute payoff2=exp(-rate*expire)*%max(0,price*exp(hdrift-u)-strike) compute total =total +.5*(payoff1+payoff2) compute total2 =total2+.25*(payoff1+payoff2)^2 end do draw compute mcvalue=total/ndraws compute mcvar =(total2/ndraws-mcvalue^2)/ndraws disp "Value by MC with Antithetic Acceleration" total/ndraws "Std Dev" sqrt(mcvar)