[R-SIG-Finance] Code for FOptions GBS Greeks based on Haug 2nd Ed.

Joe W. Byers ecjbosu at aol.com
Sat Oct 12 03:25:39 CEST 2013


The following is the GBSStrike delta and ProbITM calculation that could 
be added the fOptions package.

.GBSStrike <- function(TypeFlag, S, X, Time, r, b, sigma) {
     d1 = (log(S / X) + (b + sigma ^ 2 / 2) * Time) / (sigma * sqrt(Time))
     d2 = d1 - sigma * sqrt(Time)
     if (TypeFlag == "c")
         result =  -exp((b - r) * Time) * CND(d2)
     if (TypeFlag == "p")
         result =  exp((b - r) * Time) * (CND(-d2))
     result
}

ProbITM <- function(TypeFlag, S, X, Time, r, b, sigma) {
     d1 = (log(S / X) + (b + sigma ^ 2 / 2) * Time) / (sigma * sqrt(Time))
     d2 = d1 - sigma * sqrt(Time)
     if (TypeFlag == "c")
         result =  CND(d2)
     if (TypeFlag == "p")
         result =  CND(-d2)
     result
}

Thanks
Joe W Byers



More information about the R-SIG-Finance mailing list