Skip to content

Methodology

Rajdeep Konwar edited this page Jan 4, 2019 · 3 revisions

Taking a recursive Euler discretization of the Black-Scholes equation, we can generate future values of stock prices depending on the number of time-steps. This introduces an issue: the equation depends completely on the pseudorandom number generator, whose output can be unpredictable, hence is not a good prediction of a real life market.

This is where Monte-Carlo method comes into play. We approximate the values for a large number of timesteps, to ensure we are getting the most optimally accurate price approximation to a real life market scenario. We call the recursive function runBlackScholesModel within the inner loop of the Monte-Carlo simulations in our code (100 inner and 10,000 outer loops making a total of 1,000,000 iterations). This function returns a vector of 180 elements representing predicted stock prices for the next 180 mins (3 hrs).

At the outer loop, we take the average of 100 of these stock-price vectors into another vector called avgStock. Once the outer loops are completed, we take the average of 10,000 avgStock vectors into a single vector called optStock, containing the most optimal outcome from running the Monte-Carlo simulations a million times. The same execution is repeated with 50,000 outer loop iterations resulting in 5 million iterations.

Inside the runBlackScholesModel function, we generate an array of random numbers having standard normal distribution (with mean of 0.0 and standard deviation 1.0) based on a seed created by the system clock by making use of the available C++ class templates “default random engine” and “normal distribution”.

Clone this wiki locally