41 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
47 Real illegalLocalVolOverwrite)
48 : process_(
std::move(process)),
49 tGrid_(tGrid), xGrid_(xGrid), dampingSteps_(dampingSteps),
50 schemeDesc_(schemeDesc), localVol_(localVol),
51 illegalLocalVolOverwrite_(illegalLocalVolOverwrite) {
57 ext::shared_ptr<GeneralizedBlackScholesProcess> process,
64 Real illegalLocalVolOverwrite)
65 : process_(
std::move(process)), dividends_(
std::move(dividends)),
66 tGrid_(tGrid), xGrid_(xGrid), dampingSteps_(dampingSteps),
67 schemeDesc_(schemeDesc), localVol_(localVol),
68 illegalLocalVolOverwrite_(illegalLocalVolOverwrite) {
76 const ext::shared_ptr<StrikedTypePayoff>
payoff =
77 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
83 "only european style option are supported");
86 QL_REQUIRE(spot > 0.0,
"negative or null underlying given");
102 const ext::shared_ptr<Fdm1dMesher> equityMesher(
105 xMin, xMax, 0.0001, 1.5,
109 const ext::shared_ptr<FdmMesher> mesher (
110 ext::make_shared<FdmMesherComposite>(equityMesher));
113 ext::shared_ptr<FdmInnerValueCalculator> calculator(
114 ext::make_shared<FdmLogInnerValue>(
payoff, mesher, 0));
117 std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
118 std::list<std::vector<Time> > stoppingTimes;
121 ext::shared_ptr<FdmDividendHandler> dividendCondition(
122 ext::make_shared<FdmDividendHandler>(
dividends_, mesher,
123 process_->riskFreeRate()->referenceDate(),
124 process_->riskFreeRate()->dayCounter(), 0));
127 stepConditions.push_back(dividendCondition);
128 std::vector<Time> dividendTimes = dividendCondition->dividendTimes();
130 for (
auto&
t: dividendTimes)
131 t = std::min(maturity,
t);
132 stoppingTimes.push_back(dividendTimes);
135 ext::shared_ptr<FdmStepConditionComposite> conditions(
136 ext::make_shared<FdmStepConditionComposite>(stoppingTimes, stepConditions));
142 boundaries.push_back(
150 boundaries.push_back(
156 FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator,
159 ext::shared_ptr<FdmBlackScholesSolver> solver(
160 ext::make_shared<FdmBlackScholesSolver>(
166 results_.delta = solver->deltaAt(spot);
167 results_.gamma = solver->gammaAt(spot);
168 results_.theta = solver->thetaAt(spot);
174 ext::shared_ptr<StrikedTypePayoff>
payoff =
175 ext::dynamic_pointer_cast<StrikedTypePayoff>(
182 ext::make_shared<FdBlackScholesVanillaEngine>(
193 const Size min_grid_size = 50;
194 const Size rebateDampingSteps
Barrier::Type barrierType
bool triggered(Real underlying) const
Barrier option on a single asset.
Real illegalLocalVolOverwrite_
FdmSchemeDesc schemeDesc_
void calculate() const override
DividendSchedule dividends_
ext::shared_ptr< GeneralizedBlackScholesProcess > process_
FdBlackScholesBarrierEngine(ext::shared_ptr< GeneralizedBlackScholesProcess > process, Size tGrid=100, Size xGrid=100, Size dampingSteps=0, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas(), bool localVol=false, Real illegalLocalVolOverwrite=-Null< Real >())
BarrierOption::results results_
BarrierOption::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.
template class providing a null value for a given type.
std::pair< iterator, bool > registerWith(const ext::shared_ptr< Observable > &)
Vanilla option (no discrete dividends, no barriers) on a single asset.
#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 barrier-option engine.
Finite-differences Black/Scholes barrier option rebate helper engine.
Finite-differences Black Scholes vanilla option engine.
1-d mesher for the Black-Scholes process (in ln(S))
Dirichlet boundary conditions for differential operators.
dividend handler for fdm method for one equity direction
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
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
normal, cumulative and inverse cumulative distributions
Vanilla option on a single asset.