#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10 > void MCDigitalEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, DT cashPayoff, bool optionType, bool exEarly, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int timeSteps = 100, unsigned int requiredSamples = 1024, unsigned int maxSamples = 134217727 )
Digital Option Pricing Engine using Monte Carlo Simulation. The B-S model is used to describe dynamics of undelying asset price.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result, default double-precision data type. |
UN | number of Monte Carlo Module in parallel, which affects the latency and resources utilization, default 10. |
underlying | intial value of underlying asset at time 0. |
volatility | fixed volatility of underlying asset. |
dividendYield | the constant dividend rate for continuous dividends. |
riskFreeRate | risk-free interest rate. |
timeLength | the time length of contract from start to end. |
strike | the strike price also known as exericse price, which is settled in the contract. |
cashPayoff | fixed payoff when option is exercised. |
exEarly | exercise early or not, true: option exercise at anytime. false: option only exericse at expiry time. |
optionType | option type. 1: put option, 0: call option. |
seed | array to store the inital seeds for each RNG. |
output | output array. |
requiredTolerance | the tolerance required. If requiredSamples is not set, when reaching the required tolerance, simulation will stop, default 0.02. |
requiredSamples | the samples number required. When reaching the required number, simulation will stop, default 1024. |
timeSteps | the number of discrete steps from 0 to T, T is the expiry time, default 100. |
maxSamples | the maximum sample number. When reaching it, the simulation will stop, default 2,147,483,648. |