21#include <ql/exercise.hpp>
22#include <ql/pricingengines/blackcalculator.hpp>
23#include <ql/pricingengines/vanilla/analyticeuropeanengine.hpp>
29 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
30 : process_(
std::move(process)) {
35 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
37 : process_(
std::move(process)), discountCurve_(
std::move(discountCurve)) {
46 ext::shared_ptr<YieldTermStructure> discountPtr =
48 process_->riskFreeRate().currentLink() :
52 "not an European option");
54 ext::shared_ptr<StrikedTypePayoff> payoff =
55 ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
56 QL_REQUIRE(payoff,
"non-striked payoff given");
59 process_->blackVolatility()->blackVariance(
60 arguments_.exercise->lastDate(),
64 arguments_.exercise->lastDate());
65 DiscountFactor df = discountPtr->discount(arguments_.exercise->lastDate());
67 process_->riskFreeRate()->discount(arguments_.exercise->lastDate());
69 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
70 Real forwardPrice = spot * dividendDiscount / riskFreeDiscountForFwdEstimation;
75 results_.value = black.
value();
76 results_.delta = black.
delta(spot);
79 results_.gamma = black.
gamma(spot);
85 arguments_.exercise->lastDate());
86 results_.rho = black.
rho(t);
89 arguments_.exercise->lastDate());
93 arguments_.exercise->lastDate());
94 results_.vega = black.
vega(t);
96 results_.theta = black.
theta(spot, t);
97 results_.thetaPerDay =
107 Real tte =
process_->blackVolatility()->timeFromReference(arguments_.exercise->lastDate());
108 results_.additionalResults[
"spot"] = spot;
109 results_.additionalResults[
"dividendDiscount"] = dividendDiscount;
110 results_.additionalResults[
"riskFreeDiscount"] = riskFreeDiscountForFwdEstimation;
111 results_.additionalResults[
"forward"] = forwardPrice;
112 results_.additionalResults[
"strike"] = payoff->strike();
113 results_.additionalResults[
"volatility"] =
Real(std::sqrt(variance / tte));
114 results_.additionalResults[
"timeToExpiry"] = tte;
Handle< YieldTermStructure > discountCurve_
void calculate() const override
AnalyticEuropeanEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >)
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Black 1976 calculator class.
Real dividendRho(Time maturity) const
virtual Real delta(Real spot) const
Real vega(Time maturity) const
Real itmCashProbability() const
Real strikeSensitivity() const
virtual Real gamma(Real spot) const
virtual Real elasticity(Real spot) const
virtual Real thetaPerDay(Real spot, Time maturity) const
Real deltaForward() const
virtual Real theta(Real spot, Time maturity) const
Real rho(Time maturity) const
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.
Shared handle to an observable.
template class providing a null value for a given type.
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates