Search code examples
rfinancequantitative-finance

Financial Options. fOptions vs RQuantLib


For some projects I am looking into financial options. I prefer to use RQuantLib, but sometimes its hard to convince others (Mac users for instance) to install QuantLib, Boost, etc. therefore I am also looking at the fOptions-package. However I have issues replicating results.

Mainly I am trying to calculate the price for American and European options, as well as the delta, gamma, vega, theta, and rho.

In RQuantLib everything works as expected:

library(RQuantLib)
EuropeanOption(type = "call", underlying = 100, strike = 100, dividendYield = 0, 
               riskFreeRate = 0.03, maturity = 1, volatility = 0.05)

# Concise summary of valuation for EuropeanOption 
# value    delta    gamma     vega    theta      rho   divRho 
# 3.7861   0.7340   0.0656  32.8161  -2.9089  69.6153 -73.4014 

fOptions however gives me different results:

library(fOptions)
GBSOption(TypeFlag = "c", S = 100, X = 100, Time = 1, r = 0.03, b = 0, 
          sigma = 0.05)
# 
# Title:
#   Black Scholes Option Valuation 
# 
# Call:
#   GBSOption(TypeFlag = "c", S = 100, X = 100, Time = 1, r = 0.03, 
#             b = 0, sigma = 0.05)
# 
# Parameters:
#   Value:
#   TypeFlag c     
# S        100   
# X        100   
# Time     1     
# r        0.03  
# b        0     
# sigma    0.05  
# 
# Option Price:
#   1.935566 
# 
# Description:
#   Wed Nov  2 23:08:57 2016 

Or similar for the greeks:

GBSGreeks(Selection = "delta", TypeFlag = "c", S = 100, X = 100, Time = 1, 
      r = 0.03, b = 0, sigma = 0.05)
# [1] 0.4949006

I am not necessarily bound to the fOptions-library, I just need a (rather) lightweight alternative to RQuantLib that doesn't need the installation of additional software (on Mac and Linux).

What am I missing? Thank you very much for your help!


Solution

  • You've misunderstood the purpose of the b argument to fOptions::GBSOption. It's not equivalent to the dividend yield in RQuantLib::EuropeanOption, it's actually the cost of carry. In your case with no dividend yield, the cost of carry is just the risk-free rate:

    GBSOption(TypeFlag = "c", S = 100, X = 100, Time = 1, r = 0.03, 
              sigma = 0.05, b=0.03)
    
    Title:
     Black Scholes Option Valuation 
    
    Call:
     GBSOption(TypeFlag = "c", S = 100, X = 100, Time = 1, r = 0.03, 
               b = 0.03, sigma = 0.05)
    
    Parameters:
              Value:
     TypeFlag c     
     S        100   
     X        100   
     Time     1     
     r        0.03  
     b        0.03  
     sigma    0.05  
    
    Option Price:
     3.786116 
    

    This matches what you got from the other package.