2) Result from executive file after compiling:
Option type = Put
Maturity = May 17th, 1999
Underlying price = 36
Strike = 40
Risk-free interest rate = 6.000000 %
Dividend yield = 0.000000 %
Volatility = 20.000000 %
Method European Bermudan American
Black-Scholes 3.844308 N/A N/A
Barone-Adesi/Whaley N/A N/A 4.459628
Bjerksund/Stensland N/A N/A 4.453064
Integral 3.844309 N/A N/A
Finite differences 3.844342 4.360807 4.486118
Binomial Jarrow-Rudd 3.844132 4.361174 4.486552
Binomial Cox-Ross-Rubinstein 3.843504 4.360861 4.486415
Additive equiprobabilities 3.836911 4.354455 4.480097
Binomial Trigeorgis 3.843557 4.360909 4.486461
Binomial Tian 3.844171 4.361176 4.486413
Binomial Leisen-Reimer 3.844308 4.360713 4.486076
Binomial Joshi 3.844308 4.360713 4.486076
MC (crude) 3.834522 N/A N/A
MC (Sobol) 3.844613 N/A N/A
MC (Longstaff Schwartz) N/A N/A 4.481675
Run completed in 5 s
3) With the above result, let us begin to analyze how this program works step by step:
Step 1: Include the QuantLib header and Boost timer
#define BOOST_LIB_DIAGNOSTIC # include#undef BOOST_LIB_DIAGNOSTIC
#includeOption::Type type(Option::Put);
Step 2: Define option parameters: The important thing here
is that we need to the time as Date class. And also We need
to determine the date counter type(DayCounter class).
Date todaysDate(15, May, 1998);
Date settlementDate(17, May, 1998);
Settings::instance().evaluationDate() = todaysDate;
Date maturity(17, May, 1999);
DayCounter dayCounter = Actual365Fixed();
Step 3: Determine the exercise Dates for different type of options/
And also we need to set the parameters to the engine of the Quantlib.
The trick here is to use the Handle class to make the observable being shared.
template
class QuantLib::Handle<> And is inherited from observable.
So the definition for dividend is like:class QuantLib::Handle<> And
HandleflatDividendTS(
boost::shared_ptr(
new FlatForward(settlementDate, dividendYield, dayCounter)));
Step 4: define option type , eg:
VanillaOption americanOption(stochasticProcess, payoff,
americanExercise);
Step 5: Use different method to calculate the option. The only trick here is to
use the setPricingEngine to do this job with the selected. eg:
americanOption.setPricingEngine(boost::shared_ptr(
new BaroneAdesiWhaleyApproximationEngine));
No comments:
Post a Comment