#include <vector> #include "xf_fintech_api.hpp" using namespace xf::fintech; int retval = XLNX_OK; int i; // Instantiate a Monte-Carlo European object... MCEuropean mcEuropean; // Some input data... OptionType optionType = Put; double stockPrice = 36.0; double strikePrice = 40.0; double riskFreeRate = 0.06; double dividendYield = 0.0; double volatility = 0.20; double timeToMaturity = 1.0; /* in years */ double requiredTolerance = 0.02; double optionPrice; // output // Claim the device for use by our object... retval = mcEuropean.claimDevice(pChosenDevice); if(retval == XLNX_OK) { for(i=0; i<100; i++) { //Run the model... retval = mcEuropean.run(optionType, stockPrice, strikePrice, riskFreeRate, dividendYield,volatility, timeToMaturity, requiredTolerance, &optionPrice); if(retval != XLNX_OK) { //TODO report error break; // out of loop } } } //Release the device... retval = mcEuropean.releaseDevice();
In the above example pChosenDevice is a pointer to a Device object. This acquired by enumerating available devices (see Device Enumeration)