University College London
Financial Computing
LGS MF2:
Computational Finance Notes 2011-12
King's Logo

Professor William T Shaw, University College London

Latest update 14th December 2011:

This week is for hands-on work with finite-difference modelling. Codes below...

Looking ahead to CUDA

If you want to start exploring this now and have access to a machine with a fairly recent Nvidia GPU, go to Nvidia CUDA download and get the driver, toolkit and SDK samples.

MF2 Lecture notes and supplementary information

It usually takes a while for IT issues to settle down so I will lecture theoretically for the first 2-3 times, then we will do some C/C++ and Mathematica introductions when we are all clear on how the computing is working out.

Topic 0. Introduction [PDF]

Topic 1. Principles of simulation via quantiles. The material for this consists of a base notebook (also PDF) that look at what has gone before. Then I will look at the reformulation of quantiles for Monte Carlo simulation via the solution of non-linear differential equations, which relies on selected bits of the following papers and preprints and web links. (We will just look at the summary in the first lecture.) I will not usually give Wikipedia as references but for these I wrote the relevant parts and no-one else has fouled them up (yet).

EJAM Quantile Mechanics 2008

JCF Student Quantile 2006

Peter Acklam's web page

Wikipedia on quantile functions

Wikipedia on probit

"Quantile Mechnics II" (with NB, including GPU work)

I found the link to Bailey's nice paper on extending Box Muller etc to Student t. It is here. Please use and CITE his work, as it is an important result, particularly in the light of the fact that you can go form normal to fat tailed in a one line code change,

Topic 2. Introduction to C++:

[PDF]

[notebook]

I recommend you get the examples all in one go from the zip file that you can download here. If you have trouble with the zip file the individual *.cpp files are also listed here but with these you might have to watch out for CR/LF (line-breaking issues) depending on what OS you use.

Topic 3. Copula simulation: (the PDF is big due to embedded graphics)

[notebook] [PDF]

Topic 4: Finite Difference Methods I will begin this by quickly going through some basic ideas on operator methods for FD; truncation errors and stability. The theory of this is given here [PDF].

Topic 5 Introduction to Heston-class models and associated transform work

This lecture will look at models of Heston type from the point of view of the presentation by Alan Lewis, in which payoffs are separated from Green's functions and the whole theory works much more elegantly. We will also give a proper view of the "damping factors" that have made a rather regrettable intrusion into the theory, and explain the relationship to complex analysis. How to avoid the branch cut "issue" will be summarized, Material is as follows:

Heston summary [notebook]

Heston summary [PDF]

Transform review [notebook]

Transform review [PDF]

Topic 6 Introduction to Mathematica. I have been using this tool for examples but now will explain how to use it!

[notebook] [PDF]

Topic 7: Implied Volatility Nightmares

I will do this on Dec 7 in part due to the need to sort out some technology for the FD sessions and in part because it is important!

So this explores the rather neglected topic of multiple solutions for implied volatility and instability even for vanilla cases. It also gives me the excuse to draw a fractal in a finance lecture!

IVNightmares.nb

IVNightmares.pdf

LAB SESSIONS for Dec 14 on...

Explicit in Mathematica: Notebook. [PDF]

Explicit in C++: First version. Second version.

Please go fetch the Public domain component of the numerical recipes file (see below) and install them on any other machine where you might be playing with these example codes.

Implicit Finite Difference Lab Session

C/C++ Codes: (save from browser, then Open in DEV C++ and save with *cpp.txt -> *.cpp

FullyImplicitDiffusion2cpp.txt

CNImplicitDiffusion2cpp.txt

DouglasImplicitDiffusion2cpp.txt

bsfindiffvsanalytic_cpp.txt

Notebook: FDLabSession2_Implicit.nb

PDF: FDLabSession2_Implicit.pdf

Non-smooth initial data: implicit schemes and option payoffs

We will round off this term with a completion of various FD issues. First there are the issues rasied by using actual option payoffs in the full PDE.

We will use the C codesLaLab: (download and save, then open in DEV C++ and save as *.cpp file)

blackscholesgreeks_cpp.txt

bsfindiffvsanalytic_cpp.txt

and the notebook/PDsF:

LabSession3.nb

LabSession3.pdf

LabSession4.nb

LabSession4.pdf

Next there is the issue of how to modify an implicit scheme to cope with early exercise. In an explicit or tree model one just takes the maximum of the payoff with the evolved value. How this works in an example explicit scheme is summarized in the following notebook and PDF:

AmericanPSOR.nb

AmericanPSOR.pdf

I will not go over analytic methods for Americans but you can read some more here.

Parallel Computing Lecture Notes

1. Introduction to GridMathematica. Available as

Notebook(3MB) or PDF (10MB).

2. Introduction to CUDA.

Part I Notebook or PDF.

C++ Programming Material

I am using the C++ development environment Dev-cpp from www.bloodshed.net, running under Windows XP. This is the environment available in the classroom.

Mark Joshi's web page that goes with his book Design Patterns and Derivatives Pricing is here. It has a link where you can download his code as a zip file. You might also like to take a look at his tools for linking C++ models to Excel. He supports the Dev-cpp environment with pre-made project files. See the section on Software downloads on this page.

The public domain C++ utility files for Numerical Recipes in C++ are downloadable from here. I have made a zip file containing all these files with the right .h or .c extensions and you can download it from here. On your own system you can add these to the Dev-Cpp\include\ directory or put it anywhere you like and use the Dev-Cpp Tools:Compiler Options:Directories:C++ includes menu option to point to it. There is also a self-extracting zip file for Windows available here. Note that other components of NR in C++ are NOT public domain nor are they shareware.  I will use the NR setup for arrays in all the C++ code in this course, when I need to do so.