| Title: | Financial Engineering in R | 
| Version: | 0.94 | 
| Description: | R implementations of standard financial engineering codes; vanilla option pricing models such as Black-Scholes, Bachelier, CEV, and SABR. | 
| URL: | https://github.com/PyFE/FE-R | 
| BugReports: | https://github.com/PyFE/FE-R/issues | 
| Depends: | R (≥ 3.3.1) | 
| NeedsCompilation: | no | 
| License: | GPL-2 | GPL-3 [expanded from: GPL (≥ 2)] | 
| Encoding: | UTF-8 | 
| LazyData: | true | 
| RoxygenNote: | 7.1.1 | 
| Imports: | stats, statmod | 
| Suggests: | testthat (≥ 3.0.0) | 
| Packaged: | 2021-03-05 13:40:12 UTC; msft | 
| Author: | Jaehyuk Choi [aut, cre] | 
| Maintainer: | Jaehyuk Choi <pyfe@eml.cc> | 
| Repository: | CRAN | 
| Date/Publication: | 2021-03-05 14:00:20 UTC | 
Calculate Bachelier model implied volatility
Description
Calculate Bachelier model implied volatility
Usage
BachelierImpvol(
  price,
  strike = forward,
  spot,
  texp = 1,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| price | (vector of) option price | 
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| intr | interest rate (domestic interest rate) | 
| divr | dividend/convenience yield (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
Bachelier implied volatility
References
Choi, J., Kim, K., & Kwak, M. (2009). Numerical Approximation of the Implied Volatility Under Arithmetic Brownian Motion. Applied Mathematical Finance, 16(3), 261-268. doi: 10.1080/13504860802583436
See Also
Examples
spot <- 100
strike <- 100
texp <- 1.2
sigma <- 20
intr <- 0.05
price <- 20
FER::BachelierImpvol(price, strike, spot, texp, intr=intr)
Calculate Bachelier model option price
Description
Calculate Bachelier model option price
Usage
BachelierPrice(
  strike = forward,
  spot,
  texp = 1,
  sigma,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| intr | interest rate (domestic interest rate) | 
| divr | dividend/convenience yield (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
option price
References
Choi, J., Kim, K., & Kwak, M. (2009). Numerical Approximation of the Implied Volatility Under Arithmetic Brownian Motion. Applied Mathematical Finance, 16(3), 261-268. doi: 10.1080/13504860802583436
See Also
Examples
spot <- 100
strike <- seq(80,125,5)
texp <- 1.2
sigma <- 20
intr <- 0.05
FER::BachelierPrice(strike, spot, texp, sigma, intr=intr)
Calculate Black-Scholes implied volatility
Description
Calculate Black-Scholes implied volatility
Usage
BlackScholesImpvol(
  price,
  strike = forward,
  spot,
  texp = 1,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| price | (vector of) option price | 
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| intr | interest rate (domestic interest rate) | 
| divr | dividend/convenience yield (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
Black-Scholes implied volatility
References
Giner, G., & Smyth, G. K. (2016). statmod: Probability Calculations for the Inverse Gaussian Distribution. The R Journal, 8(1), 339-351. doi: 10.32614/RJ-2016-024
See Also
Examples
spot <- 100
strike <- 100
texp <- 1.2
sigma <- 0.2
intr <- 0.05
price <- 20
FER::BlackScholesImpvol(price, strike, spot, texp, intr=intr)
Calculate Black-Scholes option price
Description
Calculate Black-Scholes option price
Usage
BlackScholesPrice(
  strike = forward,
  spot,
  texp = 1,
  sigma,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| intr | interest rate (domestic interest rate) | 
| divr | dividend/convenience yield (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
option price
References
Black, F., & Scholes, M. (1973). The Pricing of Options and Corporate Liabilities. Journal of Political Economy, 81(3), 637-654. doi: 10.1086/260062
Black, F. (1976). The pricing of commodity contracts. Journal of Financial Economics, 3(1), 167-179. doi: 10.1016/0304-405X(76)90024-6
https://en.wikipedia.org/wiki/Black-Scholes_model
See Also
Examples
spot <- 100
strike <- seq(80,125,5)
texp <- 1.2
sigma <- 0.2
intr <- 0.05
FER::BlackScholesPrice(strike, spot, texp, sigma, intr=intr)
Calculate the mass at zero under the CEV model
Description
Calculate the mass at zero under the CEV model
Usage
CevMassZero(
  spot,
  texp = 1,
  sigma,
  beta = 0.5,
  intr = 0,
  divr = 0,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| beta | beta | 
| intr | interest rate | 
| divr | dividend rate | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
mass at zero
Examples
spot <- 100
texp <- 1.2
beta <- 0.5
sigma <- 2
FER::CevMassZero(spot, texp, sigma, beta)
Calculate the constant elasticity of variance (CEV) model option price
Description
Calculate the constant elasticity of variance (CEV) model option price
Usage
CevPrice(
  strike = forward,
  spot,
  texp = 1,
  sigma,
  beta = 0.5,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| beta | elasticity parameter | 
| intr | interest rate (domestic interest rate) | 
| divr | dividend/convenience yield (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
option price
References
Schroder, M. (1989). Computing the constant elasticity of variance option pricing formula. Journal of Finance, 44(1), 211-219. doi: 10.1111/j.1540-6261.1989.tb02414.x
Examples
spot <- 100
strike <- seq(80,125,5)
texp <- 1.2
beta <- 0.5
sigma <- 2
FER::CevPrice(strike, spot, texp, sigma, beta)
Calculate the option price under the NSVh model with lambda=1 (Choi et al. 2019)
Description
Calculate the option price under the NSVh model with lambda=1 (Choi et al. 2019)
Usage
Nsvh1Choi2019(
  strike = forward,
  spot,
  texp = 1,
  sigma,
  vov = 0,
  rho = 0,
  intr = 0,
  divr = 0,
  cp = 1L,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| vov | (vector of) vol-of-vol | 
| rho | (vector of) correlation | 
| intr | interest rate | 
| divr | dividend rate | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
BS volatility or option price based on cp
References
Choi, J., Liu, C., & Seo, B. K. (2019). Hyperbolic normal stochastic volatility model. Journal of Futures Markets, 39(2), 186–204. doi: 10.1002/fut.21967
Examples
spot <- 100
strike <- seq(80,125,5)
texp <- 1.2
sigma <- 20
vov <- 0.2
rho <- -0.5
strike <- seq(0.1, 2, 0.1)
FER::Nsvh1Choi2019(strike, spot, texp, sigma, vov, rho)
Calculate the equivalent BS volatility (Hagan et al. 2002) for the Stochatic-Alpha-Beta-Rho (SABR) model
Description
Calculate the equivalent BS volatility (Hagan et al. 2002) for the Stochatic-Alpha-Beta-Rho (SABR) model
Usage
SabrHagan2002(
  strike = forward,
  spot,
  texp = 1,
  sigma,
  vov = 0,
  rho = 0,
  beta = 1,
  intr = 0,
  divr = 0,
  cp = NULL,
  forward = spot * exp(-divr * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot | (vector of) spot price | 
| texp | (vector of) time to expiry | 
| sigma | (vector of) volatility | 
| vov | (vector of) vol-of-vol | 
| rho | (vector of) correlation | 
| beta | (vector of) beta | 
| intr | interest rate (domestic interest rate) | 
| divr | convenience rate (foreign interest rate) | 
| cp | call/put sign.  | 
| forward | forward price. If given,  | 
| df | discount factor. If given,  | 
Value
BS volatility or option price based on cp
References
Hagan, P. S., Kumar, D., Lesniewski, A. S., & Woodward, D. E. (2002). Managing Smile Risk. Wilmott, September, 84-108.
Examples
sigma <- 0.25
vov <- 0.3
rho <- -0.8
beta <- 0.3
texp <- 10
strike <- seq(0.1, 2, 0.1)
FER::SabrHagan2002(strike, 1, texp, sigma, vov, rho, beta)
FER::SabrHagan2002(strike, 1, texp, sigma, vov, rho, beta, cp=1)
Spread option under the Bachelier model
Description
The payout of the spread option is
max(S1_T - S2_T - K, 0) where S1_T and S2_T are the
prices at expiry T of assets 1 and 2 respectively and K is
the strike price.
Usage
SpreadBachelier(
  strike = 0,
  spot1,
  spot2,
  texp = 1,
  sigma1,
  sigma2,
  corr,
  intr = 0,
  divr1 = 0,
  divr2 = 0,
  cp = 1L,
  forward1 = spot1 * exp(-divr1 * texp)/df,
  forward2 = spot2 * exp(-divr2 * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot1 | (vector of) spot price of asset 1 | 
| spot2 | (vector of) spot price of asset 2 | 
| texp | (vector of) time to expiry | 
| sigma1 | (vector of) Bachelier volatility of asset 1 | 
| sigma2 | (vector of) Bachelier volatility of asset 2 | 
| corr | correlation | 
| intr | interest rate | 
| divr1 | dividend rate of asset 1 | 
| divr2 | dividend rate of asset 2 | 
| cp | call/put sign.  | 
| forward1 | forward price of asset 1. If given, overrides  | 
| forward2 | forward price of asset 2. If given, overrides  | 
| df | discount factor. If given,  | 
Value
option price
Examples
FER::SpreadBachelier((-2:2)*10, 100, 120, 1.3, 20, 36, -0.5)
Spread option pricing method by Bjerksund & Stensland (2014)
Description
The payout of the spread option is
max(S1_T - S2_T - K, 0) where S1_T and S2_T are the
prices at expiry T of assets 1 and 2 respectively and K is
the strike price.
Usage
SpreadBjerksund2014(
  strike = 0,
  spot1,
  spot2,
  texp = 1,
  sigma1,
  sigma2,
  corr,
  intr = 0,
  divr1 = 0,
  divr2 = 0,
  cp = 1L,
  forward1 = spot1 * exp(-divr1 * texp)/df,
  forward2 = spot2 * exp(-divr2 * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot1 | (vector of) spot price of asset 1 | 
| spot2 | (vector of) spot price of asset 2 | 
| texp | (vector of) time to expiry | 
| sigma1 | (vector of) volatility of asset 1 | 
| sigma2 | (vector of) volatility of asset 2 | 
| corr | correlation | 
| intr | interest rate | 
| divr1 | dividend rate of asset 1 | 
| divr2 | dividend rate of asset 2 | 
| cp | call/put sign.  | 
| forward1 | forward price of asset 1. If given, overrides  | 
| forward2 | forward price of asset 2. If given, overrides  | 
| df | discount factor. If given,  | 
Value
option price
References
Bjerksund, P., & Stensland, G. (2014). Closed form spread option valuation. Quantitative Finance, 14(10), 1785–1794. doi: 10.1080/14697688.2011.617775
Examples
FER::SpreadBjerksund2014((-2:2)*10, 100, 120, 1.3, 0.2, 0.3, -0.5)
Kirk's approximation for spread option
Description
The payout of the spread option is
max(S1_T - S2_T - K, 0) where S1_T and S2_T are the
prices at expiry T of assets 1 and 2 respectively and K is
the strike price.
Usage
SpreadKirk(
  strike = 0,
  spot1,
  spot2,
  texp = 1,
  sigma1,
  sigma2,
  corr,
  intr = 0,
  divr1 = 0,
  divr2 = 0,
  cp = 1L,
  forward1 = spot1 * exp(-divr1 * texp)/df,
  forward2 = spot2 * exp(-divr2 * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| strike | (vector of) strike price | 
| spot1 | (vector of) spot price of asset 1 | 
| spot2 | (vector of) spot price of asset 2 | 
| texp | (vector of) time to expiry | 
| sigma1 | (vector of) volatility of asset 1 | 
| sigma2 | (vector of) volatility of asset 2 | 
| corr | correlation | 
| intr | interest rate | 
| divr1 | dividend rate of asset 1 | 
| divr2 | dividend rate of asset 2 | 
| cp | call/put sign.  | 
| forward1 | forward price of asset 1. If given, overrides  | 
| forward2 | forward price of asset 2. If given, overrides  | 
| df | discount factor. If given,  | 
Value
option price
References
Kirk, E. (1995). Correlation in the energy markets. In Managing Energy Price Risk (First, pp. 71–78). Risk Publications.
See Also
Examples
FER::SpreadKirk((-2:2)*10, 100, 120, 1.3, 0.2, 0.3, -0.5)
Margrabe's formula for exhange option price
Description
The payout of the exchange option is
max(S1_T - S2_T, 0) where S1_T and S2_T are the
prices at expiry T of assets 1 and 2 respectively.
Usage
SwitchMargrabe(
  spot1,
  spot2,
  texp = 1,
  sigma1,
  sigma2,
  corr,
  intr = 0,
  divr1 = 0,
  divr2 = 0,
  cp = 1L,
  forward1 = spot1 * exp(-divr1 * texp)/df,
  forward2 = spot2 * exp(-divr2 * texp)/df,
  df = exp(-intr * texp)
)
Arguments
| spot1 | (vector of) spot price of asset 1 | 
| spot2 | (vector of) spot price of asset 2 | 
| texp | (vector of) time to expiry | 
| sigma1 | (vector of) volatility of asset 1 | 
| sigma2 | (vector of) volatility of asset 2 | 
| corr | correlation | 
| intr | interest rate | 
| divr1 | dividend rate of asset 1 | 
| divr2 | dividend rate of asset 2 | 
| cp | call/put sign.  | 
| forward1 | forward price of asset 1. If given, overrides  | 
| forward2 | forward price of asset 2. If given, overrides  | 
| df | discount factor. If given,  | 
Value
option price
References
Margrabe, W. (1978). The value of an option to exchange one asset for another. The Journal of Finance, 33(1), 177–186.
See Also
Examples
FER::SwitchMargrabe(100, 120, 1.3, 0.2, 0.3, -0.5)