David - 1 year ago 87

R Question

For some projects I am looking into financial options. I prefer to use

`RQuantLib`

`QuantLib`

`Boost`

`fOptions`

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`

`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`

`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`

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

Recommended for you: Get network issues from **WhatsUp Gold**. **Not end users.**

Answer Source

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.

Recommended from our users: **Dynamic Network Monitoring from WhatsUp Gold from IPSwitch**. ** Free Download**