Sunday, February 22, 2015

C++ Coding - Black Scholes Option Pricing - Monte Carlo

3.2 Monte Carlo: Black Scholes European Call Option

Now we are going to value an European call option using Monte-Carlo. The setup is very simple, we just need to sum up the payoffs from a bunch of sample paths and then take the average. First start with an empty program except for the random number generator, as follows

Monday, January 12, 2015

Visual Studio 2012 at the University of Manchester

Getting started on Visual Studio 2012
A previous post of mine dealt with setting up an empty project on Visual Studio 2012, which you can find if you click here. If you follow the instructions there you will find that the terminal disappears even when you run the program with "Start Without Debugging". This is because some of the default properties are not set up correctly on opening an empty project.

Saturday, December 20, 2014

C++ Coding - Time to first exit (C++11 VS2012)

4.1 Time To First Exit

Calculate the expected hitting time E[t∗] for a Brownian motion X(t), where the process must hit either X(t∗) = 0 or X(t∗) = 1 for t∗ < T. If neither boundary is hit within the time T then t∗ = T.

Assume that the process X follows the SDE

dX  =  μdt + σdW
where μ = 0.01 is the drift and σ = 0.75 is the standard deviation of the Brownian motion. We have that the initial start point of the Brownian motion is X(t = 0) = 0.56, and we set T = 1.

Friday, December 19, 2014

C++ Coding - Random Numbers (Update c++11 VS2012)

The example question for these solutions can be found on my website (click here).

2.1 Random Numbers

To use the new random number generator we need to include the random library, the cmath library for any calculations and also iostream to show results onscreen. We first create a new project with an empty program with the correct libraries, and then declare a variable of type mt19937. This declares a new random number generator, which generates pseudo random sequence of integers defined by the Mersenne Twister algorithm. A computer can only generate a random sequence of integers, but of course we can then take that sequence of integers and convert it to any required distribution. Some of the conversions are simple but others are more complex, luckily we now have inbuilt c++ conversion to all standard distributions (more on this later). This means you will always have to create a generator to pass as an argument to the probability distribution you want to generate.

Thursday, February 27, 2014

C++ Coding - Time to first exit

Question Calculate the expected time to first exit from the interval [0,1] for a Brownian motion X with the following SDE
where dW is a standard Wiener process and X(t=0)=0.56.

Thursday, March 7, 2013

C++ Coding - Using NAG for normal

Question Generate pseudo random numbers from the normal distribution with NAG libraries