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

19
.project Normal file
View file

@ -0,0 +1,19 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>OptionPricingStuff</name>
<comment></comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>de.walware.statet.r.builders.RSupport</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>de.walware.statet.base.StatetNature</nature>
<nature>de.walware.statet.r.RNature</nature>
<nature>de.walware.statet.r.RPkgNature</nature>
</natures>
</projectDescription>

View file

@ -0,0 +1,2 @@
RProjectBuild/Package.name=OptionPricingStuff
eclipse.preferences.version=1

10
DESCRIPTION Normal file
View file

@ -0,0 +1,10 @@
Package: OptionPricingStuff
Title: Option Pricing Stuff
Version: 0.1
Date: 2014-02-11
Author: Francois Pelletier
Maintainer: Francois Pelletier <francois@francoispelletier.org>
Description: This is a package gathering different functions to work with option pricing
Suggests:
MASS
License: LGPL-3

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
}