ajouts Epps
This commit is contained in:
parent
3611a746a9
commit
72d149832c
9 changed files with 143 additions and 6 deletions
2
.Rbuildignore
Normal file
2
.Rbuildignore
Normal file
|
@ -0,0 +1,2 @@
|
|||
^.*\.Rproj$
|
||||
^\.Rproj\.user$
|
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -3,3 +3,4 @@
|
|||
|
||||
# Example code in package build process
|
||||
*-Ex.R
|
||||
.Rproj.user
|
||||
|
|
|
@ -4,7 +4,8 @@ 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
|
||||
Description: This is a package gathering different functions to work with
|
||||
option pricing
|
||||
Suggests:
|
||||
MASS
|
||||
License: LGPL-3
|
||||
License: LGPL-3
|
||||
|
|
0
NAMESPACE
Normal file
0
NAMESPACE
Normal file
|
@ -8,7 +8,6 @@
|
|||
|
||||
#' 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
|
||||
|
@ -17,15 +16,15 @@
|
|||
#' @return Option price
|
||||
#'
|
||||
#' @author François Pelletier
|
||||
parity <- function(optionvalue,stockprice,strikeprice,eval.time,expiry.time,rate,toPut=TRUE)
|
||||
parity <- function(optionvalue,strikeprice,eval.time,expiry.time,rate,toPut=TRUE)
|
||||
{
|
||||
if(toPut)
|
||||
{
|
||||
optionvalue-stockprice+strikeprice*zerobond(eval.time,expiry.time,rate)
|
||||
optionvalue-1+strikeprice*zerobond(eval.time,expiry.time,rate)
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
stockprice+optionvalue-strikeprice*zerobond(eval.time,expiry.time,rate)
|
||||
1+optionvalue-strikeprice*zerobond(eval.time,expiry.time,rate)
|
||||
}
|
||||
}
|
||||
|
|
38
R/putEpps.R
Normal file
38
R/putEpps.R
Normal file
|
@ -0,0 +1,38 @@
|
|||
# European put option pricing using characteristic function
|
||||
#
|
||||
# Author: Francois Pelletier
|
||||
#
|
||||
# LGPL 3.0
|
||||
###############################################################################
|
||||
|
||||
#' European put option pricing using characteristic function
|
||||
#'
|
||||
#' As seen in Epps (2009)
|
||||
#' @param char.fn Characteristic function of the price level at expiry time
|
||||
#' @param strikeprice Strike price, relative to a unit stock price
|
||||
#' @param eval.time Evaluation time
|
||||
#' @param expiry.time Expiry time
|
||||
#' @param rate Continuously compounded interest rate (force of interest)
|
||||
#' @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
|
||||
#'
|
||||
#' @author Francois Pelletier
|
||||
putEpps <- function(char.fn,strikeprice,eval.time,expiry.time,rate,...,int.bounds=c(-Inf,Inf))
|
||||
{
|
||||
# function to integrate (zhi)
|
||||
zhi <- function(x,char.fn,strikeprice,eval.time,expiry.time,rate,...)
|
||||
{
|
||||
Re(strikeprice^{-1i*x} *
|
||||
char.fn(x,strikeprice,eval.time,expiry.time,rate,...) /
|
||||
(x*(1i+x)))
|
||||
}
|
||||
# function to integrate with strike price as first parameter
|
||||
integrate.K <- function(strikeprice,zhi,int.bounds,eval.time,expiry.time,rate,...)
|
||||
{
|
||||
exp(-rate*(expiry.time-eval.time)) *
|
||||
strikeprice *
|
||||
(.5 - integrate(zhi,int.bounds[1],int.bounds[2],strikeprice,eval.time,expiry.time,rate,...)$value / (2*pi))
|
||||
}
|
||||
mclapply(as.vector(strikeprice),integrate.K,zhi,int.bounds,eval.time,expiry.time,rate,...)
|
||||
}
|
30
man/parity.Rd
Normal file
30
man/parity.Rd
Normal file
|
@ -0,0 +1,30 @@
|
|||
\name{parity}
|
||||
\alias{parity}
|
||||
\title{Put-Call Parity}
|
||||
\usage{
|
||||
parity(optionvalue, strikeprice, eval.time, expiry.time, rate, toPut = TRUE)
|
||||
}
|
||||
\arguments{
|
||||
\item{optionvalue}{Option price}
|
||||
|
||||
\item{strikeprice}{Strike price}
|
||||
|
||||
\item{eval.time}{Evaluation time}
|
||||
|
||||
\item{expiry.time}{Expiry time}
|
||||
|
||||
\item{rate}{Continuously compounded interest rate (force
|
||||
of interest)}
|
||||
|
||||
\item{toPut}{Boolean, Call to Put or Put to Call ?}
|
||||
}
|
||||
\value{
|
||||
Option price
|
||||
}
|
||||
\description{
|
||||
Put-Call Parity
|
||||
}
|
||||
\author{
|
||||
François Pelletier
|
||||
}
|
||||
|
36
man/putEpps.Rd
Normal file
36
man/putEpps.Rd
Normal file
|
@ -0,0 +1,36 @@
|
|||
\name{putEpps}
|
||||
\alias{putEpps}
|
||||
\title{European put option pricing using characteristic function}
|
||||
\usage{
|
||||
putEpps(char.fn, strikeprice, eval.time, expiry.time, rate, ...,
|
||||
int.bounds = c(-Inf, Inf))
|
||||
}
|
||||
\arguments{
|
||||
\item{char.fn}{Characteristic function of the price level
|
||||
at expiry time}
|
||||
|
||||
\item{strikeprice}{Strike price, relative to a unit stock
|
||||
price}
|
||||
|
||||
\item{eval.time}{Evaluation time}
|
||||
|
||||
\item{expiry.time}{Expiry time}
|
||||
|
||||
\item{rate}{Continuously compounded interest rate (force
|
||||
of interest)}
|
||||
|
||||
\item{...}{Parameters of the characteristic function}
|
||||
|
||||
\item{int.bounds}{Integration bounds for the integrate()
|
||||
method used. Defaults to infinite bounds.}
|
||||
}
|
||||
\value{
|
||||
European put option price
|
||||
}
|
||||
\description{
|
||||
As seen in Epps (2009)
|
||||
}
|
||||
\author{
|
||||
Francois Pelletier
|
||||
}
|
||||
|
30
man/zerobond.Rd
Normal file
30
man/zerobond.Rd
Normal file
|
@ -0,0 +1,30 @@
|
|||
\name{zerobond}
|
||||
\alias{zerobond}
|
||||
\title{zerobond}
|
||||
\usage{
|
||||
zerobond(eval.time, expiry.time, rate, face = 1)
|
||||
}
|
||||
\arguments{
|
||||
\item{eval.time}{Evaluation time}
|
||||
|
||||
\item{expiry.time}{Expiry time}
|
||||
|
||||
\item{rate}{Continuously compounded interest rate (force
|
||||
of interest)}
|
||||
|
||||
\item{face}{Face value}
|
||||
}
|
||||
\value{
|
||||
Actualised price of bond
|
||||
}
|
||||
\description{
|
||||
Evaluate the price of a zero coupon bond
|
||||
}
|
||||
\details{
|
||||
Evaluates the actualised price of a bond using interest
|
||||
rate and face value
|
||||
}
|
||||
\author{
|
||||
François Pelletier
|
||||
}
|
||||
|
Loading…
Reference in a new issue