Created
March 1, 2012 09:04
-
-
Save raphaelsaunier/1948460 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Black-Scholes Option Value | |
# Call value is returned in values[1], put in values[2] | |
blackscholes <- function(S, X, rf, T, sigma) { | |
values <- c(2) | |
d1 <- (log(S/X)+(rf+sigma^2/2)*T)/sigma*sqrt(T) | |
d2 <- d1 - sigma * sqrt(T) | |
values[1] <- S*pnorm(d1) - X*exp(-rf*T)*pnorm(d2) | |
values[2] <- X*exp(-rf*T) * pnorm(-d2) - S*pnorm(-d1) | |
values | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment