37 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
42 : process_(
std::move(process)), tGrid_(tGrid), xGrid_(xGrid), aGrid_(aGrid),
43 schemeDesc_(schemeDesc) {}
49 "European exercise supported only");
51 "Arithmetic averaging supported only");
54 "Running average requires at least one past fixing");
57 const ext::shared_ptr<StrikedTypePayoff>
payoff =
58 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
60 const ext::shared_ptr<Fdm1dMesher> equityMesher(
65 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
72 =
process_->blackVolatility()->blackVol(maturity,
payoff->strike())
74 const Real r = sigmaSqrtT*normInvEps;
76 Real xMin = std::min(std::log(avg) - 0.25*
r, std::log(spot) - 1.5*
r);
77 Real xMax = std::max(std::log(avg) + 0.25*
r, std::log(spot) + 1.5*
r);
79 const ext::shared_ptr<Fdm1dMesher> averageMesher(
81 payoff->strike(), xMin, xMax));
83 const ext::shared_ptr<FdmMesher> mesher (
87 ext::shared_ptr<FdmInnerValueCalculator> calculator(
91 std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
92 std::list<std::vector<Time> > stoppingTimes;
95 std::vector<Time> averageTimes;
98 QL_REQUIRE(
t >= 0,
"Fixing dates must not contain past date");
99 averageTimes.push_back(
t);
101 stoppingTimes.emplace_back(averageTimes);
107 ext::shared_ptr<FdmStepConditionComposite> conditions(
115 calculator, maturity,
tGrid_, 0 };
116 ext::shared_ptr<FdmSimple2dBSSolver> solver(
122 results_.delta = solver->deltaAt(spot, avg, spot*0.01);
123 results_.gamma = solver->gammaAt(spot, avg, spot*0.01);
Average::Type averageType
std::vector< Date > fixingDates
void calculate() const override
FdBlackScholesAsianEngine(ext::shared_ptr< GeneralizedBlackScholesProcess >, Size tGrid=100, Size xGrid=100, Size aGrid=50, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas())
const ext::shared_ptr< GeneralizedBlackScholesProcess > process_
const FdmSchemeDesc schemeDesc_
DiscreteAveragingAsianOption::results results_
DiscreteAveragingAsianOption::arguments arguments_
Shared handle to an observable.
Inverse cumulative normal distribution function.
condition to be applied at every time step
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
Finite-Differences Black Scholes arithmentic asian option engine.
step condition to handle arithmetic average
1-d mesher for the Black-Scholes process (in ln(S))
layer of abstraction to calculate the inner value
memory layout of a fdm linear operator
FdmMesher which is a composite of Fdm1dMesher.
composite of fdm step conditions
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
ext::shared_ptr< QuantLib::Payoff > payoff
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
normal, cumulative and inverse cumulative distributions
ext::shared_ptr< YieldTermStructure > r