20#include <ql/exercise.hpp>
21#include <ql/experimental/exoticoptions/analytictwoassetbarrierengine.hpp>
22#include <ql/math/distributions/bivariatenormaldistribution.hpp>
23#include <ql/math/distributions/normaldistribution.hpp>
29 ext::shared_ptr<GeneralizedBlackScholesProcess> process1,
30 ext::shared_ptr<GeneralizedBlackScholesProcess> process2,
32 : process1_(
std::move(process1)), process2_(
std::move(process2)), rho_(
std::move(rho)) {
39 ext::shared_ptr<PlainVanillaPayoff> payoff =
41 QL_REQUIRE(payoff,
"non-plain payoff given");
42 QL_REQUIRE(payoff->strike()>0.0,
"strike must be positive");
46 QL_REQUIRE(spot2 > 0.0,
"negative or null underlying given");
47 QL_REQUIRE(!
triggered(spot2),
"barrier touched");
51 switch (payoff->optionType()) {
53 switch (barrierType) {
69 switch (barrierType) {
85 QL_FAIL(
"unknown type");
98 ext::shared_ptr<PlainVanillaPayoff> payoff =
100 QL_REQUIRE(payoff,
"non-plain payoff given");
101 return payoff->strike();
121 return rho_->value();
183 return b-(vol*vol)/2;
205 Rate mu1 = b1 - sigma1*sigma1/2.0;
206 Rate mu2 = b2 - sigma2*sigma2/2.0;
208 Real d1 = (std::log(S1/X)+(mu1+sigma1*sigma1)*T)/
209 (sigma1*std::sqrt(T));
211 Real d3 =
d1 + (2*
rho*std::log(H/S2))/(sigma2*std::sqrt(T));
212 Real d4 =
d2 + (2*
rho*std::log(H/S2))/(sigma2*std::sqrt(T));
214 Real e1 = (std::log(H/S2)-(mu2+
rho*sigma1*sigma2)*T)/
215 (sigma2*std::sqrt(T));
217 Real e3 =
e1 - (2*std::log(H/S2))/(sigma2*std::sqrt(T));
218 Real e4 =
e2 - (2*std::log(H/S2))/(sigma2*std::sqrt(T));
221 eta*S1*std::exp((b1-r)*T) *
223 -std::exp((2*(mu2+
rho*sigma1*sigma2)*std::log(H/S2))/(sigma2*sigma2))
226 - eta*X*std::exp(-r*T) *
228 -std::exp((2*mu2*std::log(H/S2))/(sigma2*sigma2))*
ext::shared_ptr< GeneralizedBlackScholesProcess > process2_
Rate dividendYield1() const
Real M(Real m_a, Real m_b, Real rho) const
Time residualTime() const
ext::shared_ptr< GeneralizedBlackScholesProcess > process1_
Volatility volatility2() const
void calculate() const override
AnalyticTwoAssetBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process1, ext::shared_ptr< GeneralizedBlackScholesProcess > process2, Handle< Quote > rho)
Real B(Real eta, Real phi) const
Volatility volatility1() const
Rate costOfCarry2() const
Real mu(Real b, Real vol) const
Rate costOfCarry1() const
Rate riskFreeRate() const
Rate dividendYield2() const
Real A(Real eta, Real phi) const
Cumulative bivariate normal distribution function.
Cumulative normal distribution function.
TwoAssetBarrierOption::results results_
TwoAssetBarrierOption::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
Barrier::Type barrierType
bool triggered(Real underlying) const
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility