Learn R Programming

ecd (version 0.9.2.4)

ecop.bs_implied_volatility: Implied volatility of Black-Sholes model

Description

This is the standard library to calculate implied volatility \(\sigma_{BS}\) in Black-Sholes model. There is no external dependency on elliptic distribution.

Usage

ecop.bs_implied_volatility(
  V,
  K,
  S,
  ttm,
  int_rate = 0,
  div_yield = 0,
  otype = "c",
  stop.on.na = FALSE,
  use.mc = TRUE
)

Arguments

V

numeric vector of option prices

K

numeric vector of strike prices

S

length-one numeric for underlying price

ttm

length-one numeric for time to maturity, in the unit of days/365.

int_rate

length-one numeric for risk-free rate, default to 0.

div_yield

length-one numeric for dividend yield, default to 0.

otype

character, specifying option type: c or p.

stop.on.na

logical, to stop if fails to find solution. Default is to use NaN and not stop.

use.mc

logical, to use mclapply (default), or else just use for loop. For loop option is typically for debugging.

Value

The implied volatity \(\sigma_{BS}\).

Examples

Run this code
# NOT RUN {
V <- c(1.8, 50)
K <- c(2100, 2040)
S <- 2089.27
T <- 1/365
y <- 0.019
ecop.bs_implied_volatility(V, K, S, ttm=T, div_yield=y, otype="c")
# expect output of 12.8886% and 29.4296%
# }

Run the code above in your browser using DataLab