R/pde_gbm.R

Defines functions pde_gbm

Documented in pde_gbm

#' Solve a PDE/variational inequality under GBM dynamics
#' 
#' @param spot the spot price
#' @param strike the strike sprice
#' @param maturity the maturity of the option contract
#' @param rate the risk-neutral rate
#' @param div the dividend yield rate
#' @param volat the volatility
#' @param what the payoff to use
#' @param style 'european' for PDE/PIDE problems, 'american' for variational inequalities
#' @param output "greeks", "price" or "grid" for the format to return the solution in
#' @param N the time resolution
#' @param M the space resolution
#' 
#' @description {Solve a PDE/variational equality under GBM dynamics using an implicit finite difference scheme}
#' @export pde_gbm
pde_gbm <- function(spot, strike, maturity, rate, div, volat, what = "call", style = "american", output = "greeks", N = 400, M = 400)
{
  if(output == "greeks")
  {
    x <- data.frame(t(pde_gbm_greeks(spot, strike, maturity, rate, div, volat, N, M, what, style)))
    names(x) <- c("fee", "delta", "gamma", "theta")
    return(x)
  } else if(output == "price")
  {
    return(pde_gbm_price(spot, strike, maturity, rate, div, volat, N, M, what, style))
  } else if(output == "grid")
  {
    return(pde_gbm_grid(spot, strike, maturity, rate, div, volat, N, M, what, style))
  } else{
    stop("argument 'output' must be: greeks, price, or grid ")
  }
}
shill1729/OptionPricer documentation built on June 11, 2020, 12:18 a.m.