43 class PriceAtBoundary {
45 PriceAtBoundary(
Time maturityTime,
46 ext::shared_ptr<StrikedTypePayoff>
payoff,
47 ext::shared_ptr<YieldTermStructure> rTS,
48 ext::shared_ptr<CEVCalculator> calculator)
53 const Time time2Expiry = std::max(1/365., maturityTime_ -
t);
55 rTS_->discount(maturityTime_) /
rTS_->discount(
t);
63 const ext::shared_ptr<StrikedTypePayoff>
payoff_;
65 const ext::shared_ptr<YieldTermStructure>
rTS_;
80 xGrid_(xGrid), dampingSteps_(dampingSteps), scalingFactor_(scalingFactor), eps_(eps),
81 schemeDesc_(schemeDesc) {
88 const ext::shared_ptr<StrikedTypePayoff>
payoff =
89 ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
92 const ext::shared_ptr<YieldTermStructure> rTS =
97 const Date referenceDate = rTS->referenceDate();
98 const Date maturityDate = arguments_.exercise->lastDate();
101 const ext::shared_ptr<Fdm1dMesher> cevMesher =
102 ext::make_shared<FdmCEV1dMesher>(
106 std::make_pair(
payoff->strike(), 0.1));
108 const Real lowerBound = cevMesher->locations().front();
109 const Real upperBound = cevMesher->locations().back();
111 const ext::shared_ptr<FdmMesher> mesher =
112 ext::make_shared<FdmMesherComposite>(cevMesher);
115 const ext::shared_ptr<FdmInnerValueCalculator> calculator =
116 ext::make_shared<FdmCellAveragingInnerValue>(
payoff, mesher, 0);
119 const ext::shared_ptr<FdmStepConditionComposite> conditions =
128 const PriceAtBoundary upperBoundPrice(
129 maturityTime,
payoff, rTS,
130 ext::make_shared<CEVCalculator>(upperBound,
alpha_,
beta_));
132 boundaries.push_back(ext::make_shared<FdmTimeDepDirichletBoundary>(
133 mesher, ext::function<
Real (
Real)>(upperBoundPrice),
138 const Real terminalCashFlow = (*payoff)(lowerBound);
140 boundaries.push_back(
141 ext::make_shared<FdmDiscountDirichletBoundary>(
142 mesher, rTS, maturityTime, terminalCashFlow,
148 mesher, boundaries, conditions,
152 const ext::shared_ptr<FdmLinearOpComposite> op =
153 ext::make_shared<FdmCEVOp>(
156 const ext::shared_ptr<Fdm1DimSolver> solver =
157 ext::make_shared<Fdm1DimSolver>(solverDesc,
schemeDesc_, op);
Pricing engine for European vanilla options using a constant elasticity of variance (CEV) model.
const YieldTermStructure & discountCurve_
const Instrument::results * results_
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.
const Handle< YieldTermStructure > discountCurve_
void calculate() const override
FdCEVVanillaEngine(Real f0, Real alpha, Real beta, Handle< YieldTermStructure > discountCurve, Size tGrid=50, Size xGrid=400, Size dampingSteps=0, Real scalingFactor=1.0, Real eps=1e-4, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas())
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.
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.
const ext::shared_ptr< CEVCalculator > calculator_
Finite-Differences pricing engine for the CEV model.
One-dimensional mesher for the CEV model.
FDM operator for the Constant Elasticity of Variance (CEV) model.
const ext::shared_ptr< YieldTermStructure > rTS_
discounted value on Dirichlet boundary conditions
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
time dependent Dirichlet boundary conditions
const ext::shared_ptr< Payoff > payoff_
Real Time
continuous quantity with 1-year units
Real DiscountFactor
discount factor between dates
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
Interest-rate term structure.