OptPx:

Usage Arguments Examples

Usage

1
OptPx(o = Opt(), r = 0.05, q = 0, rf = 0, vol = 0.3, NSteps = 2)

Arguments

o
r
q
rf
vol
NSteps

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
##---- Should be DIRECTLY executable !! ----
##-- ==>  Define data, use random,
##--	or do  help(data=index)  for the standard data sets.

## The function is currently defined as
function (o = Opt(), r = 0.05, q = 0, rf = 0, vol = 0.3, NSteps = 2) 
{
    stopifnot(is.Opt(o), is.numeric(r), r > 0, r < 1, is.numeric(vol), 
        is.numeric(q), is.numeric(rf))
    dt = o$ttm/NSteps
    u = exp(vol * sqrt(dt))
    d = 1/u
    SYld = r - q - rf
    a = exp(SYld * dt)
    o$r = r
    o$q = q
    o$rf = rf
    o$vol = vol
    o$NSteps = NSteps
    o$u = u
    o$d = d
    o$dt = dt
    o$a = a
    o$p = p = (a - d)/(u - d)
    o$SYld = SYld
    o$DF_ttm = exp(-r * o$ttm)
    o$DF_dt = exp(-r * dt)
    class(o) = c(class(o), "OptPx")
    return(o)
  }

rhooahn/sample-code documentation built on May 27, 2019, 7:40 a.m.