Project Overview

This project assembles a library of Java classes for Monte Carlo simulation of stochastic processes with special attention to applications in Finance.

The classes are designed to replicate the basic mathematical notions of probability theory: random variable, conditioning on information, stochastic process, optional time, sampling a process at an optional time etc. Staying close to mathematical terminology and concepts has several benefits:

Time evolves in multiples t*dt, t=0,1,...,T of a time step dt. Integer time t used in code corresponds to real time t*dt and T is the number of time steps to the time horizon T*dt of the simulation.

Information. It is assumed that the simulation operates in a context providing increasing information about all random phenomena under observation as time increases. Methods take account of this context through the time parameter t. In practice the information available at time t is the path of some stochastic process sε[0,t]-> X(s) up to time t.

Random variables, conditioning. Random variables H are defined through the abstract method getValue(int t) to be interpreted as the next sample from the distribution of H conditioned on all information available at time t. The precise nature of the information and how one conditions on it depends on the context and the implementation is left to the concrete subclasses. There may not be any information or sense of time in which case the paramter t is simply ignored.

In the most important case however the random variable H is a functional (deterministic function) of the path of some stochastic process in which case there is a standard sense of information avialable at time t and how to condition on it (path functional).

Random variables then provide methods to compute numerous statistics (such as means, standard deviations, etc.) and histograms all conditioned on information available at the current time t.

Stochastic Processes are defined through the abstract method timeStep(int t) which advances the path of the process from path[u],u<=t to path[t+1]. A sample of a process X=(X_0,X_1,...,X_T) is a realized path of values X_0=x_0,X_1=x_1,...,X_T=x_T.

The information available at time t is the seqence of values x_0,x_1,...,x_t which have been observed by time t.

A random variable H which is a deterministic function H=f(X_0,X_1,...,X_T) of the path of the process X is called a path functional. Conditioning H at time t on an observed path x_0,x_1,...,x_t means passing to the random variable H=f(x_0,x_1,...,x_t,X_{t+1},...,X_T) and a new sample getValue(t) is generated by branching the existing path at time t (continuing the path from time t to the horizon T) and evaluating H along this branch.

Optional times (stopping times). If a path functional C4=f(X_0,X_1,...,X_T) takes values in the set of times {0,1,2,...,T} it is called a random time. Such a random time is called optional if, for each t, the event [C4=t] is a function of the observed values X_0,...,X_t only.

In other words optionality guarentees that we can decide wether C4=t or not on the basis of information available at time t alone. No prevision into the future development of the process X is necessary to make this decision.

This property is crucial if some urgent action is called for at time C4. At each time t we then have to ask ourselves wether now C4=t, that is wether we have to act now or not.

Sampling a process at an optional time. The value X_C4 of the process X at a random time C4 is a random variable, the process X sampled at time C4.

Typically a random time C4 is defined to be the first time at which some significant event related to the process X takes place. The value X_C4 of the process X at time C4 is then of obvious interest.

Finance. Markets, trading strategies, the gains from trading (as a random variable), options, Monte Carlo pricing, hedging with various "deltas" (ie. weights of the underlying assets), hedge profit and loss (as a random variable) are all defined. Currently implemented:

Quasi Monte Carlo package. Halton, Sobol and Niederreiter-Xing generator.

Libor package. A forward Libor process L=(L_i) with a correlation and volatility structure of the form
d<log(L_i),log(L_j)> = sigma_i(t)sigma_j(t)rho(i,j)dt, with deterministic volatilities sigma_i(t) and constant correlations rho(i,j). See the document LiborProcess.ps.

Credits. Let us gratefully acknowledge the use of several other libraries.

Current state of the project. Please browse the extensive documentation to familiarize yourself with the API and see where the project stands now. Example programs illustrating the API can be found in the package Examples. In addition many classes have a main method which is a small test program which illustrates the use of the API.

Here is a list of known bugs.

Warning: This code is fragile and not tested enough. It is intended to provide an infrastructure for users to conduct their own experiments and supply them with ideas. The target audience are programmers willing to read the source code and run tests.
In case you are naive and have an unwavering belief in the infallibility of all things related to computing you are probably not a programmer and are here by mistake. Please note the Disclaimer, Lack of Warranty, Unfitness for Purpose

download the material.

Have fun!

Michael J. Meyer (email)