Learn R Programming

derivmkts (version 0.2.5)

binom: Binomial option pricing

Description

binomopt using the binomial pricing algorithm to compute prices of European and American calls and puts.

Usage

binomopt(s, k, v, r, tt, d, nstep = 10, american = TRUE,
    putopt=FALSE, specifyupdn=FALSE, crr=FALSE, jarrowrudd=FALSE,
    up=1.5, dn=0.5, returntrees=FALSE, returnparams=FALSE,
    returngreeks=FALSE)

binomplot(s, k, v, r, tt, d, nstep, putopt=FALSE, american=TRUE, plotvalues=FALSE, plotarrows=FALSE, drawstrike=TRUE, pointsize=4, ylimval=c(0,0), saveplot = FALSE, saveplotfn='binomialplot.pdf', crr=FALSE, jarrowrudd=FALSE, titles=TRUE, specifyupdn=FALSE, up=1.5, dn=0.5, returnprice=FALSE, logy=FALSE)

Arguments

s

Stock price

k

Strike price of the option

v

Volatility of the stock, defined as the annualized standard deviation of the continuously-compounded return

r

Annual continuously-compounded risk-free interest rate

tt

Time to maturity in years

d

Dividend yield, annualized, continuously-compounded

nstep

Number of binomial steps. Default is nstep = 10

american

Boolean indicating if option is American

putopt

Boolean TRUE is the option is a put

specifyupdn

Boolean, if TRUE, manual entry of the binomial parameters up and down. This overrides the crr and jarrowrudd flags

crr

TRUE to use the Cox-Ross-Rubinstein tree

jarrowrudd

TRUE to use the Jarrow-Rudd tree

up, dn

If specifyupdn=TRUE, up and down moves on the binomial tree

returntrees

If returntrees=TRUE, the list returned by the function includes four trees: for the price of the underlying asset (stree), the option price (oppricetree), where the option is exercised (exertree), and the probability of being at each node. This parameter has no effect if returnparams=FALSE, which is the default.

returnparams

Return the vector of inputs and computed pricing parameters as well as the price

returngreeks

Return time 0 delta, gamma, and theta in the vector greeks

plotvalues

display asset prices at nodes

plotarrows

draw arrows connecting pricing nodes

drawstrike

draw horizontal line at the strike price

pointsize

CEX parameter for nodes

ylimval

c(low, high) for ylimit of the plot

saveplot

boolean; save the plot to a pdf file named saveplotfn

saveplotfn

file name for saved plot

titles

automatically supply appropriate main title and x- and y-axis labels

returnprice

if TRUE, the binomplot function returns the option price

logy

(FALSE). If TRUE, y-axis is plotted on a log scale

Value

By default, binomopt returns the option price. If returnparams=TRUE, it returns a list where $price is the binomial option price and $params is a vector containing the inputs and binomial parameters used to compute the option price. Optionally, by specifying returntrees=TRUE, the list can include the complete asset price and option price trees, along with trees representing the replicating portfolio over time. The current delta, gamma, and theta are also returned. If returntrees=FALSE and returngreeks=TRUE, only the current price, delta, gamma, and theta are returned. The function binomplot produces a visual representation of the binomial tree.

Details

By default, binomopt returns an option price. Optionally, it returns a vector of the parameters used to compute the price, and if returntrees=TRUE it can also return the following matrices, all but but two of which have dimensionality \((\textrm{nstep}+1)\times (\textrm{nstep}+ 1)\):

stree

the binomial tree for the price of the underlying asset.

oppricetree

the binomial tree for the option price at each node

exertree

the tree of boolean indicators for whether or not the option is exercisd at each node

probtree

the probability of reaching each node

delta

at each node prior to expiration, the number of units of the underlying asset in the replicating portfolio. The dimensionality is \((\textrm{nstep})\times (\textrm{nstep})\)

bond

at each node prior to expiration, the bond position in the replicating portfolio. The dimensionality is \((\textrm{nstep})\times (\textrm{nstep})\)

binomplot plots the stock price lattice and shows graphically the probability of being at each node (represented as the area of the circle at that price) and whether or not the option is optimally exercised there (green if yes, red if no), and optionally, ht, depending on the inputs.

Examples

Run this code
# NOT RUN {
s=40; k=40; v=0.30; r=0.08; tt=0.25; d=0; nstep=15

binomopt(s, k, v, r, tt, d, nstep, american=TRUE, putopt=TRUE)

binomopt(s, k, v, r, tt, d, nstep, american=TRUE, putopt=TRUE,
    returnparams=TRUE)

## matches Fig 10.8 in 3rd edition of Derivatives Markets
x <- binomopt(110, 100, .3, .05, 1, 0.035, 3, american=TRUE,
    returntrees=TRUE, returnparams=TRUE)
print(x$oppricretree)
print(x$delta)
print(x$bond)

binomplot(s, k, v, r, tt, d, nstep, american=TRUE, putopt=TRUE)

binomplot(s, k, v, r, tt, d, nstep, american=FALSE, putopt=TRUE)


# }

Run the code above in your browser using DataLab