44 ext::shared_ptr<LocalVolTermStructure> leverageFct,
45 const Real mixingFactor)
49 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
50 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)), mixingFactor_(mixingFactor) {}
59 ext::shared_ptr<LocalVolTermStructure> leverageFct,
60 const Real mixingFactor)
64 dividends_(
std::move(dividends)),
65 tGrid_(tGrid), xGrid_(xGrid), vGrid_(vGrid), dampingSteps_(dampingSteps),
66 schemeDesc_(schemeDesc), leverageFct_(
std::move(leverageFct)), mixingFactor_(mixingFactor) {}
71 const ext::shared_ptr<HestonProcess>& process =
model_->process();
72 const Time maturity = process->time(
arguments_.exercise->lastDate());
75 const Size tGridMin = 5;
76 const Size tGridAvgSteps = std::max(tGridMin,
tGrid_/50);
78 const ext::shared_ptr<FdmHestonLocalVolatilityVarianceMesher> vMesher
79 = ext::make_shared<FdmHestonLocalVolatilityVarianceMesher>(
83 const ext::shared_ptr<StrikedTypePayoff>
payoff =
84 ext::dynamic_pointer_cast<StrikedTypePayoff>(
arguments_.payoff);
97 const ext::shared_ptr<Fdm1dMesher> equityMesher(
101 process->s0(), process->dividendYield(),
102 process->riskFreeRate(), vMesher->volaEstimate()),
103 maturity,
payoff->strike(),
104 xMin, xMax, 0.0001, 1.5,
108 const ext::shared_ptr<FdmMesher> mesher (
109 ext::make_shared<FdmMesherComposite>(equityMesher, vMesher));
112 ext::shared_ptr<FdmInnerValueCalculator> calculator(
113 ext::make_shared<FdmLogInnerValue>(
payoff, mesher, 0));
116 std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
117 std::list<std::vector<Time> > stoppingTimes;
120 ext::shared_ptr<FdmDividendHandler> dividendCondition(
121 ext::make_shared<FdmDividendHandler>(
dividends_, mesher,
122 process->riskFreeRate()->referenceDate(),
123 process->riskFreeRate()->dayCounter(), 0));
126 stepConditions.push_back(dividendCondition);
127 std::vector<Time> dividendTimes = dividendCondition->dividendTimes();
129 for (
auto&
t: dividendTimes)
130 t = std::min(maturity,
t);
131 stoppingTimes.push_back(dividendTimes);
135 "only european style option are supported");
137 ext::shared_ptr<FdmStepConditionComposite> conditions(
138 ext::make_shared<FdmStepConditionComposite>(stoppingTimes, stepConditions));
144 boundaries.push_back(
145 ext::make_shared<FdmDirichletBoundary>(mesher,
arguments_.rebate, 0,
151 boundaries.push_back(
152 ext::make_shared<FdmDirichletBoundary>(mesher,
arguments_.rebate, 0,
158 calculator, maturity,
161 ext::shared_ptr<FdmHestonSolver> solver(ext::make_shared<FdmHestonSolver>(
165 const Real spot = process->s0()->value();
166 results_.value = solver->valueAt(spot, process->v0());
167 results_.delta = solver->deltaAt(spot, process->v0());
168 results_.gamma = solver->gammaAt(spot, process->v0());
169 results_.theta = solver->thetaAt(spot, process->v0());
175 ext::shared_ptr<StrikedTypePayoff>
payoff =
176 ext::dynamic_pointer_cast<StrikedTypePayoff>(
190 const Size xGridMin = 20;
191 const Size vGridMin = 10;
192 const Size rebateDampingSteps
197 std::max(xGridMin,
xGrid_/4),
198 std::max(vGridMin,
vGrid_/4),
Barrier option on a single asset.
FdmSchemeDesc schemeDesc_
void calculate() const override
FdHestonBarrierEngine(const ext::shared_ptr< HestonModel > &model, Size tGrid=100, Size xGrid=100, Size vGrid=50, Size dampingSteps=0, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer(), ext::shared_ptr< LocalVolTermStructure > leverageFct={}, Real mixingFactor=1.0)
DividendSchedule dividends_
ext::shared_ptr< LocalVolTermStructure > leverageFct_
static ext::shared_ptr< GeneralizedBlackScholesProcess > processHelper(const Handle< Quote > &s0, const Handle< YieldTermStructure > &rTS, const Handle< YieldTermStructure > &qTS, Volatility vol)
Base class for some pricing engine on a particular model.
Handle< HestonModel > model_
Shared handle to an observable.
Heston model for the stochastic volatility of an asset.
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.
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
Finite-differences Heston barrier-option engine.
Finite-differences Heston barrier-option rebate helper engine.
Finite-differences Heston 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
One-dimensional grid mesher for the variance part of the Heston model.
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
Vanilla option on a single asset.