# The option values are different from two r package - foptions,rquantlib

The results are very different.I know the code from quantlib and the result of quantlib seem right(close to market price). Is there anyone know why the value from fOptions is so large or fOptions used different approach? Thank you

  library(fOptions)
library(RQuantLib)

TypeFlag<-"c"
S<-530.32
X<-550
Time<-283/365
r<-0.000703
b<-0.05
sigma<-0.2442

fOptions.BAW<-BAWAmericanApproxOption(TypeFlag, S, X, Time, r, b, sigma,
title = NULL, description = NULL)
quantlib.BAW<-AmericanOption("call", S, X,
b, r, Time, sigma,

modelName<-c("fOptions.BAW","quantlib.BAW")
result <-cbind(modelName,
c(fOptions.BAW@price,quantlib.BAW[1]$value)) colnames(result)<-c("Model","Value")  - The source code for both is available. Have you looked at it? – Joshua Ulrich Jun 13 '14 at 12:51 I already read the quantlib version (it can be found at github). I try to find the foptions source, but it wrote by fortran (which I don't understand). am i right or could you send me the link about foptions source code. Much obliged – galaxyan Jun 13 '14 at 14:34 Yes, it's in Fortran. You could compare the current version with archived versions of fOptions on CRAN. Maybe one of the older versions had a pure-R implementation. – Joshua Ulrich Jun 13 '14 at 15:06 @JoshuaUlrich thank you. – galaxyan Jun 13 '14 at 15:14 ## 2 Answers The price difference is so large -- that the only possible reason is that you have spot and strike confused between the two functions. And indeed: R> fOptions.BAW <- BAWAmericanApproxOption(TypeFlag, S, X, Time, + r, b, sigma, title = NULL, description = NULL) R> quantlib.BAW <- AmericanOption("call", X, S, b, r, Time, + sigma, timeSteps=150, gridPoints=149, + engine="BaroneAdesiWhaley") R> result <- c("fOptions"=fOptions.BAW@price, + "RQL"=quantlib.BAW$value)
R> result
fOptions      RQL
47.7631  47.5193
R>

-

In RQuantLib, the formula you are using should include "dividendYield" which is "r-b" instead of b (the annualized cost-of-carry rate)

quantlib.BAW<-AmericanOption(type = TypeFlag, underlying = S, strike = X, dividendYield = r - b,
riskFreeRate = r, maturity = Time, volatility = sigma, engine="BaroneAdesiWhaley")


This will provide the same(similar) answer to fOptions.

-
No, that is in-line with the documentation and moves the price for me from 29.82 to 29.91. – Dirk Eddelbuettel Nov 18 at 12:35