54 fGrid_(fGrid), xGrid_(xGrid), dampingSteps_(dampingSteps), scalingFactor_(scalingFactor),
55 eps_(eps), schemeDesc_(schemeDesc) {
60 <<
beta <<
" not allowed");
67 const ext::shared_ptr<StrikedTypePayoff>
payoff =
68 ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
73 const Date referenceDate =
rTS_->referenceDate();
74 const Date maturityDate = arguments_.exercise->lastDate();
80 const ext::shared_ptr<Fdm1dMesher> cevMesher =
81 ext::make_shared<FdmCEV1dMesher>(
84 std::make_pair(
payoff->strike(), 0.025));
87 const Real logDrift = -0.5*
nu_*
nu_*maturityTime;
91 const Real xMin = std::log(
alpha_) + logDrift - volRange;
92 const Real xMax = std::log(
alpha_) + logDrift + volRange;
94 const ext::shared_ptr<Fdm1dMesher> xMesher =
95 ext::make_shared<Concentrating1dMesher>(
96 xMin, xMax,
xGrid_, std::make_pair(std::log(
alpha_), 0.1));
98 const ext::shared_ptr<FdmMesher> mesher =
99 ext::make_shared<FdmMesherComposite>(cevMesher, xMesher);
102 const ext::shared_ptr<FdmInnerValueCalculator> calculator =
103 ext::make_shared<FdmCellAveragingInnerValue>(
payoff, mesher, 0);
106 const ext::shared_ptr<FdmStepConditionComposite> conditions =
109 mesher, calculator, referenceDate, dc);
114 const Real lowerBound = cevMesher->locations().front();
115 const Real upperBound = cevMesher->locations().back();
117 boundaries.push_back(
118 ext::make_shared<FdmDiscountDirichletBoundary>(
119 mesher,
rTS_.currentLink(),
120 maturityTime, (*
payoff)(upperBound),
123 boundaries.push_back(
124 ext::make_shared<FdmDiscountDirichletBoundary>(
125 mesher,
rTS_.currentLink(),
126 maturityTime, (*
payoff)(lowerBound),
131 mesher, boundaries, conditions,
135 const ext::shared_ptr<FdmLinearOpComposite> op =
136 ext::make_shared<FdmSabrOp>(
137 mesher,
rTS_.currentLink(),
140 const ext::shared_ptr<Fdm2DimSolver> solver =
141 ext::make_shared<Fdm2DimSolver>(solverDesc,
schemeDesc_, op);
const Instrument::results * results_
risk neutral density calculator for the constant elasticity of variance (CEV) model
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.
void calculate() const override
FdSabrVanillaEngine(Real f0, Real alpha, Real beta, Real nu, Real rho, Handle< YieldTermStructure > rTS, Size tGrid=50, Size fGrid=400, Size xGrid=50, Size dampingSteps=0, Real scalingFactor=1.0, Real eps=1e-4, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer())
const Handle< YieldTermStructure > rTS_
const Real scalingFactor_
const FdmSchemeDesc schemeDesc_
static ext::shared_ptr< FdmStepConditionComposite > vanillaComposite(const DividendSchedule &schedule, const ext::shared_ptr< Exercise > &exercise, const ext::shared_ptr< FdmMesher > &mesher, const ext::shared_ptr< FdmInnerValueCalculator > &calculator, const Date &refDate, const DayCounter &dayCounter)
Shared handle to an observable.
Inverse cumulative normal distribution function.
One-dimensional grid mesher concentrating around critical points.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Option exercise classes and payoff function.
One-dimensional mesher for the CEV model.
const ext::shared_ptr< YieldTermStructure > rTS_
discounted value on Dirichlet boundary conditions
layer of abstraction to calculate the inner value
FdmMesher which is a composite of Fdm1dMesher.
FDM operator for the SABR model.
composite of fdm step conditions
Finite-Differences pricing engine for the SABR model.
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
void validateSabrParameters(Real alpha, Real beta, Real nu, Real rho)
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
normal, cumulative and inverse cumulative distributions
Interest-rate term structure.