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 =
46 QL_REQUIRE(spot2 > 0.0,
"negative or null underlying given");
51 switch (
payoff->optionType()) {
53 switch (barrierType) {
69 switch (barrierType) {
98 ext::shared_ptr<PlainVanillaPayoff>
payoff =
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))*
Analytic engine for barrier option on two assets.
bivariate cumulative normal distribution
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
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
#define QL_FAIL(message)
throw an error (possibly with file and line information)
Option exercise classes and payoff function.
ext::function< Real(Real)> b
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
ext::shared_ptr< QuantLib::Payoff > payoff
normal, cumulative and inverse cumulative distributions
ext::shared_ptr< YieldTermStructure > r