From 3166d19feb3b3b89391486338b5c0b1bf63b8196 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Wed, 5 Mar 2014 21:52:41 -0500 Subject: [PATCH] Ajout des return() et update du namespace avec roxygen --- NAMESPACE | 10 ++-------- R/EppsPulley.test.R | 2 +- R/callCarrMadan.R | 2 +- R/dampedcfcallCarrMadan.R | 10 +++++----- R/putEpps.R | 2 +- R/putHeston.R | 2 +- R/{parity.R => putcallparity.R} | 8 ++++---- R/zerobond.R | 2 +- man/{parity.Rd => putcallparity.Rd} | 7 ++++--- 9 files changed, 20 insertions(+), 25 deletions(-) rename R/{parity.R => putcallparity.R} (66%) rename man/{parity.Rd => putcallparity.Rd} (76%) diff --git a/NAMESPACE b/NAMESPACE index 81a43db..a47af15 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -1,8 +1,2 @@ -export(callCarrMadan, -dampedcfcallCarrMadan, -EppsPulley.test, -parity, -putEpps, -putHeston, -zerobond -) \ No newline at end of file +export(dampedcfcallCarrMadan) +export(putcallparity) diff --git a/R/EppsPulley.test.R b/R/EppsPulley.test.R index a7f2fb4..e80de59 100644 --- a/R/EppsPulley.test.R +++ b/R/EppsPulley.test.R @@ -14,7 +14,7 @@ #' @param x Sample #' @param alpha Tolerance level #' @return A list containing the test statistics -#' +#' @export EppsPulley.test #' @author François Pelletier EppsPulley.test <- function(x,alpha=0.05) { diff --git a/R/callCarrMadan.R b/R/callCarrMadan.R index 79fcf8e..d592468 100644 --- a/R/callCarrMadan.R +++ b/R/callCarrMadan.R @@ -16,7 +16,7 @@ #' @param ... Parameters of the characteristic function #' @param fft.control Control parameters list for the FFT discretization #' @return A European call option price vector -#' +#' @export callCarrMadan #' @author Francois Pelletier callCarrMadan <- function(strikeprice,char.fn,eval.time,expiry.time,rate,alpha, ...,fft.control=list(N=2^14,eta=.1)) diff --git a/R/dampedcfcallCarrMadan.R b/R/dampedcfcallCarrMadan.R index 8a29c74..f409c50 100644 --- a/R/dampedcfcallCarrMadan.R +++ b/R/dampedcfcallCarrMadan.R @@ -17,15 +17,15 @@ #' @param moneyness Boolean for moneyness of call option #' (TRUE if strike price is lower than stock price) #' @return Characteristic function value -#' +#' @export dampedcfcallCarrMadan #' @author Francois Pelletier dampedcfcallCarrMadan <- function(u,char.fn,eval.time,expiry.time,rate,alpha,...,moneyness=TRUE) { if(moneyness) { - exp(-rate*(expiry.time-eval.time))* + return(exp(-rate*(expiry.time-eval.time))* char.fn(u-1i*(alpha+1),expiry.time-eval.time,...) / - (alpha^2+alpha-u^2+1i*u*(2*alpha+1)) + (alpha^2+alpha-u^2+1i*u*(2*alpha+1))) } else { @@ -35,8 +35,8 @@ dampedcfcallCarrMadan <- function(u,char.fn,eval.time,expiry.time,rate,alpha,... (1/(1+1i*u)-exp(rate*(expiry.time-eval.time))/ (1i*u)-char.fn(u-1i,expiry.time-eval.time,...)/(u^2-1i*u)) } - (auxiliairyf(u-1i*alpha,char.fn,eval.time,expiry.time,rate,alpha,...)- - auxiliairyf(u+1i*alpha,char.fn,eval.time,expiry.time,rate,alpha,...))/2 + return((auxiliairyf(u-1i*alpha,char.fn,eval.time,expiry.time,rate,alpha,...)- + auxiliairyf(u+1i*alpha,char.fn,eval.time,expiry.time,rate,alpha,...))/2) } } diff --git a/R/putEpps.R b/R/putEpps.R index e134ef0..33bf457 100644 --- a/R/putEpps.R +++ b/R/putEpps.R @@ -16,7 +16,7 @@ #' @param ... Parameters of the characteristic function #' @param int.bounds Integration bounds for the integrate() method used. Defaults to infinite bounds. #' @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)) { diff --git a/R/putHeston.R b/R/putHeston.R index 439ceb6..6ef3a7f 100644 --- a/R/putHeston.R +++ b/R/putHeston.R @@ -14,7 +14,7 @@ #' @param rate Continuously compounded interest rate (force of interest) #' @param ... Parameters of the distribution function dist.fn #' @return European put option price -#' +#' @export putHeston #' @author Francois Pelletier putHeston <- function(strikeprice,dist.fn,ess.dist.fn,eval.time,expiry.time,rate,...) { diff --git a/R/parity.R b/R/putcallparity.R similarity index 66% rename from R/parity.R rename to R/putcallparity.R index 11de830..5515ec0 100644 --- a/R/parity.R +++ b/R/putcallparity.R @@ -14,17 +14,17 @@ #' @param rate Continuously compounded interest rate (force of interest) #' @param toPut Boolean, Call to Put or Put to Call ? #' @return Option price -#' +#' @export putcallparity #' @author François Pelletier -parity <- function(optionvalue,strikeprice,eval.time,expiry.time,rate,toPut=TRUE) +putcallparity <- function(optionvalue,strikeprice,eval.time,expiry.time,rate,toPut=TRUE) { if(toPut) { - optionvalue-1+strikeprice*zerobond(eval.time,expiry.time,rate) + return(optionvalue-1+strikeprice*zerobond(eval.time,expiry.time,rate)) } else { - 1+optionvalue-strikeprice*zerobond(eval.time,expiry.time,rate) + return(1+optionvalue-strikeprice*zerobond(eval.time,expiry.time,rate)) } } diff --git a/R/zerobond.R b/R/zerobond.R index 5deea0d..8b87c89 100644 --- a/R/zerobond.R +++ b/R/zerobond.R @@ -15,7 +15,7 @@ #' @param rate Continuously compounded interest rate (force of interest) #' @param face Face value #' @return Actualised price of bond -#' +#' @export zerobond #' @author François Pelletier zerobond <- function(eval.time,expiry.time,rate,face=1) diff --git a/man/parity.Rd b/man/putcallparity.Rd similarity index 76% rename from man/parity.Rd rename to man/putcallparity.Rd index 2f7b33f..67d228b 100644 --- a/man/parity.Rd +++ b/man/putcallparity.Rd @@ -1,8 +1,9 @@ -\name{parity} -\alias{parity} +\name{putcallparity} +\alias{putcallparity} \title{Put-Call Parity} \usage{ -parity(optionvalue, strikeprice, eval.time, expiry.time, rate, toPut = TRUE) +putcallparity(optionvalue, strikeprice, eval.time, expiry.time, rate, + toPut = TRUE) } \arguments{ \item{optionvalue}{Option price}