Examples / MCPRICEEUROPE.RPF |
MCPRICEEUROPE.RPF is an example of Monte Carlo option pricing. It prices a vanilla European call using Monte Carlo, estimates the standard deviation of the error in this calculation, and compares it with the Black-Scholes value.
Because only the value at expiration matters, this can be simulated without generating a full path for the security price, just that at expiration assuming that the price follows a geometric Brownian motion.
This sets the control parameters and computes the mean and standard deviation for the log price change in the security including the holding costs given the safe rate of return.
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)
This computes the sum and sum of squares for the present value of the investment in the option for each draw. (The %ran(hsigma) is the only random number draw inside a trip through the loop).
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
This converts the raw sums into the mean and standard deviation and displays them.
compute mcvalue=total/ndraws
compute mcvar =(total2/ndraws-mcvalue^2)/ndraws
?"Value by Monte Carlo" total/ndraws "Std Dev" sqrt(mcvar)
This uses the @BSOption procedure to compute the Black-Scholes formula value:
@BSOption(price=price,sigma=sigma,rate=rate,strike=strike,expire=expire) bsvalue
?"Value by Black-Scholes" bsvalue
To improve upon the performance of the original Monte Carlo procedure, this does antithetic acceleration, doing an average of the payoffs to + and - random numbers.
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
?"Value by MC with Antithetic Acceleration" total/ndraws "Std Dev" sqrt(mcvar)
Full Program
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
?"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)
?"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
?"Value by MC with Antithetic Acceleration" total/ndraws "Std Dev" sqrt(mcvar)
Output
These (other than Black-Scholes) depend upon random numbers and so will not be exactly reproducible. Clearly 10000 draws is nowhere near enough for an accurate calculation. 1000000 would be expected to reduce the standard deviations by a factor of 10. Antithetic acceleration is only marginally effective.
Value by Monte Carlo 5.01677 Std Dev 0.08770
Value by Black-Scholes 5.19108
Value by MC with Antithetic Acceleration 5.24957 Std Dev 0.05115
Copyright © 2025 Thomas A. Doan