View source: R/cf_lattice_princing.R
cf_lattice_pricing | R Documentation |
Function for pricing an option with a multinomial model
cf_lattice_pricing(Q, EQ, R, S, option, type = "E")
Q |
equivalent discrete martingale measure |
EQ |
discrete version of the equivalent discrete martingale average |
R |
term structure of the interest rate, could be a fixed value or a multinomial lattice |
S |
multinomial lattice |
option |
function defining the option over S |
type |
option type a character that specifies the king of option, by default 'E' european option, 'A' american option, 'F' futures option, 'S' swap option, 'P' ... |
A list with a tree structure of the asset evolution
Pedro Guarderas
cflattice-class
s <- 0.3
T <- 0.25
N <- 15
c <- 0.01
u <- exp( s * sqrt( T / N ) )
d <- 1 / u
r <- 0.02
S0 <- 100
K <- 110
R <- exp( r * T / N )
q <- ( R - d ) / ( u - d )
Q <- c( 1 - q, q )
U <- c( d, u )
# K is global
call <- function( S ) {
max( S - K, 0 )
}
put <- function( S ) {
max( K - S, 0 )
}
# Equivalent measure
EQ <- function( R, Q, C ) {
return( sum( R * Q * C ) )
}
S <- cf_lattice( N, U, S0 )
# Pricing zero coupon bond
ZCB <- cf_lattice_pricing( Q, EQ, R, S, identity, type = 'A' )
# Pricing american call
Ca <- cf_lattice_pricing( Q, EQ, R, S, call, type = 'A' )
# Pricing american put
Pa <- cf_lattice_pricing( Q, EQ, R, S, put, type = 'A' )
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.