From 92b291e2b47b3aed4dae2f102df44eca7e9af726 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Sat, 24 May 2014 11:26:40 -0400 Subject: [PATCH] modification putEpps --- .project | 1 - R/putEpps.R | 12 ++++++------ 2 files changed, 6 insertions(+), 7 deletions(-) diff --git a/.project b/.project index ecb64bd..e65c65b 100644 --- a/.project +++ b/.project @@ -14,6 +14,5 @@ de.walware.statet.base.StatetNature de.walware.statet.r.RNature - de.walware.statet.r.RPkgNature diff --git a/R/putEpps.R b/R/putEpps.R index fbbcccb..33a2fbb 100644 --- a/R/putEpps.R +++ b/R/putEpps.R @@ -18,21 +18,21 @@ #' @return European put option price vector #' @export putEpps #' @author Francois Pelletier -putEpps <- function(strikeprice,char.fn,eval.time,expiry.time,rate,...,int.bounds=c(-Inf,Inf)) +putEpps <- function(strikeprice,char.fn,param,eval.time,expiry.time,rate,...,int.bounds=c(-Inf,0)) { # function to integrate (zhi) - zhi <- function(x,char.fn,strikeprice,eval.time,expiry.time,...) + zhi <- function(x,char.fn,param,strikeprice,eval.time,expiry.time,...) { Re(strikeprice^{-1i*x} * - char.fn(x,expiry.time-eval.time,...) / + char.fn(x,param,eval.time,expiry.time,...) / (x*(1i+x))) } # function to integrate with strike price as first parameter - integrate.K <- function(strikeprice,zhi,char.fn,int.bounds,eval.time,expiry.time,rate,...) + integrate.K <- function(strikeprice,zhi,char.fn,param,int.bounds,eval.time,expiry.time,rate,...) { exp(-rate*(expiry.time-eval.time)) * strikeprice * - (.5 - integrate(zhi,int.bounds[1],int.bounds[2],char.fn,strikeprice,eval.time,expiry.time,...)$value / (2*pi)) + (.5 - integrate(zhi,int.bounds[1],int.bounds[2],char.fn,param,strikeprice,eval.time,expiry.time,...)$value / (pi)) } - mclapply(as.list(strikeprice),integrate.K,zhi,char.fn,int.bounds,eval.time,expiry.time,rate,...) + lapply(as.list(strikeprice),integrate.K,zhi,char.fn,param,int.bounds,eval.time,expiry.time,rate,...) }