Ajout des fonctions zerobond et parity

This commit is contained in:
François Pelletier 2014-02-11 22:03:45 -05:00
parent fcbe98a035
commit 3611a746a9
5 changed files with 86 additions and 0 deletions

31
R/parity.R Normal file
View file

@ -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)
}
}

24
R/zerobond.R Normal file
View file

@ -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
}