From 3611a746a9cc1cabb790380f0cd67ed5c9403b7d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fran=C3=A7ois=20Pelletier?= Date: Tue, 11 Feb 2014 22:03:45 -0500 Subject: [PATCH] Ajout des fonctions zerobond et parity --- .project | 19 +++++++++++++++++++ .settings/de.walware.r.core.prefs | 2 ++ DESCRIPTION | 10 ++++++++++ R/parity.R | 31 +++++++++++++++++++++++++++++++ R/zerobond.R | 24 ++++++++++++++++++++++++ 5 files changed, 86 insertions(+) create mode 100644 .project create mode 100644 .settings/de.walware.r.core.prefs create mode 100644 DESCRIPTION create mode 100644 R/parity.R create mode 100644 R/zerobond.R diff --git a/.project b/.project new file mode 100644 index 0000000..ecb64bd --- /dev/null +++ b/.project @@ -0,0 +1,19 @@ + + + OptionPricingStuff + + + + + + de.walware.statet.r.builders.RSupport + + + + + + de.walware.statet.base.StatetNature + de.walware.statet.r.RNature + de.walware.statet.r.RPkgNature + + diff --git a/.settings/de.walware.r.core.prefs b/.settings/de.walware.r.core.prefs new file mode 100644 index 0000000..0c68bf3 --- /dev/null +++ b/.settings/de.walware.r.core.prefs @@ -0,0 +1,2 @@ +RProjectBuild/Package.name=OptionPricingStuff +eclipse.preferences.version=1 diff --git a/DESCRIPTION b/DESCRIPTION new file mode 100644 index 0000000..d7a9399 --- /dev/null +++ b/DESCRIPTION @@ -0,0 +1,10 @@ +Package: OptionPricingStuff +Title: Option Pricing Stuff +Version: 0.1 +Date: 2014-02-11 +Author: Francois Pelletier +Maintainer: Francois Pelletier +Description: This is a package gathering different functions to work with option pricing +Suggests: + MASS +License: LGPL-3 \ No newline at end of file diff --git a/R/parity.R b/R/parity.R new file mode 100644 index 0000000..e33eecb --- /dev/null +++ b/R/parity.R @@ -0,0 +1,31 @@ +# Put-Call Parity +# +# Author: Francois Pelletier +# +# LGPL 3.0 +############################################################################### + + +#' Put-Call Parity +#' @param optionvalue Option price +#' @param stockprice Stock price +#' @param strikeprice Strike price +#' @param eval.time Evaluation time +#' @param expiry.time Expiry time +#' @param rate Continuously compounded interest rate (force of interest) +#' @param toPut Boolean, Call to Put or Put to Call ? +#' @return Option price +#' +#' @author François Pelletier +parity <- function(optionvalue,stockprice,strikeprice,eval.time,expiry.time,rate,toPut=TRUE) +{ + if(toPut) + { + optionvalue-stockprice+strikeprice*zerobond(eval.time,expiry.time,rate) + + } + else + { + stockprice+optionvalue-strikeprice*zerobond(eval.time,expiry.time,rate) + } +} diff --git a/R/zerobond.R b/R/zerobond.R new file mode 100644 index 0000000..5deea0d --- /dev/null +++ b/R/zerobond.R @@ -0,0 +1,24 @@ +# Evaluate the price of a zero coupon bond +# +# Author: Francois Pelletier +# +# LGPL 3.0 +############################################################################### + + +#' Evaluate the price of a zero coupon bond +#' +#' Evaluates the actualised price of a bond using interest rate and face value +#' @title zerobond +#' @param eval.time Evaluation time +#' @param expiry.time Expiry time +#' @param rate Continuously compounded interest rate (force of interest) +#' @param face Face value +#' @return Actualised price of bond +#' +#' @author François Pelletier + +zerobond <- function(eval.time,expiry.time,rate,face=1) +{ + exp(-rate*(expiry.time-eval.time))*face +}