#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN_PATH = 1, int UN_STEP = 1, int UN_PRICING = 2 > void MCAmericanEngine ( DT underlying, DT volatility, DT riskFreeRate, DT dividendYield, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, ap_uint <8*sizeof (DT)*UN_PATH>* priceData, ap_uint <8*sizeof (DT)>* matData, DT* output, DT requiredTolerance = 0.02, unsigned int calibSamples = 4096, unsigned int requiredSamples = 4096, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
American Option Pricing Engine using Monte Carlo Method. calibration process and pricing process all in one kernel.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result, default double-precision data type. |
UN_PATH | number of Monte Carlo Module of calibration process in parallel (in path dimension), which affects the latency and resources utilization, default 1. |
UN_STEP | number of Monte Carlo Module of calibration process in parallel (in time steps dimension), which affects the latency and resources utilization, default 1. |
UN_PRICING | number of Monte Carlo Module of pricing process in parallel (in path dimension), which affects the latency and resources utilization, default 2. Three unroll numbers UN_PATH, UN_STEP and UN_PRICING are independent. Each unroll number affects the execution speed of part of AmericanEngine. On-board test reveals that the pricing phase takes longest time of execution. Therefore, setting larger UN_PRICING benifits most with limited resources. |
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. |
optionType | option type. 1: put option, 0: call option. |
seed | array of seed to initialize RNG. |
priceData | the price data, used as the intermediate result storage location. It should be mapped to an external memory: DDR or HBM. |
matData | the matrix data, used as the intermediate result storage location. It should be mapped to an external memory: DDR or HBM. |
output | the output price data (size=1), can be stroed in DDR or HBM |
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. |
calibSamples | sample numbers that used in calibration, default 4096. |
timeSteps | the number of discrete steps from 0 to T, T is the expiry time. |
maxSamples | the maximum sample number. When reaching it, the simulation will stop, default 2,147,483,648. |