Skip to content

Commit

Permalink
Used Implied Volatility of Geometric Asian Greeks as starting point f…
Browse files Browse the repository at this point in the history
…or Implied Volatility of Asian Greeks to improve performance.
  • Loading branch information
hudde committed Aug 31, 2023
1 parent bb0eec7 commit b86136f
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions R/Implied_Volatility.R
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
#' @param time_to_maturity - time to maturity in years
#' @param dividend_yield - dividend yield
#' @param model - the model to be chosen
#' @param option_type in c("European", "American", "Asian", "Digital") - the
#' type of option to be considered TODO: Is this complete?
#' @param option_type in c("European", "American", "Geometric Asian", "Asian",
#' "Digital") - the type of option to be considered
#' @param payoff - in c("call", "put")
#' @param max_iter maximal number of iterations of the approximation
#' @param start_volatility initial guess
Expand Down Expand Up @@ -58,30 +58,36 @@ Implied_Volatility <-
# We compute the option price with zero volatility to check if
# BS_Implied_Volatility can deliver a viable starting value

# TODO: Use BS_Geometric_Asian_Greeks in the arithmetic Asian case
if(option_type == "Asian") {
option_type_start_price <- "Geometric Asian"
} else {
option_type_start_price <- "European"
}

option_price_zero_vol <-
BS_European_Greeks(
Greeks(
initial_price = initial_price,
exercise_price = exercise_price,
r = r,
time_to_maturity = time_to_maturity,
volatility = 0,
volatility = 1e-12,
dividend_yield = dividend_yield,
option_type = option_type_start_price,
payoff = payoff,
greek = "fair_value"
)

if(option_price > option_price_zero_vol) {

start_volatility <-
BS_Implied_Volatility(
Implied_Volatility(
option_price = option_price,
initial_price = initial_price,
exercise_price = exercise_price,
r = r,
time_to_maturity = time_to_maturity,
dividend_yield = dividend_yield,
option_type = option_type_start_price,
payoff = payoff,
start_volatility = start_volatility)

Expand Down Expand Up @@ -159,8 +165,6 @@ Implied_Volatility <-

vega <- fair_value_and_vega["vega"]

# print(c(volatility = volatility, diff = fair_value - option_price))

if (abs(fair_value - option_price) < precision) {
return(volatility)
}
Expand Down

0 comments on commit b86136f

Please sign in to comment.