# Re: [S] Black-Scholes option valuation

Doug Martin (doug@statsci.com)
Mon, 03 Aug 1998 07:17:05 -0700

At 02:35 AM 8/3/98 EDT, SusieMM@aol.com wrote:
>Does anyone have a S-Plus routine for determining Black-Schole calls and
puts?
>If so, would you tell me where I can find it? Thanks.

The following will do it for you:

callprice.bs <- function(s, x, t.exp, t, r, sigma)
{
d.pos <- log(s/x) + (r + 0.5 * sigma^2) * (t.exp - t)
d.pos <- d.pos/(sigma * (t.exp - t)^0.5)
d.neg <- d.pos - sigma * (t.exp - t)^0.5
s * pnorm(d.pos) - x * exp( - r * (t.exp - t)) * pnorm(d.neg)
}

> putprice.bs <- function(s, x, T, t, r, sigma)
{
c <- callprice.bs(s, x, T, t, r, sigma)
c - s + x * exp( - r * (T - t)) # By put-call parity
}

Where:

s = stock price
x = strike price
T = expiration time
t = current time
r = risk free rate
sigma = volatility

***************************

And if you want the Black-Scholes implied volatility, you can compute it
with:

> vol.implied <- function(c, s, x, T, t, r, sigma.init = 0.05)
{
dif <- 1
sigma0 <- sigma.init
while(dif > 0.001) {
c0 <- callprice.bs(s, x, T, t, r, sigma0)
v0 <- vega(s, x, T, t, r, sigma0)
sigma1 <- sigma0 - (c0 - c)/v0
print(sigma1) # Remove print if you like
dif <- abs(sigma1 - sigma0)
sigma0 <- sigma1
}
}

Here vega is (one of the "Greeks") the partial derivative of the
call price with respect to volatility:

> vega <- function(s, x, T, t, r, sigma)
{
d.pos <- log(s/x) + (r + 0.5 * sigma^2) * (T - t)
d.pos <- d.pos/(sigma * (T - t)^0.5)
s * dnorm(d.pos) * (T - t)^0.5
}

Doug Martin

>
>Susan M. Mangiero
>-----------------------------------------------------------------------
>This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
>send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
>message: unsubscribe s-news
>
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news
-----------------------------------------------------------------------
This message was distributed by s-news@wubios.wustl.edu. To unsubscribe
send e-mail to s-news-request@wubios.wustl.edu with the BODY of the
message: unsubscribe s-news