30 ext::shared_ptr<BlackProcess> process2,
32 : process1_(
std::move(process1)), process2_(
std::move(process2)), rho_(correlation) {
40 "not a European option");
42 ext::shared_ptr<EuropeanExercise> exercise =
44 QL_REQUIRE(exercise,
"not a European exercise");
46 ext::shared_ptr<SpreadBasketPayoff> spreadPayoff =
48 QL_REQUIRE(spreadPayoff,
" spread payoff expected");
50 ext::shared_ptr<PlainVanillaPayoff>
payoff =
51 ext::dynamic_pointer_cast<PlainVanillaPayoff>(
52 spreadPayoff->basePayoff());
60 const Real variance1 =
process1_->blackVolatility()->blackVariance(
61 exercise->lastDate(), f1);
62 const Real variance2 =
process2_->blackVolatility()->blackVariance(
63 exercise->lastDate(), f2);
66 process1_->riskFreeRate()->discount(exercise->lastDate());
68 const Real f = f1/(f2 + strike);
71 + variance2*
squared(f2/(f2+strike))
72 - 2*
rho_*std::sqrt(variance1*variance2)
76 ext::make_shared<PlainVanillaPayoff>(
78 f,
v, riskFreeDiscount);
Black-formula calculator class.
Black 1976 calculator class.
BasketOption::results results_
BasketOption::arguments arguments_
void calculate() const override
ext::shared_ptr< BlackProcess > process1_
ext::shared_ptr< BlackProcess > process2_
KirkEngine(ext::shared_ptr< BlackProcess > process1, ext::shared_ptr< BlackProcess > process2, Real correlation)
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
ext::shared_ptr< Exercise > exercise
ext::shared_ptr< Payoff > payoff
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
Real DiscountFactor
discount factor between dates
ext::shared_ptr< QuantLib::Payoff > payoff
kirk formulae, due to Kirk (1995)
functionals and combinators not included in the STL
ext::shared_ptr< BlackVolTermStructure > v