This engine uses the framework of Monte Carlo Simulation in L1. It has a template argument to setup unroll number of Monte Carlo Module (MCM). For a single MCM, it has two normally distributed random number generators (RNGs) as input, to simulate random walks of stock price and its volatility. Two RNGs will send two random numbers stream to Heston PathGenerator for calculating the stock price at each time steps. The stock price is sent to the pricer for calculating the option’s value of each path. After certain number of paths being generated, the accumulator determines whether the value of options has been “stable” according to its variance. Then, it will stop and output the average of option values as the final result. However, if it is not stable, MCM will move to the next round of calculation to generate more paths.
Optimization in two parts:
- Optimization of L1 functions.
- Save one call of cumulative distribution function in single underlying assets since it can get the value directly from RNGs. It may not work for multiple underlying assets because it will lose direct link between Gaussian random number and its corresponding uniform random number.