From 724b3e83b2a341ef734458ffb646b80676fcf5bf Mon Sep 17 00:00:00 2001 From: ahudde Date: Mon, 4 Sep 2023 15:06:45 +0000 Subject: [PATCH] bugfix --- R/BS_European_Greeks.R | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/R/BS_European_Greeks.R b/R/BS_European_Greeks.R index b76a4d4..c1b7889 100644 --- a/R/BS_European_Greeks.R +++ b/R/BS_European_Greeks.R @@ -94,6 +94,14 @@ BS_European_Greeks <- -initial_price * time_to_maturity * exp_minus_dividend_yield_times_time_to_maturity * pnorm_d1 } + if ("lambda" %in% greek) { + result['lambda'] <- + initial_price * + (exp_minus_dividend_yield_times_time_to_maturity * pnorm_d1) / + (initial_price * exp_minus_dividend_yield_times_time_to_maturity + * pnorm_d1 - exp_minus_r_times_time_to_maturity * exercise_price * + pnorm_d2) + } ## second-order Greeks @@ -150,6 +158,14 @@ BS_European_Greeks <- initial_price * time_to_maturity * exp_minus_dividend_yield_times_time_to_maturity * pnorm_minus_d1 } + if ("lambda" %in% greek) { + result['lambda'] <- + -initial_price * + (exp_minus_dividend_yield_times_time_to_maturity * pnorm_minus_d1) / + (exp_minus_r_times_time_to_maturity * exercise_price * + pnorm_minus_d2 - initial_price * + exp_minus_dividend_yield_times_time_to_maturity * pnorm_minus_d1) + } # second-order Greeks @@ -175,14 +191,6 @@ BS_European_Greeks <- initial_price * exp_minus_dividend_yield_times_time_to_maturity * dnorm_d1 * sqrt_time_to_maturity } - if ("lambda" %in% greek) { - result['lambda'] <- - initial_price * - (exp_minus_dividend_yield_times_time_to_maturity * pnorm_d1) / - (initial_price * exp_minus_dividend_yield_times_time_to_maturity - * pnorm_d1 - exp_minus_r_times_time_to_maturity * exercise_price * - pnorm_d2) - } ## second-order Greeks