A sample program

The binomial tree is the simplest way to evaluate option values.  I have implemented a small binomial tree program that computes the call option value using the binomial tree.  The usage of the program is as follows:
~vpathak/binomial/testbinomial 100 0.4 105 0.5 0.0525 10
where:
100 is the securityprice
0.4 is the annual volatility, 40% means 0.4
105 is the strike price of the call
0.5 is time to expiry in years
0.0525 is the risk free rate of interest i.e. 5.25%
10 is the number of levels in the tree

Build Instructions

You can find the source code of the program at math.rutgers.edu/~vpathak/binomial.  I have checked that everyone can access the directory.  I suggest you make a copy of the entire directory in your account by running:
cp -fR ~vpathak/binomial .
from math.rutgers.edu or matrix.rutgers.edu.  The latter works better because the Makefile is linux compatible.  For running it on a sun machine you will have to tweak the Makefile and add -lm and -lstdc++ to the linker line.  The program files are also available online:
binomial.h      Class definition
binomial.cpp   Implementation of class functions
test.cpp
         File with the main function
Makefile
         Makefile to make the program

Once you have a copy of the source code, it is a good idea to start reviewing test.cpp, binomial.h, and binomial.cpp in that order.  The first file has the main program, you may like to tweak it for your entertainment.  The second file is the class definition, which you make like to extend.  The third file has the implementation which will be useful to understand.  Finally, after making your changes, you can compile the program by typing "make".  You can also clear out the object and executable files by typing "make clean".

Sample Run

A sample run of the program gives the following output:
./testbinomial 100 0.4 105 0.5 0.0525 5
[100,0,9.54754]
[88.1182,0.1,2.92679]   [113.484,0.1,16.2688]
[77.6482,0.2,0] [100,0.2,5.8844]        [128.786,0.2,26.8245]
[68.4222,0.3,0] [88.1182,0.3,0] [113.484,0.3,11.8307]   [146.151,0.3,42.1006]
[60.2924,0.4,0] [77.6482,0.4,0] [100,0.4,0]     [128.786,0.4,23.786]    [165.858,0.4,60.8584]

You may like to compare with Peter Hoadley's CRR Binomial Tree Site for comparison.