Question
I am attempting to create an R function to approximate sigma using Black-Sholes option pricing model and the following variables: Put = put option price,
I am attempting to create an R function to approximate sigma using Black-Sholes option pricing model and the following variables: Put = put option price, S0 = current stock price, K = strike price, r = risk-free rate, T =: remaining time to maturity, and sigma = standard deviation of underlying stock price.
The first line of the code should read:
sigma <- function (put, S0, K, r, T) {
As an example of creating a function with the same variables and Black Sholes option pricing model please see R function below used to calculate the put option price:
put <- function (S0, K, r, T, sigma) { d1 <- (log(S0/K) + (r + sigma^2/2)*T) / (sigma*sqrt(T)) d2 <- d1 - sigma*sqrt(T) value <- (K*exp(-r*T)*pnorm(-d2) - S0*pnorm(-d1)) return(value) }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started