36 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
43 : process_(
std::move(process)), currentAverage_(
std::move(currentAverage)),
44 startDate_(startDate), z_min_(z_min), z_max_(z_max), timeSteps_(timeSteps),
45 assetSteps_(assetSteps) {
54 "not an Arithmetic average option");
56 "not an European Option");
64 ext::shared_ptr<StrikedTypePayoff>
payoff =
65 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
73 "strike (0 for vecer fixed strike asian) not on Grid");
76 process_->blackVolatility()->blackVol(maturity, X);
86 "Seasoned Asian not yet implemented");
95 if ((T2 - T1) < 0.001) {
99 ext::make_shared<AnalyticEuropeanEngine>(
process_));
117 for (
Natural i= 0; i<= SVec.size()-1;i++) {
132 for (
Natural i= 0; i<= SVec.size()-1;i++) {
133 u_initial[i] = std::max<Real>(SVec[i] , 0.0);
142 for (
Natural i = 1; i<= SVec.size()-2;i++) {
143 vecerTerm = SVec[i] - std::exp(-
q * (
T-(j-1)*k))
146 0.5 * sigma2 * vecerTerm * vecerTerm * lowerD[i-1],
147 0.5 * sigma2 * vecerTerm * vecerTerm * Dia[i],
148 0.5 * sigma2 * vecerTerm * vecerTerm * upperD[i]);
151 (1 - Theta) * k * gammaOp;
163 for (
Natural i = 1; i<= SVec.size()-2;i++) {
164 vecerTerm = SVec[i] - std::exp(-
q * (
T-j*k)) *
167 0.5 * sigma2 * vecerTerm * vecerTerm * lowerD[i-1],
168 0.5 * sigma2 * vecerTerm * vecerTerm * Dia[i],
169 0.5 * sigma2 * vecerTerm * vecerTerm * upperD[i]);
190 pv = u[lowerI] + (u[lowerI+1] - u[lowerI]) * (Z_0 - SVec[lowerI])/h;
196 expectedAverage = S_0;
199 S_0 * (std::exp( (
r-
q) * T2) -
200 std::exp( (
r-
q) * T1)) / ((
r-
q) * (T2-T1));
203 Real asianForward = std::exp(-
r * T2) * (expectedAverage - X);
215 Real const eps= 0.00001;
217 QL_REQUIRE(T1 <= T2,
"Average Start must be before Average End");
218 if (std::fabs(
t-T2) < eps) {
222 if (std::fabs(
r-
v) >= eps) {
223 return (std::exp(
v * (
t-T2)) *
224 (1 - std::exp((
v-
r) * (T2-T1) )) /
225 ((
r -
v) * (T2 - T1) ));
227 return std::exp(
v*(
t-T2));
230 if (std::fabs(
r-
v) >= eps) {
231 return std::exp(
v * (
t-T2)) *
232 (1 - std::exp( (
v -
r) * (T2-
t) )) /
233 ((
r -
v) * (T2 - T1) );
235 return std::exp(
v * (
t-T2)) * (T2 -
t) / (T2 - T1);
Analytic European engine.
Black-formula calculator class.
1-D array used in linear algebra.
Real cont_strategy(Time t, Time T1, Time T2, Real v, Real r) const
void calculate() const override
ContinuousArithmeticAsianVecerEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, Handle< Quote > currentAverage, Date startDate, Size timeSteps=100, Size assetSteps=100, Real z_min=-1.0, Real z_max=1.0)
Handle< Quote > currentAverage_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
Average::Type averageType
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.
Real NPV() const
returns the net present value of the instrument.
void setPricingEngine(const ext::shared_ptr< PricingEngine > &)
set the pricing engine to be used.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
static Settings & instance()
access to the unique instance
Base implementation for tridiagonal operator.
const Array & diagonal() const
Array solveFor(const Array &rhs) const
solve linear system for a given right-hand side
Array applyTo(const Array &v) const
apply operator to a given array
const Array & lowerDiagonal() const
void setLastRow(Real, Real)
const Array & upperDiagonal() const
void setFirstRow(Real, Real)
static TridiagonalOperator identity(Size size)
identity instance
void setMidRow(Size, Real, Real, Real)
Vanilla option (no discrete dividends, no barriers) on a single asset.
Vecer engine for continuous arithmetic Asian options.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
@ NoFrequency
null frequency
Real Time
continuous quantity with 1-year units
unsigned QL_INTEGER Natural
positive integer
Real Volatility
volatility
QL_INTEGER Integer
integer number
std::size_t Size
size of a container
ext::shared_ptr< QuantLib::Payoff > payoff
normal, cumulative and inverse cumulative distributions
ext::shared_ptr< YieldTermStructure > q
ext::shared_ptr< YieldTermStructure > r
ext::shared_ptr< BlackVolTermStructure > v
Vanilla option on a single asset.