0

I have a problem using the "fOptions" Package for R. While I use the built-in MonteCarloSimulator with it's standard innovations and path generator I change the Payoff Function to price Parisian Options. My Problem is that the MCSimulation overpices the Option by 0.2.

Now my Question is: Is the Code I wrote correct? It should do the following (it's part of a function, the other stuff is correct):

  1. I get a vector "path", which is constructed from the exponent of a geometric Brownian Motian, so the first line changes this "path" to a vector containing the values of the Underlying.

  2. I change path to be a 0-1 Vector containing 1s where the Underlying value falls below the barrier H.

  3. I change path to be a True-False Vector containing the information if there are k or more consecutive steps in which the asset is below the barrier H.

  4. If this is the case, set payoff to 0.

    path = S*exp(cumsum(path))
    path = (path <= H) + 0
    path = (rle(path)$values[which(rle(path)$lengths >= k)] == 1)
    
    if (sum(path) > 0) {payoff = 0}
    

The code seems to be wrong for small k = 0, 1, 2, ... as the option prices underestimates the probability of a Knock-Out.

Thanks in advance for your help!

Edit: The path is generated via

wienerPath = function(eps) {
path = (b-sigma*sigma/2)*delta.t + sigma*sqrt(delta.t)*eps
path
}

where "eps" is a matrix filled with sobol low discrepancy numbers. the matrix which i get by running wienerPath is then inserted in my payoff function row by row, so "path" in the code in my original question is a vector.

4

1 回答 1

0

要在不通过示例代码的情况下回答标题问题:

foo<-sample(c(0,1),1000,replace=TRUE)
bar<-rle(bar)

bar$values[bar$lengths >=k]

如果你从最后一行中得到任何“1”,你就赢了。

于 2013-08-27T13:07:44.223 回答