20#include <ql/exercise.hpp>
21#include <ql/experimental/exoticoptions/analytictwoassetcorrelationengine.hpp>
22#include <ql/math/distributions/bivariatenormaldistribution.hpp>
30 ext::shared_ptr<GeneralizedBlackScholesProcess> p1,
31 ext::shared_ptr<GeneralizedBlackScholesProcess> p2,
33 : p1_(
std::move(p1)), p2_(
std::move(p2)), correlation_(
std::move(correlation)) {
42 const ext::shared_ptr<PlainVanillaPayoff> payoff =
44 QL_REQUIRE(payoff,
"non-plain payoff given");
45 QL_REQUIRE(payoff->strike()>0.0,
"strike must be positive");
47 Real strike = payoff->strike();
49 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
52 p1_->blackVolatility()->blackVol(
p1_->time(exercise->lastDate()),
55 p2_->blackVolatility()->blackVol(
p2_->time(exercise->lastDate()),
69 Real y1=(log(s1/strike)+(b1-(sigma1*sigma1)/2)*T)/(sigma1*std::sqrt(T));
70 Real y2=(log(s2/
arguments_.
X2)+(b2-(sigma2*sigma2)/2)*T)/(sigma2*std::sqrt(T));
72 switch (payoff->optionType()) {
74 results_.
value=s2*std::exp((b2-r)*T)*M(y2+sigma2*std::sqrt(T),y1+rho*sigma2*std::sqrt(T))-
arguments_.
X2*std::exp(-r*T)*M(y2,y1);
77 results_.
value=
arguments_.
X2*std::exp(-r*T)*M(-y2,-y1)-s2*std::exp((b2-r)*T)*M(-y2-sigma2*std::sqrt(T),-y1-rho*sigma2*std::sqrt(T));
80 QL_FAIL(
"unknown option type");
Handle< Quote > correlation_
ext::shared_ptr< GeneralizedBlackScholesProcess > p1_
AnalyticTwoAssetCorrelationEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > p1, ext::shared_ptr< GeneralizedBlackScholesProcess > p2, Handle< Quote > correlation)
void calculate() const override
ext::shared_ptr< GeneralizedBlackScholesProcess > p2_
Cumulative bivariate normal distribution function.
TwoAssetCorrelationOption::results results_
TwoAssetCorrelationOption::arguments arguments_
Shared handle to an observable.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
ext::shared_ptr< Exercise > exercise
ext::shared_ptr< Payoff > payoff
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility