2
$\begingroup$

I am trying to work backwards from a binomial tree. To make it clear right away, here is a graph General Concept of a Binomial Tree Binomial Tree with some numbers

The basic concept is that price of a financial asset (for ex. a stock) starting from t=0 (the initial node from where the tree begins) moves "up" or "down" each period with certain probabilities. In my case, from t=0 to t=1, this price goes up 3.84 times (u=3.84) or falls 0.26 times (d=0.26) with probability of going up at 0.21 (21%) or falling at 0.79 (79%). If we assume the price at t=0 to be p0, then at t=1, it will be either 3.84p0 or 0.26p0 with respective probabilities 0.21 or 0.79. The good thing is that this proportion by which price goes up or comes down and the associated probabilities ARE THE SAME from one period to the other. In my case, I have t=10, so that price changes from t=0 to t=1,t=2,....t=10. At t=10, there will be 11 terminal nodes (the general figure shows the concept with 2 time periods and the second figure has 3 periods: PLEASE IGNORE the NUMBERS in the second figure). In finance, this kind of binomial tree is regularly used for valuing an option (but my problem is a little different and I want to code it in Mathematica). In my case, we choose many p0's: Range[0.01,1000000,1000]. There will be 1000 different (initial) p0's. We can construct binomial trees for each of the p0's. At t=10, the prices would be p0*u^10,p0*u^9*d,p0*u^8*d^2.....p0*u*d^9,p0*d^10. Similarly for t=9,...t=1. The value of the option (for my problem) at the terminal node t=10 is Max[npva,pict] where npva=-1549.56 and pict(p)=0.001*(110978-1.382*p) for each of the 11 nodes. Then at the previous period t=9, at each node the value of the option is Max[npva, pict+rho*expected value] where rho=0.975; expected value=0.21*value of the option (if the price goes up)+0.21*value of the option (if the price goes down). As I said, the value of the option at each of the nodes at the final period is just Max[npva,pict]. In my problem, this process is repeated until t=0 (just one point). Taking Max[npva, pict+rho*expected value], I get the option value at t=0. A similar approach, but little different method is to find option values in finance with some known strike price etc. My application is for economics and so its not the same. Any help would be greatly appreciated.

$\endgroup$
  • $\begingroup$ If you could distill out the extraneous information in you're question it will be easier to help you. Perhaps provide some work you've already done and make the question you would like answered clearer. For example, rather than explaining the particulars of your case, maybe identify a more general question we can answer that you can then apply to your case. $\endgroup$ – b3m2a1 Dec 30 '16 at 15:43
  • $\begingroup$ @MB1965 Thank you for your help. I figured out some part of the problem myself later. I later found a code from a journal paper for working backwards from the terminal nodes to get the option value. $\endgroup$ – Supratim Das Gupta Jan 1 '17 at 1:10
0
$\begingroup$

So as I understand your problem you need a way to traverse a tree defined by an initial value and a pair of weighted probabilities to be applied to a node to generate its child nodes.

That's easy enough to do with Fold. Then at each step you also seem to want to calculate the "option value" or whatever, so we'll also pass that into our Fold call.

We'll set up your parameters and that stuff:

npva = -1549.56;
pict[p_] := 0.001*(110978 - 1.382*p);
expectedValue[p_, u_, d_] := .21*u*p + .21*d*p;
rho = .975;
optionValue[p_, rho_, u_, d_] := 
  Max[npva, pict[p] + rho*expectedValue[p, u, d]];

Then the tree traversal code:

treeTraverseStep[{t0_, p0_, ev_}, 
   weights : ({__} -> {u_, d_})] :=
  {t0 + 1, 
   p0*(RandomChoice[weights]), optionValue[p0, rho, u, d]};
treeTraverse[p0_, tree_] :=
  With[{traversal =
     FoldList[
      treeTraverseStep[#, #2] &,
      {0, p0, optionValue[p0, rho, Sequence @@ Last@First@tree]},
      tree]},
   ReplacePart[traversal,
    {-1, 3} -> optionValue[traversal[[-1, 2]], 0, 0, 0]
    ]
   ];

And then because it seems in your case you suggest there is only one set of probabilities you need to check and you have 10 time steps:

weights = {.79, .21} -> {.26, 3.84};
tree = ConstantArray[weights, 10];

Then we'll test this:

In[204]:= treeTraverse[1, tree]

Out[204]= {{0, 1, 111.816}, {1, 3.84, 111.816}, {2, 0.9984, 
  114.196}, {3, 3.83386, 111.815}, {4, 0.996803, 114.191}, {5, 
  0.259169, 111.813}, {6, 0.0673839, 111.195}, {7, 0.258754, 
  111.034}, {8, 0.067276, 111.195}, {9, 0.0174918, 111.034}, {10, 
  0.00454786, 110.978}}

For each element of that list, the first value is the time step, the second is the price after applying the weighting, and the third is the option value as you have it defined.

We can even see what happens if we flip the weighting:

In[207]:= treeTraverse[1, tree]

Out[207]= {{0, 1, 111.816}, {1, 3.84, 111.816}, {2, 14.7456, 
  114.196}, {3, 56.6231, 123.336}, {4, 217.433, 158.433}, {5, 834.942,
   293.207}, {6, 3206.18, 810.737}, {7, 12311.7, 2798.05}, {8, 47277.,
   10429.3}, {9, 181544., 39733.5}, {10, 47201.3, 45.7457}}

Hopefully that solves the problem you were getting at.

$\endgroup$
  • $\begingroup$ Thank you for your help. I figured out some part of the problem myself later. I later found a code from a journal paper for working backwards from the terminal nodes to get the option value. But I will definitely use your code for next time. It looks more transparent. Thanks $\endgroup$ – Supratim Das Gupta Jan 1 '17 at 1:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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