15.2.09

Generating the lattice from first principles

In an attempt to model the binomial lattice, I will have to generate the lattice data structure and decorate it with various properties(probabilities, prices, node Id’s etc), so I thought I would approach the problem by first generating the node Ids for each time-step. So here we go:

public void GenerateLatticeNodes()
{
var numberOfTimeSteps = 20;
var nodes = new Hashtable();
var nodeId = 1;
for (var i = 0; i < numberOfTimeSteps; i++)
{
var numberOfNodes = i + 1;
var nodesAtTimeStep = new int[numberOfNodes]; ;
for (var j = 0; j < numberOfNodes; j++)
nodesAtTimeStep[j] = nodeId++;
nodes.Add(i,nodesAtTimeStep);
}
//What no test?
}


For the moment this is just a collection of identifiers to which the object richness( the notion of a node having asset price, probability of up/down movement etc) will be added.

The node numbering scheme adopted is such that the initial node is 1 and subsequent nodes are numbered incrementally in an up/down fashion.

No comments: