29 ext::shared_ptr<GeneralizedBlackScholesProcess> process1,
30 ext::shared_ptr<GeneralizedBlackScholesProcess> process2,
32 : process1_(
std::move(process1)), process2_(
std::move(process2)), rho_(correlation) {
40 "not an European Option");
42 ext::shared_ptr<EuropeanExercise> exercise =
43 ext::dynamic_pointer_cast<EuropeanExercise>(
arguments_.exercise);
44 QL_REQUIRE(exercise,
"not an European Option");
46 ext::shared_ptr<NullPayoff>
payoff =
47 ext::dynamic_pointer_cast<NullPayoff>(
arguments_.payoff);
57 exercise->lastDate(), s1);
59 exercise->lastDate(), s2);
62 process1_->riskFreeRate()->discount(exercise->lastDate());
65 process1_->dividendYield()->discount(exercise->lastDate());
67 process2_->dividendYield()->discount(exercise->lastDate());
70 dividendDiscount1 / riskFreeDiscount;
72 dividendDiscount2 / riskFreeDiscount;
74 Real stdDev1 = std::sqrt(variance1);
75 Real stdDev2 = std::sqrt(variance2);
78 Real d1 = (std::log((quantity1*forward1)/(quantity2*forward2))
80 Real d2 = d1 - stdDev;
81 Real Nd1, Nd2, nd1, nd2;
91 Real sqt = std::sqrt(
t);
92 Real q1 = -std::log(dividendDiscount1)/(sqt*sqt);
93 Real q2 = -std::log(dividendDiscount2)/(sqt*sqt);
96 riskFreeDiscount * (quantity1*forward1*Nd1 - quantity2*forward2*Nd2);
101 results_.
gamma1 = (riskFreeDiscount*(quantity1*forward1*nd1)/s1)/(quantity1*s1*stdDev);
102 results_.
gamma2 = (-riskFreeDiscount*(quantity2*forward2*nd2)/s2)/(-quantity2*s2*stdDev);
103 Real vega = riskFreeDiscount*(quantity1*forward1*nd1)*sqt;
ext::shared_ptr< GeneralizedBlackScholesProcess > process2_
ext::shared_ptr< GeneralizedBlackScholesProcess > process1_
void calculate() const override
AnalyticEuropeanMargrabeEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process1, ext::shared_ptr< GeneralizedBlackScholesProcess > process2, Real correlation)
Cumulative normal distribution function.
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
MargrabeOption::results results_
MargrabeOption::arguments arguments_
Normal distribution function.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
LinearInterpolation variance
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
QL_INTEGER Integer
integer number
ext::shared_ptr< QuantLib::Payoff > payoff
normal, cumulative and inverse cumulative distributions
Payoffs for various options.
Analytic engine for European Margrabe option.