binomopt
using the binomial pricing algorithm
to compute prices of European and American calls and puts.
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)
Stock price
Strike price of the option
Volatility of the stock, defined as the annualized standard deviation of the continuously-compounded return
Annual continuously-compounded risk-free interest rate
Time to maturity in years
Dividend yield, annualized, continuously-compounded
Number of binomial steps. Default is nstep = 10
Boolean indicating if option is American
Boolean TRUE
is the option is a put
Boolean, if TRUE
, manual entry of the
binomial parameters up and down. This overrides the crr
and jarrowrudd
flags
TRUE
to use the Cox-Ross-Rubinstein tree
TRUE
to use the Jarrow-Rudd tree
If specifyupdn=TRUE
, up and down moves on the
binomial tree
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.
Return the vector of inputs and computed pricing parameters as well as the price
Return time 0 delta, gamma, and theta in the
vector greeks
display asset prices at nodes
draw arrows connecting pricing nodes
draw horizontal line at the strike price
CEX parameter for nodes
c(low, high)
for ylimit of the plot
boolean; save the plot to a pdf file named
saveplotfn
file name for saved plot
automatically supply appropriate main title and x- and y-axis labels
if TRUE
, the binomplot
function
returns the option price
(FALSE). If TRUE
, y-axis is plotted on a log
scale
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.
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)\):
the binomial tree for the price of the underlying asset.
the binomial tree for the option price at each node
the tree of boolean indicators for whether or not the option is exercisd at each node
the probability of reaching each node
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})\)
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.
# 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