Pricing Engine Kernel APIs¶
CPICapFloorEngine¶
Defined in <xf_fintech/cpi_capfloor_engine.hpp>¶
class CPICapFloorEngine
DiscountingBondEngine¶
Defined in <xf_fintech/discounting_bond_engine.hpp>¶
class DiscountingBondEngine
InflationCapFloorEngine¶
Defined in <xf_fintech/inflation_capfloor_engine.hpp>¶
class InflationCapFloorEngine
FdHullWhiteEngine¶
Defined in <xf_fintech/fd_hullwhite_engine.hpp>¶
class FdHullWhiteEngine
FdG2SwaptionEngine¶
Defined in <xf_fintech/fd_g2_swaption_engine.hpp>¶
class FdG2SwaptionEngine
binomialTreeEngine¶
#include "xf_fintech/bt_engine.hpp"
template <typename DT> DT binomialTreeEngine ( BinomialTreeInputDataType <DT>* inputData, int optionType )
BinomialTree Engine using CRR (Cox, Ross & Rubinstein)
Parameters:
inputData | A structure containing the input model parameters |
optionType | Calculate for NPV European or American Call or Put |
Returns:
The calculated NPV
cfB76Engine¶
#include "xf_fintech/cf_b76.hpp"
template <typename DT> void cfB76Engine ( DT f, DT v, DT r, DT t, DT k, DT q, unsigned int call, DT* price, DT* delta, DT* gamma, DT* vega, DT* theta, DT* rho )
Single option price plus associated Greeks.
Produces a single price and associated Greeks for the given input parameters. This function is optimized to be synthesized by the HLS compiler and as such uses the hls namespace for the maths functions. In addition, the code is structured to calculate common elements (in parallel where possible) and reuse as appropriate.
Parameters:
DT | Data Type used for this function |
f | underlying forward price |
v | volatility (decimal form) |
r | risk-free rate (decimal form) |
t | time to maturity |
k | strike price |
q | continuous dividend yield rate |
call | control whether call or put is calculated |
price | call/put premium |
delta | model sensitivity |
gamma | model sensitivity |
vega | model sensitivity |
theta | model sensitivity |
rho | model sensitivity |
cfBSMEngine¶
#include "xf_fintech/cf_bsm.hpp"
template <typename DT> void cfBSMEngine ( DT s, DT v, DT r, DT t, DT k, DT q, unsigned int call, DT* price, DT* delta, DT* gamma, DT* vega, DT* theta, DT* rho )
Single option price plus associated Greeks.
Produces a single price and associated Greeks for the given input parameters. This function is optimized to be synthesized by the HLS compiler and as such uses the hls namespace for the maths functions. In addition, the code is structured to calculate common elements (in parallel where possible) and reuse as appropriate.
Parameters:
DT | Data Type used for this function |
s | underlying |
v | volatility (decimal form) |
r | risk-free rate (decimal form) |
t | time to maturity |
k | strike price |
q | continuous dividend yield rate |
call | control whether call or put is calculated |
price | call/put premium |
delta | model sensitivity |
gamma | model sensitivity |
vega | model sensitivity |
theta | model sensitivity |
rho | model sensitivity |
FdBsLvSolver¶
#include "xf_fintech/fd_bs_local_volatility_solver.hpp"
template < typename DT, typename DT_EQ_TYPE, unsigned int N, unsigned int M > void FdBsLvSolver ( ap_uint <512>* xGrid, ap_uint <512>* tGrid, ap_uint <512>* sigma, ap_uint <512>* rate, ap_uint <512>* initialCondition, float theta, DT boundary_lower, DT boundary_upper, unsigned int tSteps, ap_uint <512>* solution )
Entry point to Fd1D Solver.
Parameters:
DT | Data Type used for this function |
DT_EQ_TYPE | Integer data type of same width as DT |
N | Discretized spatial grid size |
M | Discretized temporal grid maximum possible size |
xGrid | Pointer to spatial grid |
tGrid | Pointer to temporal grid |
sigma | Pointer to 2D volatility array sigma(x,t) |
rate | Pointer to interest rate vector |
boundary | Pointer to boundary vector |
boundary | Pointer to initial condition |
tGrid | Pointer to temporal grid |
theta | Controls explicit/implicit/Crank-Nicholson |
tSteps | Size of tGrid |
solution | Final solution vector |
FdDouglas¶
#include "xf_fintech/fd_solver.hpp"
template < typename DT, unsigned int MEM_WIDTH, unsigned int INDEX_WIDTH, unsigned int A_SIZE, unsigned int M_SIZE, unsigned int LOG2_M_SIZE, unsigned int DIM2_SIZE1, unsigned int DIM2_SIZE2 > void FdDouglas ( DT A [A_SIZE], unsigned int Ar [A_SIZE], unsigned int Ac [A_SIZE], unsigned int Annz, DT A1 [M_SIZE][DIM2_SIZE1], DT A2 [M_SIZE][DIM2_SIZE2], DT X1 [M_SIZE][DIM2_SIZE1], DT X2 [M_SIZE][DIM2_SIZE2], DT b [M_SIZE], DT u0 [M_SIZE], unsigned int M1, unsigned int M2, unsigned int N, DT u [M_SIZE] )
Top level callable function to perform the Douglas ADI method.
This function creates the solver/stream wrapper objects and connects them up It also provides the extra connectivity for the non-streaming blocks
Parameters:
A | Sparse matrix value |
Ar | Sparse matrix row |
Ac | Sparse matrix column |
Annz | Number of non-zeros in sparse matrix (how many elements of A/Ar/Ac are valid) |
A1 | Tridiagonal matrix stored as three vectors lower/main/upper |
A2 | Pentadiagonal matrix stored as five vectors lower/lower/main/upper/upper |
X1 | Tridiagonal matrix stored as three vectors lower/main/upper |
X2 | Pentadiagonal matrix stored as five vectors lower/lower/main/upper/upper |
b | Boundary condition vector |
u0 | Initial condition (payoff condition for a call option) |
M1 | Size of array [0..M1] in S direction |
M2 | Size of array [0..M2] in V direction |
N | Iteration count |
u | Calculated price grid |
hcfEngine¶
#include "xf_fintech/hcf_engine.hpp"
template <typename DT> DT hcfEngine (struct hcfEngineInputDataType <DT>* input_data)
Engine for Heston Closed Form Solution.
Parameters:
input_data | A structure containing the kerenl model parameters |
Returns:
the calculated call value
hjmPcaEngine¶
#include "xf_fintech/hjm_engine.hpp"
template < typename DT, unsigned MAX_TENORS, unsigned MAX_CURVES, unsigned NCU = 1 > void hjmPcaEngine ( DT ratesIn [MAX_CURVES *MAX_TENORS], const unsigned int noTenors, const unsigned int noObservations, DT riskNeutralDrift [MAX_TENORS], DT volatilities [hjmModelParams::N][MAX_TENORS], DT presentForwardCurve [MAX_TENORS] )
Analyses raw historical data and calculates the input vectors for a Heath-Jarrow-Morton Monte-Carlo simulation.
Parameters:
DT | The internal DataType of the calculations. |
MAX_TENORS | Maximum support synthetisable tenors. |
MAX_CURVES | Maximum synthetisable number of entries from the historial data. |
NCU | Number of parallel component units when processing the historical data matrix. |
ratesIn | Matrix with the historical data. |
noTenors | Number of tenors in the simulation. Must be fewer than MAX_TENORS and be a multiple of NCU . |
noObservations | Number of forward curves in the historical data matrix. |
riskNeutralDrift | Output buffer for the Risk Neutral Drift vector for the MC simulation, tenors wide |
volatilities | Output vectors of the volatilities extracted from historical data. Consists on N vectors, tenors wide. |
presentForwardCurve | Output vector with the forward curve at present date. |
hjmMcEngine¶
#include "xf_fintech/hjm_engine.hpp"
template < typename DT, class PT, unsigned MAX_TENORS, unsigned UN = 1 > void hjmMcEngine ( const unsigned tenors, const float simYears, const unsigned int noPaths, DT presentFc [MAX_TENORS], DT vol [hjmModelParams::N][MAX_TENORS], DT drift [MAX_TENORS], PT pricer [UN][1], ap_uint <32> seed [UN][hjmModelParams::N], hls::stream <DT>& outputPrice )
Prepares and runs a Monte-Carlo simulation and pricing for the Heath-Jarrow-Morton framework.
Parameters:
DT | The internal DataType in the simulation. |
PT | The class name for the HJM pricer. |
MAX_TENORS | The maximum number of supported tenors in the simulation. |
UN | The Unroll Number for the path generators and pricers. It will determine the level of parallelism of the simulation. |
tenors | Number of tenors to process. Must be <= MAX_TENORS . |
simYears | Number of years to simulate per path. Each path’s IFR matrix is composed of simYears/dt rows. |
noPaths | Number of MonteCarlo paths to generate. |
presentFc | Present forward curve, determining the first row of every simulated path. |
vol | Volatility vectors for N factor model, tenors elements wide, describing the volatility per tenor for each of the factors. |
drift | Risk Neutral Drift vector, tenors elements wide. |
pricer | UN instances of the selected path pricer. Must be of PT class and implement the correct MC path pricer method interface. |
seed | Seeds for the RNGs in the simulation. There are N RNGs per path generator and UN path generators. |
outputPrice | Stream with the calculated HJM output price. |
hjmEngine¶
#include "xf_fintech/hjm_engine.hpp"
template < typename DT, class PT, unsigned MAX_TENORS, unsigned MAX_CURVES, unsigned PCA_NCU = 1, unsigned MC_UN = 1 > void hjmEngine ( const unsigned tenors, const unsigned curves, const float simYears, const unsigned noPaths, DT ratesIn [MAX_CURVES *MAX_TENORS], PT pricer [MC_UN][1], ap_uint <32> seeds [MC_UN][hjmModelParams::N], hls::stream <DT>& outPrice )
Prepares and runs a Monte-Carlo simulation and pricing for the Heath-Jarrow-Morton framework from historical data. Combines hjmPcaEngine and hjmMcEngine into a single operation.
Parameters:
DT | The internal DataType in the simulation. |
PT | The class name for the HJM pricer. |
MAX_TENORS | The maximum number of supported tenors in the simulation. |
MAX_CURVES | Maximum synthetisable number of entries from the historial data. |
PCA_NCU | Number of parallel computing units when implementing the PCA engine. |
MC_UN | The Unroll Number for the path generators and pricers. It will determine the level of parallelism of the simulation. |
tenors | Number of tenors to process. Must be <= MAX_TENORS . |
curves | Number of curves in the historical data matrix. |
simYears | Number of years to simulate per path. Each path’s IFR matrix is composed of simYears/dt rows. |
noPaths | Number of MonteCarlo paths to generate. |
ratesIn | Historical data matrix. |
pricer | UN instances of the selected path pricer. Must be of PT class and implement the correct MC path pricer method interface. |
seed | Seeds for the RNGs in the simulation. There are N RNGs per path generator and UN path generators. |
outputPrice | Stream with the calculated HJM output price. |
lmmEngine¶
#include "xf_fintech/lmm_engine.hpp"
template < typename DT, typename PT, unsigned MAX_TENORS, unsigned NF, unsigned UN = 5, unsigned PCA_NCU = 2 > void lmmEngine ( unsigned noTenors, unsigned noPaths, hls::stream <DT>& rho, DT presentFc [MAX_TENORS], hls::stream <DT>& sigma, PT pricer [UN][1], ap_uint <32> seeds [UN], DT* outputPrice )
Prepares and runs a Monte-Carlo simulation and pricing for the LIBOR Market Model framework from a given correlation and volatility matrix.
Parameters:
DT | The data type of the internal simulation. |
PT | The class name for the LMM pricer. |
NF | Number of factors to use in the internal LMM Monte-Carlo simulation. |
UN | Unroll number for path generators and pricers. It will determine the parallelism level of the simulation. |
PCA_NCU | Unroll number for the dimensionality reduction of the correlation matrix stage. |
noTenors | Number of tenors to simulate. It must be <= MAX_TENORS |
noPaths | Number of MonteCarlo paths to generate. It will determine the accuracy of the final price. |
rho | Stream with generated correlation matrix between tenors. |
presentFc | Current LIBOR rates for this tenor structure. |
sigma | Stream with lower triangular calibrated volatilities matrix. |
pricer | UN instances of the selected path pricer. Must be of PT class and implement the correct MC path pricer method interface. |
seeds | Seeds for the RNGs in the simulation. There are UN RNGs in total. |
outputPrice | Calculated LMM MonteCarlo price with the selected pricer. |
M76Engine¶
#include "xf_fintech/m76_engine.hpp"
template <typename DT> void M76Engine ( struct jump_diffusion_params <DT>* p, DT* call_price )
Engine for the Merton Jump Diffusion Model.
Parameters:
p | A structure containing the jump diffusion parameters |
call_price | An array of BS solutions multiplied by the jump weighting Note that these must be subsequently summed to get the Jump Diffusion solution |
MCEuropeanEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10, bool Antithetic = false > void MCEuropeanEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
European Option Pricing Engine using Monte Carlo Method. This implementation uses Black-Scholes valuation model.
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. |
Antithetic | antithetic is used for variance reduction, default this feature is disabled. |
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 to store the inital seed 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. |
MCEuropeanPriBypassEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10 > void MCEuropeanPriBypassEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
path pricer bypass variant (interface compatible with standard MCEuropeanEngine)
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. |
optionType | option type. 1: put option, 0: call option. |
seed | array to store the inital seed 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. |
MCEuropeanHestonEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 8, DiscreType discretization = kDTQuadraticExponential, bool Antithetic = false > void MCEuropeanHestonEngine ( DT underlying, DT riskFreeRate, DT sigma, DT v0, DT theta, DT kappa, DT rho, DT dividendYield, bool optionType, DT strike, DT timeLength, ap_uint <32> seed [UN][2], DT* outputs, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
European Option Pricing Engine using Monte Carlo Method based on Heston valuation model.
Parameters:
DT | supported data type including double and float, which decides the precision of output, default double-precision data type. |
UN | number of Monte Carlo Module in parallel, which affects the latency and resources utilization, default 10. |
DiscreType | methods which is used to discrete the stochastic process. Currently, five discrete types, including kDTPartialTruncation, kDTFullTruncation, kDTReflection, kDTQuadraticExponential and kDTQuadraticExponentialMartingale, are supported, default kDTQuadraticExponential. |
Antithetic | antithetic is used for variance reduction, default this feature is disabled. |
underlying | the initial price of underlying asset at time 0. |
riskFreeRate | risk-free interest rate. |
sigma | the volatility of volatility |
v0 | initial volatility of stock |
theta | the long variance, as t tends to infinity, the expected value of vt tends to theta. |
kappa | the rate at which vt tends to theta. |
rho | the correlation coefficient between price and variance. |
dividendYield | the constant dividend rate for continuous dividends. |
optionType | option type. 1: put option, 0: call option. |
strike | the strike price also known as exericse price, which is settled in the contract. |
timeLength | time length from now to expiry date. |
seed | the seeds used to initialize RNG. |
outputs | pricing result array of this engine. |
requiredTolerance | the tolerance required. If requiredSamples is not set, when reaching the required tolerance, simulation will stop. |
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. |
MCMultiAssetEuropeanHestonEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int ASSETS = 5, int UN = 1, DiscreType discretization = kDTQuadraticExponential > void MCMultiAssetEuropeanHestonEngine ( DT underlying [ASSETS], DT riskFreeRate, DT sigma [ASSETS], DT v0 [ASSETS], DT theta [ASSETS], DT kappa [ASSETS], DT corrMatrix [ASSETS *2+1][ASSETS], DT rho [ASSETS], DT dividendYield [ASSETS], bool optionType, DT strike, DT timeLength, ap_uint <32> seed [UN][2], DT* outputs, DT requiredTolerance = 0.02, ap_uint <32> requiredSamples = 0, ap_uint <32> timeSteps = 100, ap_uint <32> maxSamples = 134217727 )
Multiple Asset European Option Pricing Engine using Monte Carlo Method based on Heston valuation model.
Parameters:
DT | supported data type including double and float, which decides the precision of output, default double-precision data type. |
ASSETS | number of underlying assets supported. |
UN | number of Monte Carlo Module in parallel, which affects the latency and resources utilization, default 10. |
DiscreType | methods which is used to discrete the stochastic process. Currently, five discrete types, including kDTPartialTruncation, kDTFullTruncation, kDTReflection, kDTQuadraticExponential and kDTQuadraticExponentialMartingale, are supported, default kDTQuadraticExponential. |
underlying | the initial price of underlying asset at time 0. |
riskFreeRate | risk-free interest rate. |
sigma | the volatility of volatility |
v0 | initial volatility of stock |
theta | the long variance, as t tends to infinity, the expected value of vt tends to theta. |
kappa | the rate at which vt tends to theta. |
corrMatrix | the LU decomposition result of correlation matrix of all stochastic variables, only none-zero elements are stored. |
rho | the correlation coefficient between price and variance. |
dividendYield | the constant dividend rate for continuous dividends. |
optionType | option type. 1: call option, 0: put option. |
strike | the strike price also known as exericse price, which is settled in the contract. |
timeLength | time length from now to expiry date. |
seed | the seeds used to initialize RNG. |
outputs | pricing result array of this engine. |
requiredTolerance | the tolerance required. If requiredSamples is not set, when reaching the required tolerance, simulation will stop. |
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. |
MCAmericanEnginePreSamples¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 2 > void MCAmericanEnginePreSamples ( DT underlying, DT volatility, DT riskFreeRate, DT dividendYield, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, ap_uint <8*sizeof (DT)*UN>* priceOut, ap_uint <8*sizeof (DT)>* matOut, unsigned int calibSamples = 4096, unsigned int timeSteps = 100 )
American Option Pricing Engine using Monte Carlo Method. PreSample kernel: this kernel samples some amount of path and store them to external memory.
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 (in path dimension), which affects the latency and resources utilization, default 2. |
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 to store the inital seed for each RNG. |
priceOut | price data output, the data can be stored to HBM or DDR |
matOut | matrix output, the data can be stored to HBM or DDR |
calibSamples | sample numbers that used in calibration, default 4096. |
timeSteps | the number of discrete steps from 0 to T, T is the expiry time, default 100. |
MCAmericanEngineCalibrate¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 2, int UN_STEP = 2 > void MCAmericanEngineCalibrate ( DT timeLength, DT riskFreeRate, DT strike, bool optionType, ap_uint <8*sizeof (DT)*UN>* priceIn, ap_uint <8*sizeof (DT)>* matIn, ap_uint <8*sizeof (DT)*4>* coefOut, unsigned int calibSamples = 4096, unsigned int timeSteps = 100 )
American Option Pricing Engine using Monte Carlo Method. Calibrate kernel: this kernel reads the sample price data from external memory and use them to calculate the coefficient.
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 (in path dimension), which affects the latency and resources utilization, default 2. [this unroll number should be equal to UN in MCAmericanEnginePresample] |
UN_STEP | number of Monte Carlo Module in parallel (in time steps dimension), which affects the latency and resources utilization, default 2. [this Unroll is completely resource bounded, unrelated to other params] |
timeLength | the time length of contract from start to end. |
riskFreeRate | risk-free interest rate. |
strike | the strike price also known as exericse price, which is settled in the contract. |
optionType | option type. 1: put option, 0: call option. |
priceIn | the price data, read in from DDR or HBM |
matIn | the matrix data, read in from DDR or HBM |
coefOut | the coef data that calculated by this kernel, the data can be stored to DDR or HBM |
calibSamples | sample numbers that used in calibration, default 4096. |
timeSteps | the number of discrete steps from 0 to T, T is the expiry time, default 100. |
MCAmericanEnginePricing¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 2 > void MCAmericanEnginePricing ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, ap_uint <8*sizeof (DT)*4>* coefIn, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 4096, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
American Option Pricing Engine using Monte Carlo Method. Pricing kernel.
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 (in path dimension), which affects the latency and resources utilization, default 2. [this unroll number should be equal to UN in MCAmericanEnginePresample] |
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. |
coefIn | the coef data that calculated by this kernel, the data is loaded from 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. |
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. |
MCAmericanEngine¶
#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. |
MCAsianGeometricAPEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 16 > void MCAsianGeometricAPEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
Asian Arithmetic Average Price Engine using Monte Carlo Method Based on Black-Scholes Model. The settlement price of the underlying asset at expiry time is the geomertic average of asset price during the option lifetime.
Parameters:
DT | Supported data type including double and float, which decides the precision of output. |
UN | The number of Monte Carlo Module in parallel, which affects the latency and resources utilization. |
underlying | The initial price of underlying asset. |
volatility | The market’s price volatility. |
dividendYield | The dividend yield is the company’s total annual dividend payments divided by its market capitalization, or the dividend per share, divided by the price per share. |
riskFreeRate | The risk-free interest rate is the rate of return of a hypothetical investment with no risk of financial loss, over a given period of time. |
timeLength | The given period of time. |
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. |
output | Output array. |
requiredTolerance | The tolerance required. If requiredSamples is not set, simulation will not stop, unless the requiredTolerance is reached, default 0.02. |
requiredSamples | The samples number required. When reaching the required number, simulation will stop, default 1024. |
timeSteps | Number of interval, default 100. |
maxSamples | The maximum sample number. When reaching it, the simulation will stop, default 2147483648. |
MCAsianArithmeticAPEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 16 > void MCAsianArithmeticAPEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
Asian Arithmetic Average Price Engine using Monte Carlo Method Based on Black-Scholes Model. The settlement price of the underlying asset at expiry time is the arithmetic average of asset price during the option lifetime.
Parameters:
DT | Supported data type including double and float, which decides the precision of output. |
UN | The number of Monte Carlo Module in parallel, which affects the latency and resources utilization. |
underlying | The initial price of underlying asset. |
volatility | The market’s price volatility. |
dividendYield | The dividend yield is the company’s total annual dividend payments divided by its market capitalization, or the dividend per share, divided by the price per share. |
riskFreeRate | The risk-free interest rate is the rate of return of a hypothetical investment with no risk of financial loss, over a given period of time. |
timeLength | The given period of time. |
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. |
output | Output array. |
requiredTolerance | The tolerance required. If requiredSamples is not set, simulation will not stop, unless the requiredTolerance is reached, default 0.02. |
requiredSamples | The samples number required. When reaching the required number, simulation will stop, default 1024. |
timeSteps | Number of interval, default 100. |
maxSamples | The maximum sample number. When reaching it, the simulation will stop, default 2147483648. |
MCAsianArithmeticASEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 16 > void MCAsianArithmeticASEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
Asian Arithmetic Average Strike Engine using Monte Carlo Method Based on Black-Scholes Model. The settlement price of the underlying asset at expiry time is the asset price at expiry time, but the stock price is the arithmetic average of asset price during the option lifetime.
Parameters:
DT | Supported data type including double and float, which decides the precision of output. |
UN | The number of Monte Carlo Module in parallel, which affects the latency and resources utilization. |
underlying | The initial price of underlying asset. |
volatility | The market’s price volatility. |
dividendYield | The dividend yield is the company’s total annual dividend payments divided by its market capitalization, or the dividend per share, divided by the price per share. |
riskFreeRate | The risk-free interest rate is the rate of return of a hypothetical investment with no risk of financial loss, over a given period of time. |
timeLength | The given period of time. |
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. |
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. |
MCBarrierNoBiasEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10 > void MCBarrierNoBiasEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT barrier, DT strike, ap_uint <2> barrierType, bool optionType, ap_uint <32>* seed, DT* output, DT rebate = 0, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
Barrier Option Pricing Engine using Monte Carlo Simulation. Using brownian bridge to generate the non-biased result.
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. |
barrier | single barrier value. |
strike | the strike price also known as exericse price, which is settled in the contract. |
barrierType | barrier type including: DownIn(0), DownOut(1), UpIn(2), UpOut(3). |
optionType | option type. 1: put option, 0: call option. |
seed | array to store the inital seeds of RNG. |
output | output array. |
rebate | rebate value which is paid when the option is not triggered, default 0. |
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. |
MCBarrierEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10 > void MCBarrierEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT barrier, DT strike, ap_uint <2> barrierType, bool optionType, ap_uint <32>* seed, DT* output, DT rebate = 0, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
Barrier Option Pricing Engine using Monte Carlo Simulation.
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. |
barrier | single barrier value. |
strike | the strike price also known as exericse price, which is settled in the contract. |
barrierType | barrier type including: DownIn(0), DownOut(1), UpIn(2), UpOut(3). |
optionType | option type. 1: put option, 0: call option. |
seed | array to store the inital seeds for each RNG. |
output | output array. |
rebate | rebate value which is paid when the option is not triggered, default 0. |
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. |
MCCliquetEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 10 > void MCCliquetEngine ( DT underlying, DT volatility, DT dividendYield, DT riskFreeRate, DT timeLength, DT strike, bool optionType, DT* resetDates, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int timeSteps = 100, unsigned int requiredSamples = 1024, unsigned int maxSamples = 134217727 )
Cliquet Option Pricing Engine using Monte Carlo Simulation. The B-S model used to describe the dynamics of undelying asset.
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. |
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. |
resetDates | array for reset dates, such as Semiannual, Quarterly. |
seed | array to store the inital seeds of 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. |
MCDigitalEngine¶
#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. |
MCEuropeanHestonGreeksEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 1, DiscreType discretization = kDTQuadraticExponential > void MCEuropeanHestonGreeksEngine ( DT underlying, DT riskFreeRate, DT sigma, DT v0, DT theta, DT kappa, DT rho, DT dividendYield, bool optionType, DT strike, DT timeLength, ap_uint <32> seed [UN][2], DT* greeks, DT requiredTolerance = 0.02, unsigned int requiredSamples = 1024, unsigned int timeSteps = 100, unsigned int maxSamples = 134217727 )
European Option Greeks Calculating Engine using Monte Carlo Method based on Heston valuation model.
Parameters:
DT | supported data type including double and float, which decides the precision of output, default double-precision data type. |
UN | number of Monte Carlo Module in parallel, which affects the latency and resources utilization, default 10. |
DiscreType | methods which is used to discrete the stochastic process. Currently, five discrete types, including kDTPartialTruncation, kDTFullTruncation, kDTReflection, kDTQuadraticExponential and kDTQuadraticExponentialMartingale, are supported, default kDTQuadraticExponential. |
underlying | the initial price of underlying asset at time 0. |
riskFreeRate | risk-free interest rate. |
sigma | the volatility of volatility |
v0 | initial volatility of stock |
theta | the long variance, as t tends to infinity, the expected value of vt tends to theta. |
kappa | the rate at which vt tends to theta. |
rho | the correlation coefficient between price and variance. |
dividendYield | the constant dividend rate for continuous dividends. |
optionType | option type. 1: put option, 0: call option. |
strike | the strike price also known as exericse price, which is settled in the contract. |
timeLength | time length from now to expiry date. |
seed | the seeds used to initialize RNG. |
greeks | output calculated greeks. |
requiredTolerance | the tolerance required. If requiredSamples is not set, when reaching the required tolerance, simulation will stop. |
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. |
MCHullWhiteCapFloorEngine¶
#include "xf_fintech/mc_engine.hpp"
template < typename DT = double, int UN = 1 > void MCHullWhiteCapFloorEngine ( DT nomial, DT initRate, DT strike, bool isCap, DT singlePeriod, DT alpha, DT sigma, ap_uint <32>* seed, DT* output, DT requiredTolerance = 0.02, unsigned int requiredSamples = 0, unsigned int timeSteps = 2, unsigned int maxSamples = 134217727 )
Cap/Floor Pricing Engine using Monte Carlo Simulation. The Hull-White model is used to describe dynamics of short-term interest. This engine assume a flat term structure.
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. |
nomial | Nomial of capfloor contract. |
initRate | Current spot rate and forward rate (flat term structure). |
strike | Strike rate of capfloor contract |
isCap | True for cap, false for floor |
singlePeriod | period between each settlement date. |
alpha | Hull White model parameter |
sigma | Hull White model parameter |
seed | Array to store the inital seed for each RNG. |
output | Array to store result |
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 cap/floor settlement date. |
maxSamples | the maximum sample number. When reaching it, the simulation will stop, default 2,147,483,648. |
McmcCore¶
#include "xf_fintech/pop_mcmc.hpp"
template < typename DT, unsigned int NCHAINS, unsigned int NSAMPLES_MAX > void McmcCore ( DT temp_inv [NCHAINS], DT sigma [NCHAINS], DT x [NSAMPLES_MAX], unsigned int nSamples )
Top level Kernel function. Consists of INIT_LOOP and main sample loop: SAMPLES_LOOP
Generates sample from target distribution function.
Uses multiple Markov Chains to allow drawing samples from multi mode target distribution functions.
Proposal is generated ussing Normal Distribution
.
Parameters:
DT |
|
NCHAINS |
|
NSAMPLES_MAX |
|
temp_inv |
|
sigma |
|
nSamples |
|
x |
|
treeSwaptionEngine¶
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeSwaptionEngine ( Model& model, DT* process, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* exerciseCnt, int* floatingCnt, int* fixedCnt, DT flatRate, DT nominal, DT x0, DT spread, DT* NPV )
Tree Swaption Pricing Engine using Trinomial Tree based 1D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model class |
Process | stochastic process class |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process | parameters of stochastic process |
type | 0: Payer, 1: Receiver |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the maturity time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
exerciseCnt | exercise timepoints count in initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
fixedCnt | fixed coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
NPV | is pricing result array of this engine |
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeSwaptionEngine ( Model& model, DT* process1, DT* process2, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* exerciseCnt, int* floatingCnt, int* fixedCnt, DT flatRate, DT nominal, DT x0, DT spread, DT rho, DT* NPV )
Tree Swaption Pricing Engine using Trinomial Tree based 2D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model class |
Process | stochastic process class |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process1 | 1st dimensional parameters of stochastic process |
process2 | 2nd dimensional parameters of stochastic process |
type | 0: Payer, 1: Receiver |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
exerciseCnt | exercise timepoints count in initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
fixedCnt | fixed coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
rho | the correlation coefficient between price and variance. |
NPV | is pricing result array of this engine |
treeSwapEngine¶
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeSwapEngine ( Model& model, DT* process, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* floatingCnt, int* fixedCnt, DT flatRate, DT nominal, DT x0, DT spread, DT* NPV )
Tree Swap Pricing Engine using Trinomial Tree based 1D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model |
Process | stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process | parameters of stochastic process |
type | 0: Payer, 1: Receiver |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
fixedCnt | fixed coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
NPV | is pricing result array of this engine |
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeSwapEngine ( Model& model, DT* process1, DT* process2, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* floatingCnt, int* fixedCnt, DT flatRate, DT nominal, DT x0, DT spread, DT rho, DT* NPV )
Tree Swap Pricing Engine using Trinomial Tree based 2D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model |
Process | stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process1 | 1st dimensional parameters of stochastic process |
process2 | 2nd dimensional parameters of stochastic process |
type | 0: Payer, 1: Receiver |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
fixedCnt | fixed coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
rho | the correlation coefficient between price and variance. |
NPV | is pricing result array of this engine |
treeCapFloorEngine¶
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeCapFloorEngine ( Model& model, DT* process, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* floatingCnt, DT flatRate, DT nominal, DT* cfRate, DT x0, DT spread, DT* NPV )
Tree CapFloor Pricing Engine using Trinomial Tree based 1D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model that has been initialized |
Process | parameters of stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model |
process | stochastic process |
type | 0: Cap, 1: Collar, 2: Floor |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
cfRate | cap rate and floor rate |
x0 | initial underlying |
spread | spreads on interest rates |
NPV | is pricing result array of this engine |
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeCapFloorEngine ( Model& model, DT* process1, DT* process2, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* floatingCnt, DT flatRate, DT nominal, DT* cfRate, DT x0, DT spread, DT rho, DT* NPV )
Tree CapFloor Pricing Engine using Trinomial Tree based 2D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model |
Process | stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process1 | 1st dimensional parameters of stochastic process |
process2 | 2nd dimensional parameters of stochastic process |
type | 0: Cap, 1: Collar, 2: Floor |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
floatingCnt | floating coupon timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
cfRate | cap rate ans floor rate |
x0 | initial underlying |
spread | spreads on interest rates |
rho | the correlation coefficient between price and variance. |
NPV | is pricing result array of this engine |
treeCallableEngine¶
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeCallableEngine ( Model& model, DT* process, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* callableCnt, int* paymentCnt, DT flatRate, DT nominal, DT x0, DT spread, DT* NPV )
Tree Callable Fixed Rate Bond Pricing Engine using Trinomial Tree based 1D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model |
Process | stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process | parameters of stochastic process |
type | type of the callability, 0: Call, 1: Put |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
callableCnt | callable timepoints count in initTime. |
paymentCnt | payment timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
NPV | is pricing result array of this engine |
#include "xf_fintech/tree_engine.hpp"
template < typename DT, typename Model, typename Process, int DIM, int LEN, int LEN2 > void treeCallableEngine ( Model& model, DT* process1, DT* process2, int type, DT fixedRate, int timestep, DT initTime [LEN], int initSize, int* callableCnt, int* paymentCnt, DT flatRate, DT nominal, DT x0, DT spread, DT rho, DT* NPV )
Tree Callable Fixed Rate Bond Pricing Engine using Trinomial Tree based 2D Lattice method.
Parameters:
DT | supported data type including double and float data type, which decides the precision of result. |
Model | short-rate model |
Process | stochastic process |
DIM | 1D or 2D short-rate model |
LEN | maximum length of timestep, which affects the latency and resources utilization. |
LEN2 | maximum length of node of tree, which affects the latency and resources utilization. |
model | short-rate model that has been initialized |
process1 | 1st dimensional parameters of stochastic process |
process2 | 2nd dimensional parameters of stochastic process |
type | type of the callability, 0: Call, 1: Put |
fixedRate | fixed annual interest rate. |
timestep | estimate the number of discrete steps from 0 to T, T is the expiry time. |
initTime | the time including begin timepoint, end timepoint, exercise timepoints, floating coupon timepoints, and fixed coupon timepoints is arranged from small to large. The timepoints are relative values based on the reference date the unit is year. |
initSize | the length of array initTime. |
callableCnt | callable timepoints count in initTime. |
paymentCnt | payment timepoints count in initTime. |
flatRate | floating benchmark annual interest rate |
nominal | nominal principal |
x0 | initial underlying |
spread | spreads on interest rates |
rho | the correlation coefficient between price and variance. |
NPV | is pricing result array of this engine |