From a12caafb2cd6de1d922b268c3a6747aa6d85e217 Mon Sep 17 00:00:00 2001 From: hudde Date: Wed, 31 Jan 2024 09:57:59 +0100 Subject: [PATCH] Added asset-or-nothing digital options --- R/Malliavin_European_Greeks.R | 9 ++++++++- man/Malliavin_European_Greeks.Rd | 3 ++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/R/Malliavin_European_Greeks.R b/R/Malliavin_European_Greeks.R index d932833..84187bb 100644 --- a/R/Malliavin_European_Greeks.R +++ b/R/Malliavin_European_Greeks.R @@ -12,7 +12,8 @@ #' @param time_to_maturity - time to maturity in years #' @param volatility - volatility of the underlying asset #' @param payoff - the payoff function, either a string in ("call", "put", -#' "cash_or_nothing_call", "cash_or_nothing_call"), or a function +#' "cash_or_nothing_call", "cash_or_nothing_call", "asset_or_nothing_call", +#' "asset_or_nothing_put"), or a function #' @param greek - the Greeks to be calculated in ("fair_value", "delta", #' "vega", "theta", "rho", "gamma") #' @param model - the model to be chosen @@ -79,6 +80,12 @@ Malliavin_European_Greeks <- } else if (payoff %in% c("digital_put", "cash_or_nothing_put")) { payoff <- function(x) {ifelse(x <= exercise_price, 1, 0) } + } else if (payoff %in% c("asset_or_nothing_call")) { + payoff <- function(x) {ifelse(x >= exercise_price, x, 0) + } + } else if (payoff %in% c("asset_or_nothing_put")) { + payoff <- function(x) {ifelse(x <= exercise_price, x, 0) + } } if (model == "Black Scholes") { diff --git a/man/Malliavin_European_Greeks.Rd b/man/Malliavin_European_Greeks.Rd index f923dd1..d75d2c1 100644 --- a/man/Malliavin_European_Greeks.Rd +++ b/man/Malliavin_European_Greeks.Rd @@ -42,7 +42,8 @@ Malliavin_European_Greeks( \item{payoff}{\itemize{ \item the payoff function, either a string in ("call", "put", -"cash_or_nothing_call", "cash_or_nothing_call"), or a function +"cash_or_nothing_call", "cash_or_nothing_call", "asset_or_nothing_call", +"asset_or_nothing_put"), or a function }} \item{greek}{\itemize{