Monday, January 29, 2007

Random Walk in Financial Engineering: The First Step

As any qualified software engineer would do, I set off my journal into Financial Engineering with a "hello, world" alike application. In the case of Finance Engineering, that would be to model the movement of individual stocks --- in Geometric Brownian Motion. I choosed C#/.NET 2.0 to write the application. The first step is a normal distribution random number generator. I'm too lazy to write my own, so I used the one written by Stefan Troschütz on code project. Alternatively, the random number generator can be written base on CLT (Central Limit Theorem). Next, instead of writting the simplified processes such as the standard wiener process, I started with the most general form of all: Ito Process: Coefficients a(x, t) and b(x, t) are both implemented as C# delegates. This enables implementing the simpler processes in the subclasses. For example, in standard wiener process, a(x, t) is set to 0 and b(x, t) to 1. In Geometric Brownian Motion, on the other hand, a(x, t) is set to μS while b(x, t) is set to δS: Here is one sample graph for an imaginary stock follows GBM. You can probably read some techinical indicators off it (support, resistence, etc):