binom | R Documentation |
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)
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 |
american |
Boolean indicating if option is American |
putopt |
Boolean |
specifyupdn |
Boolean, if |
crr |
|
jarrowrudd |
|
up, dn |
If |
returntrees |
If |
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 |
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 |
|
saveplot |
boolean; save the plot to a pdf file named
|
saveplotfn |
file name for saved plot |
titles |
automatically supply appropriate main title and x- and y-axis labels |
returnprice |
if |
logy |
(FALSE). If |
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 (nstep+1)*(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 nstep*nstep
at each node prior to expiration, the bond position in the replicating portfolio. The dimensionality is nstep*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.
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
computes the binomial tree using
up and down moves of
u = exp((r-d)*h + v*h^(0.5))
and
d = exp((r-d)*h - v*h^(0.5))
You can use
different trees: There is a boolean variable CRR
to use
the Cox-Ross-Rubinstein pricing tree, and you can also supply
your own up and down moves with specifyupdn=TRUE
. It's
important to realize that if you do specify the up and down
moves, you are overriding the volatility parameter.
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)
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.