38#include <ql/pricingengines/blackcalculator.hpp>
39#include <ql/exercise.hpp>
42using QuantLib::DiscountFactor;
43using QuantLib::GeneralizedBlackScholesProcess;
44using QuantLib::Handle;
46using QuantLib::PricingEngine;
48using QuantLib::Settings;
49using QuantLib::StrikedTypePayoff;
51using QuantLib::VanillaOption;
52using QuantLib::YieldTermStructure;
53using QuantLib::Handle;
54using QuantLib::Exercise;
55using QuantLib::DayCounter;
61 const QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process)
67 const QuantLib::ext::shared_ptr<QuantLib::GeneralizedBlackScholesProcess>& process,
68 const QuantLib::Handle<QuantLib::YieldTermStructure>& discountCurve)
69 : process_(process), discountCurve_(discountCurve) {
78 QuantLib::ext::shared_ptr<YieldTermStructure> discountPtr =
80 process_->riskFreeRate().currentLink() :
83 QL_REQUIRE(
arguments_.exercise->type() == Exercise::European,
84 "not an European option");
86 QuantLib::ext::shared_ptr<StrikedTypePayoff> payoff =
87 QuantLib::ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
88 QL_REQUIRE(payoff,
"non-striked payoff given");
91 process_->blackVolatility()->blackVariance(
94 DiscountFactor dividendDiscount =
99 df = discountPtr->discount(
arguments_.paymentDate);
101 df = discountPtr->discount(
arguments_.exercise->lastDate());
102 DiscountFactor riskFreeDiscountForFwdEstimation =
104 Real spot =
process_->stateVariable()->value();
105 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
106 Real forwardPrice = spot * dividendDiscount / riskFreeDiscountForFwdEstimation;
108 QuantLib::BlackCalculator
black(payoff, forwardPrice, std::sqrt(
variance),df);
117 DayCounter rfdc = discountPtr->dayCounter();
118 DayCounter divdc =
process_->dividendYield()->dayCounter();
119 DayCounter voldc =
process_->blackVolatility()->dayCounter();
120 Time t = rfdc.yearFraction(
process_->riskFreeRate()->referenceDate(),
124 t = divdc.yearFraction(
process_->dividendYield()->referenceDate(),
128 t = voldc.yearFraction(
process_->blackVolatility()->referenceDate(),
134 black.thetaPerDay(spot, t);
137 results_.thetaPerDay = Null<Real>();
143 Real tte =
process_->blackVolatility()->timeFromReference(
arguments_.exercise->lastDate());
144 results_.additionalResults[
"spot"] = spot;
145 results_.additionalResults[
"dividendDiscount"] = dividendDiscount;
146 results_.additionalResults[
"riskFreeDiscount"] = riskFreeDiscountForFwdEstimation;
147 results_.additionalResults[
"forward"] = forwardPrice;
148 results_.additionalResults[
"strike"] = payoff->strike();
150 results_.additionalResults[
"timeToExpiry"] = tte;
151 results_.additionalResults[
"discountFactor"] = df;
Analytic European Forward engine.
const Instrument::results * results_
QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > process_
void calculate() const override
QuantLib::Handle< QuantLib::YieldTermStructure > discountCurve_
AnalyticEuropeanForwardEngine(const QuantLib::ext::shared_ptr< QuantLib::GeneralizedBlackScholesProcess > &)
RandomVariable variance(const RandomVariable &r)
RandomVariable black(const RandomVariable &omega, const RandomVariable &t, const RandomVariable &strike, const RandomVariable &forward, const RandomVariable &impliedVol)
Swap::arguments * arguments_