ORIE 4630 — D. Ruppert
Homework #8 — due Friday, Oct 22, 2010
Note:
Students are required to work independently on homework.
The following
R
code creates a function named
BlackScholesSim
that approximates the
price of a call option by simulation and, as default values, uses 10,000,000 simulations with
a seed equal to 4360. The other inputs are deﬁned as in Section 8.17 of the textbook. The
function
proc.time
is used to time the simulation.
BlackScholesSim
returns the mean
and the standard deviation of the
N
simulations. The latter is useful for constructing a
conﬁdence interval for the price.
*****
Put code here to specify the values of S, T, t, K, sigma, and r
*****
BlackScholesSim = function(S,T,t,K,sigma,r,N=1e07,seed=4360)
{
set.seed(seed)
Z = rnorm(N)
X
= S*exp(-sigma^2/2*(T-t) + sigma*sqrt(T-t)*Z) - K*exp(-r*(T-t))
Ind = as.numeric(X>0)
payoff = X*Ind
c(mean(payoff),sd(payoff))
}
t1 = proc.time()
sim_results = BlackScholesSim(S,T,t,K,sigma,r)
t2= proc.time()
t2-t1[3]
1. Use