20#include <ql/exercise.hpp>
21#include <ql/experimental/exoticoptions/continuousarithmeticasianlevyengine.hpp>
22#include <ql/math/distributions/normaldistribution.hpp>
23#include <ql/pricingengines/blackcalculator.hpp>
31 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
34 : process_(
std::move(process)), currentAverage_(
std::move(currentAverage)),
35 startDate_(startDate) {
42 "not an Arithmetic average option");
44 "not an European Option");
45 QL_REQUIRE(startDate_ <= process_->riskFreeRate()->referenceDate(),
46 "startDate must be earlier than or equal to reference date");
54 ext::shared_ptr<StrikedTypePayoff> payoff =
55 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
56 QL_REQUIRE(payoff,
"non-plain payoff given");
66 Real strike = payoff->strike();
69 process_->blackVolatility()->blackVol(maturity, strike);
77 Real b = riskFreeRate - dividendYield;
80 ?
Real((spot/(T*b))*(exp((b-riskFreeRate)*T2)-exp(-riskFreeRate*T2)))
81 :
Real(spot*T2/T * std::exp(-riskFreeRate*T2));
86 "current average required");
92 Real m = (std::fabs(b) > 1000*
QL_EPSILON) ? ((exp(b*T2)-1)/b) : T2;
94 Real M = (2*spot*spot/(b+volatility*volatility)) *
95 (((exp((2*b+volatility*volatility)*T2)-1)
96 / (2*b+volatility*volatility))-m);
100 Real V = log(D)-2*(riskFreeRate*T2+log(Se));
102 Real d1 = (1/sqrt(V))*((log(D)/2)-log(X));
103 Real d2 = d1-sqrt(V);
109 - Se + X*exp(-riskFreeRate*T2);
void calculate() const override
Handle< Quote > currentAverage_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
ContinuousArithmeticAsianLevyEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, Handle< Quote > currentAverage, Date startDate)
Average::Type averageType
Cumulative normal distribution function.
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.
ContinuousAveragingAsianOption::results results_
ContinuousAveragingAsianOption::arguments arguments_
Shared handle to an observable.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
Real Volatility
volatility