1
$\begingroup$

I am trying to solve the BlackScholes PDE for Barrier option. It works fine for european barrier, but errors out on american boundary condition

sol1 = NDSolve[{D[V[S, t], t] + r*S*D[V[S, t], S] + 
1/2 sigma^2 S^2 D[V[S, t], {S, 2}] - r V[S, t] == 0, 
  V[S, t] ==    Piecewise[{{0, S >= 120}, {Max[S - K, 0], S < 120}}]},V, {S, 0.1,   1000}, {t, 0, T}] 

If I change the boundary condition to capital "T", it works fine

V[S, T] ==    Piecewise[{{0, S >= 120}, {Max[S - K, 0], S < 120}}]}

If it's for any time t, then it complains about fewer dependent variables. Is there any other way to specify boundary condition for 2 variables? It seems a simple issue, but can't find anything in mathematica documentation!

$\endgroup$
4
  • 1
    $\begingroup$ For those who are not familiar with the Black-Scholes equation with the barrier option, can you either edit your question to include the PDEs and the boundary conditions you're trying to implement, or link to a description of same? $\endgroup$ Commented Jul 2, 2015 at 14:45
  • $\begingroup$ Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory Tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. $\endgroup$
    – bbgodfrey
    Commented Jul 2, 2015 at 14:54
  • 1
    $\begingroup$ The code as first written does not include a boundary condition but instead an equation defining V for all S and t, which eliminates it as a dependent variable; hence, the error. Changing t to T turns the second equation into a bouncary condition, and all is well. You need a boundary condition in t too, something like V[S,0] == 0. Also, note that sigma and K are undefined. Although it does not matter here, it is bad practice to begin variable names with capital letters, because Mathematica functions also begin with capital letters. $\endgroup$
    – bbgodfrey
    Commented Jul 2, 2015 at 15:05
  • $\begingroup$ Yes I realize the problem. I basically want to specify boundary condition as V[S,T] = Max(S-K,0) for S<120 and V[S,t] = 0 for S>=120. Not sure how to write this in pde format for dsolve $\endgroup$ Commented Jul 2, 2015 at 15:31

1 Answer 1

1
$\begingroup$

Ok I think this method worked, but still NDSolve gives an unstable solution.

barriersolution = 
 NDSolve[{D[V[S, t], t] + r*S*D[V[S, t], S] + 
     1/2 sigma^2 S^2 D[V[S, t], {S, 2}] - r V[S, t] == 0, 
   DirichletCondition[V[S, t] == 1, (S >= 100 && t == 1)], 
   DirichletCondition[V[S, t] == 0, ( S < 100 && t == 1)]}, 
  V, {S, 10, 200}, {t, 0, 1}, PrecisionGoal -> 10]

It's not at all stable for V[100,0] ranging from 0.43 to 0.56 for slight change of S boundaries. I was trying to price binary digitals with a pde where payoff is 1 if Spot > 100 at expiry. Probably I should supply the mesh along with the pde problem to get a stable solution. Maybe a mesh which is finer near expiry time and very sparse before expiry time.

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.