36 class FdmOUInnerValue :
public FdmInnerValueCalculator {
38 FdmOUInnerValue(ext::shared_ptr<Payoff>
payoff,
39 ext::shared_ptr<FdmMesher> mesher,
44 Real innerValue(
const FdmLinearOpIterator& iter,
Time)
override {
49 Real avgInnerValue(
const FdmLinearOpIterator& iter,
Time t)
override {
50 return innerValue(iter,
t);
61 ext::shared_ptr<OrnsteinUhlenbeckProcess> process,
62 const ext::shared_ptr<YieldTermStructure>& rTS,
68 : process_(
std::move(process)),
rTS_(rTS), tGrid_(tGrid), xGrid_(xGrid),
69 dampingSteps_(dampingSteps), epsilon_(epsilon), schemeDesc_(schemeDesc) {
75 ext::shared_ptr<OrnsteinUhlenbeckProcess> process,
76 const ext::shared_ptr<YieldTermStructure>& rTS,
83 : process_(
std::move(process)),
rTS_(rTS),
84 dividends_(
std::move(dividends)), tGrid_(tGrid), xGrid_(xGrid),
85 dampingSteps_(dampingSteps), epsilon_(epsilon), schemeDesc_(schemeDesc) {
93 const ext::shared_ptr<StrikedTypePayoff>
payoff =
94 ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
97 const Date referenceDate =
rTS_->referenceDate();
100 referenceDate, arguments_.exercise->lastDate());
102 const ext::shared_ptr<Fdm1dMesher> equityMesher(
106 const ext::shared_ptr<FdmMesher> mesher (
110 const ext::shared_ptr<FdmInnerValueCalculator> calculator(
111 new FdmOUInnerValue(
payoff, mesher, 0));
114 const ext::shared_ptr<FdmStepConditionComposite> conditions =
124 FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator,
127 const ext::shared_ptr<FdmOrnsteinUhlenbeckOp> op(
130 const ext::shared_ptr<Fdm1DimSolver> solver(
135 results_.value = solver->interpolateAt(spot);
136 results_.delta = solver->derivativeX(spot);
137 results_.gamma = solver->derivativeXX(spot);
138 results_.theta = solver->thetaAt(spot);
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.
FdOrnsteinUhlenbeckVanillaEngine(ext::shared_ptr< OrnsteinUhlenbeckProcess >, const ext::shared_ptr< YieldTermStructure > &rTS, Size tGrid=100, Size xGrid=100, Size dampingSteps=0, Real epsilon=0.0001, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas())
void calculate() const override
const ext::shared_ptr< YieldTermStructure > rTS_
DividendSchedule dividends_
const ext::shared_ptr< OrnsteinUhlenbeckProcess > process_
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)
Option exercise classes and payoff function.
const ext::shared_ptr< YieldTermStructure > rTS_
layer of abstraction to calculate the inner value
memory layout of a fdm linear operator
FdmMesher which is a composite of Fdm1dMesher.
Ornstein Uhlenbeck process.
One-dimensional grid mesher.
composite of fdm step conditions
const ext::shared_ptr< FdmMesher > mesher_
const ext::shared_ptr< Payoff > payoff_
Finite-Differences Ornstein Uhlenbeck vanilla option engine.
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
Ornstein-Uhlenbeck process.
Interest-rate term structure.