BOPM:

Usage Arguments Examples

Usage

1
BOPM(o = OptPx(), IncBT = TRUE)

Arguments

o
IncBT

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
31
##---- 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 = OptPx(), IncBT = TRUE) 
{
    stopifnot(is.OptPx(o), o$Style$Vanilla)
    NSteps = o$NSteps
    p = o$p
    K = o$K
    if (o$Style$European && !IncBT) 
        return(BOPM_Eu(o))
    else {
        S = with(o, S0 * d^(0:NSteps) * u^(NSteps:0))
        O = pmax(o$Right$SignCP * (S - K), 0)
        RecalcOSonPriorTimeStep = function(i) {
            O <<- o$DF_dt * (p * O[-i - 1] + (1 - p) * O[-1])
            S <<- o$d * S[-i - 1]
            Payout = pmax(o$Right$SignCP * (S - K), 0)
            if (o$Style$American) 
                O <<- pmax(O, Payout)
            return(cbind(S, O))
        }
        BT = append(list(cbind(S, O)), sapply(NSteps:1, RecalcOSonPriorTimeStep))
        o$PxBT = BT[[length(BT)]][[2]]
        if (IncBT) 
            o$BT = BT
        return(o)
    }
  }

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