where s is the stock price now and p is the probability of being at that price now, we will get 2, 4, 8, 16 ... possible prices as our code grows the tree. Each price s is shock by a factor u when the price increases and by d when it decreases.

One line of code defines the whole tree. Neat, huh?

If we define a European call option contract as

var call = function(s,k){
return Math.max(s-k,0);
}

where k is the call option's strike price.

we can price the call with something along the lines of

binomialTree.npv(call);

where binomialTree is our lazy binomial tree data structure.

The npv method takes all the possible call option prices at expiry; finds the expected value of the option; and discounts it.

Metamorphosis

The Crank Nicolson method would be interesting to investigate. There might be more of a contrast between the ugly imperative code and an elegant lazy solution.

Nevertheless the binomial tree is a good pedagogical method; it is also a clear example of the absurd reductionism found in finance.

Momentarily Binary

Sometimes life throws up equally absurd moments.

Zoran Mušič was in German occupied Venice when he was interrogated and tortured by the Gestapo.