30 ext::shared_ptr<GeneralizedBlackScholesProcess> process)
31 : process_(
std::move(process)) {
38 ext::shared_ptr<PlainVanillaPayoff> payoff1 =
40 QL_REQUIRE(payoff1,
"not a plain vanilla payoff");
42 ext::shared_ptr<PlainVanillaPayoff> payoff2 =
44 QL_REQUIRE(payoff2,
"not a plain vanilla payoff");
71 process_->riskFreeRate()->referenceDate(),
74 process_->riskFreeRate()->referenceDate(),
78 Real b = riskFree - dividend;
80 Real forwardPrice = spot * std::exp(
b*t1);
83 exercise1->lastDate(), payoff1->strike());
85 Real stdDev = volatility*std::sqrt(t1);
87 Real discount = std::exp(-riskFree*t1);
91 forwardPrice, stdDev, discount);
96 Real ro = std::sqrt(t1/t2);
97 Real z1 = (std::log(spot/payoff2->strike()) +
98 (
b+std::pow(volatility, 2)/2)*t2)/(volatility*std::sqrt(t2));
99 Real z2 = (std::log(spot/payoff1->strike()) +
100 (
b+std::pow(volatility, 2)/2)*t1)/(volatility*std::sqrt(t1));
108 Real bivariate1, bivariate2, result;
113 bivariate1 = biv(z1, -z2);
114 bivariate2 = biv(z1-volatility*std::sqrt(t2),
115 -z2+volatility*std::sqrt(t1));
116 result = black + spot*std::exp((
b-riskFree)*t2)*bivariate1
117 - payoff2->strike()*std::exp((-riskFree)*t2)*bivariate2;
120 bivariate1 = biv(-z1, z2);
121 bivariate2 = biv(-z1+volatility*std::sqrt(t2),
122 z2-volatility*std::sqrt(t1));
123 result = black - spot*std::exp((
b-riskFree)*t2)*bivariate1
124 + payoff2->strike()*std::exp((-riskFree)*t2)*bivariate2;
Analytic engine for writer-extensible options.
bivariate cumulative normal distribution
AnalyticWriterExtensibleOptionEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process)
void calculate() const override
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Cumulative bivariate normal distibution function (West 2004)
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.
WriterExtensibleOption::results results_
WriterExtensibleOption::arguments arguments_
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
ext::shared_ptr< Exercise > exercise
ext::shared_ptr< Payoff > payoff
ext::shared_ptr< Payoff > payoff2
ext::shared_ptr< Exercise > exercise2
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
ext::function< Real(Real)> b
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility
Real blackFormula(Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount, Real displacement)