I NEED TO APPLY MONTE CARLO SIMULATION MODEL TO LOOK BACK CALL OPTION WITH CONTINUOUS BARRIER ON C++. THERE ARE ALL HEADER AND MAIN CPP FILES BELOW. THIS IS JUST AND EGZAMPLE FOR EUROPEN OPTION. I NEED TO CHANGE IT TO LOOK BACK CALL OPTION WITH CONTINUOUS BARRIER.
I HAVE TO WRITE a C++ program that will run a Monte Carlo simulation to approximate the theoretical price of the
up-and-out lookback call option with a continuous barrier.
These codes should be ready to price the option for any values of its characteristics, but find the theoretical
price for the following values:
. price of the underyling at the moment of option pricing: S0 = 195,
. strike price K = 200,
. annualized volatility rate = 0.2
. annualized risk-free rate r = 0.06
. time to maturity t = 0.5
using std::vector;
using std::cout;
using std::cin;
int main(){
// set the seed
srand( time(NULL) );
//create a new instance of class
AsianOption myAsian(252, 96, 95, 0.2, 0.0, 1);
// Iterate over all the elements.
// myAsian.printPath();
//get arithmetic means
cout << "Arithmetic mean price = " << myAsian.getArithmeticMean() <<"\n";
cout << "Geometric mean price = " << myAsian.getGeometricMean() <<"\n";
//get last price of underlying
cout << "Last price of underlying = " << myAsian.thisPath.back() << "\n";
//run Monte Carlo to obtain theoretical price of arithmetic asian call
cout << "Price of arithmetic Asian Call = " << myAsian.arithmeticAsianCall(10000) << "\n";
cout << "Price of arithmetic Asian Put = " << myAsian.arithmeticAsianPut(10000) << "\n";
cout << "Price of geometric Asian Call = " << myAsian.geometricAsianCall(10000) << "\n";
cout << "Price of geometric Asian Put = " << myAsian.geometricAsianPut(10000) << "\n";
//call Monte Carlo via overloaded () operator
cout << "calling functions via operator() \n";
cout << "Price of arithmetic Asian Call = " << myAsian('A', 'C', 10000) << "\n";
cout << "Price of arithmetic Asian Put = " << myAsian('A', 'P', 10000) << "\n";
cout << "Price of geometric Asian Call = " << myAsian('G', 'C', 10000) << "\n";
cout << "Price of geometric Asian Put = " << myAsian('G', 'P', 10000) << "\n";
//check whether data generating process runs correctly
//(is the expected price and volatility of underlying close to option parameters?)
vector<double> myVec2;
for(int i = 0; i < 1000; i++){
myAsian.generatePath();
myVec2.push_back(myAsian.thisPath.back());
}
cout << "mean of myVec is " << mean(myVec2) << "\n";
cout << "stddev of myVec is " << stdDev(myVec2) << "\n";
//cout << "\nPress Enter to continue...";
//cin.get();
return 0;
}