Allen,
Yes, this was a mistake I made when I first wrote the functions, and
why I changed to t.exp in callprice.bs. But I forgot to in the other
functions (they are actually older versions that I should have removed).
I made the changes below.
Thanks for pointing this out.
Doug
The net result was that my
>maturity was being read as 1 year regardless of what numerical value for
>maturity that I put in for T. I changed T to t.exp, using the same variable
>name as you used in callprice.bs, and putprice.bs performed as I expected.
>I'm not too sure about the details of naming an object T in Splus, so I
>suppose what I'm observing could be system dependent (I'm just on my V4.5
>Windows Splus); but I think the object T in your putprice.bs needs to be
>called something else -- probably almost anything but T would work fine, and
>I can verify that t.exp works fine.
Yes, indeed.
>
>I haven't checked your vol.implied yet. Seeing that you have an object
>named T there also, there may be a similar issue.
With the change to t.exp, it should work.
Doug
>
>Allen Humbolt
>Quantitative Analyst
>Koch Industries, Inc.
>HumboltA@kochind.com
>
>> -----Original Message-----
>> From: Doug Martin [SMTP:doug@statsci.com]
>> Sent: Monday, August 03, 1998 9:17 AM
>> To: SusieMM@aol.com; s-news@wubios.wustl.edu
>> Subject: Re: [S] Black-Scholes option valuation
>>
>> 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.exp, t, r, sigma)
>> {
>> c <- callprice.bs(s, x, t.exp, t, r, sigma)
>> c - s + x * exp( - r * (t.exp - t)) # By put-call parity
>> }
>>
>>
>> Where:
>>
>> s = stock price
>> x = strike price
>> t.exp = 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.exp, t, r, sigma.init = 0.05)
>> {
>> dif <- 1
>> sigma0 <- sigma.init
>> while(dif > 0.001) {
>> c0 <- callprice.bs(s, x, t.exp, t, r, sigma0)
>> v0 <- vega(s, x, t.exp, 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.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)
>> s * dnorm(d.pos) * (t.exp - 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