49 class FdmSparkSpreadInnerValue :
public FdmInnerValueCalculator {
52 FdmSparkSpreadInnerValue(ext::shared_ptr<BasketPayoff> basketPayoff,
53 ext::shared_ptr<FdmInnerValueCalculator> fuelPrice,
54 ext::shared_ptr<FdmInnerValueCalculator> powerPrice)
58 Real innerValue(
const FdmLinearOpIterator& iter,
Time t)
override {
63 return (*basketPayoff_)(
s);
65 Real avgInnerValue(
const FdmLinearOpIterator& iter,
Time t)
override {
66 return innerValue(iter,
t);
71 const ext::shared_ptr<FdmInnerValueCalculator>
fuelPrice_;
78 ext::shared_ptr<KlugeExtOUProcess> process,
79 ext::shared_ptr<YieldTermStructure> rTS,
80 ext::shared_ptr<Shape> fuelShape,
81 ext::shared_ptr<Shape> powerShape,
88 : process_(
std::move(process)),
rTS_(
std::move(rTS)), fuelCostAddon_(fuelCostAddon),
89 fuelShape_(
std::move(fuelShape)), powerShape_(
std::move(powerShape)), tGrid_(tGrid),
90 xGrid_(xGrid), yGrid_(yGrid), gGrid_(gGrid), schemeDesc_(schemeDesc) {}
94 ext::shared_ptr<SwingExercise> swingExercise(
97 QL_REQUIRE(swingExercise,
"Swing exercise supported only");
102 const std::vector<Time> exerciseTimes
103 = swingExercise->exerciseTimes(
rTS_->dayCounter(),
104 rTS_->referenceDate());
107 const Time maturity = exerciseTimes.back();
108 const ext::shared_ptr<ExtOUWithJumpsProcess> klugeProcess
111 const ext::shared_ptr<StochasticProcess1D> klugeOUProcess
112 = klugeProcess->getExtendedOrnsteinUhlenbeckProcess();
114 const ext::shared_ptr<Fdm1dMesher> xMesher(
117 const ext::shared_ptr<Fdm1dMesher> yMesher(
119 klugeProcess->beta(),
120 klugeProcess->jumpIntensity(),
121 klugeProcess->eta(), 1e-3));
123 const ext::shared_ptr<Fdm1dMesher> gMesher(
125 process_->getExtOUProcess(),maturity));
127 const ext::shared_ptr<Fdm1dMesher> exerciseMesher(
130 const ext::shared_ptr<FdmMesher> mesher (
134 const ext::shared_ptr<FdmInnerValueCalculator> zeroInnerValue(
137 const ext::shared_ptr<Payoff> zeroStrikeCall(
140 const ext::shared_ptr<FdmInnerValueCalculator> fuelPrice(
144 const ext::shared_ptr<FdmInnerValueCalculator> powerPrice(
147 const ext::shared_ptr<FdmInnerValueCalculator> sparkSpread(
148 new FdmSparkSpreadInnerValue(
150 fuelPrice, powerPrice));
153 std::list<std::vector<Time> > stoppingTimes;
154 std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
157 stoppingTimes.push_back(exerciseTimes);
160 const ext::shared_ptr<FdmVPPStepCondition> stepCondition(
162 fuelPrice, sparkSpread));
164 stepConditions.push_back(stepCondition);
166 const ext::shared_ptr<FdmStepConditionComposite> conditions(
174 zeroInnerValue, maturity,
tGrid_, 0 };
176 const ext::shared_ptr<FdmKlugeExtOUSolver<4> > solver(
180 std::vector<Real> x(4);
181 x[0] =
process_->initialValues()[0];
182 x[1] =
process_->initialValues()[1];
183 x[2] =
process_->initialValues()[2];
185 const Real tol = 1e-8;
186 const Real maxExerciseValue = exerciseMesher->locations().back();
187 const Real minExerciseValue = exerciseMesher->locations().front();
192 x[3] = std::max(minExerciseValue + tol,
193 std::min(exerciseMesher->location(i),
194 maxExerciseValue - tol));
195 results[i] = solver->valueAt(x);
Basket option on a number of assets.
1-D array used in linear algebra.
void calculate() const override
const ext::shared_ptr< KlugeExtOUProcess > process_
FdSimpleKlugeExtOUVPPEngine(ext::shared_ptr< KlugeExtOUProcess > process, ext::shared_ptr< YieldTermStructure > rTS, ext::shared_ptr< Shape > fuelShape, ext::shared_ptr< Shape > powerShape, Real fuelCostAddon, Size tGrid=1, Size xGrid=50, Size yGrid=10, Size gGrid=20, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Hundsdorfer())
const ext::shared_ptr< Shape > powerShape_
const Real fuelCostAddon_
const ext::shared_ptr< YieldTermStructure > rTS_
const ext::shared_ptr< Shape > fuelShape_
const FdmSchemeDesc schemeDesc_
ext::shared_ptr< Fdm1dMesher > stateMesher() const
ext::shared_ptr< FdmVPPStepCondition > build(const FdmVPPStepConditionMesher &mesh, Real fuelCostAddon, const ext::shared_ptr< FdmInnerValueCalculator > &fuel, const ext::shared_ptr< FdmInnerValueCalculator > &spark) const
VanillaVPPOption::results results_
VanillaVPPOption::arguments arguments_
Shared handle to an observable.
ext::shared_ptr< Exercise > exercise
ext::shared_ptr< Payoff > payoff
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
mesher for a exponential jump mesher with high mean reversion rate and low jump intensity
extended Ornstein-Uhlenbeck process
Ornstein Uhlenbeck process plus exp jumps (Kluge Model)
One-dimensional simple FDM mesher object working on an index.
const ext::shared_ptr< YieldTermStructure > rTS_
inner value calculator for an exponential extended Ornstein Uhlenbeck grid
Kluge/extended Ornstein-Uhlenbeck FDM solver.
memory layout of a fdm linear operator
FdmMesher which is a composite of Fdm1dMesher.
One-dimensional grid mesher.
composite of fdm step conditions
factory for VPP step conditions for FD models
const ext::shared_ptr< FdmInnerValueCalculator > fuelPrice_
const ext::shared_ptr< BasketPayoff > basketPayoff_
const ext::shared_ptr< FdmInnerValueCalculator > powerPrice_
Finite Differences engine for simple vpp options.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
joint Kluge process an d Ornstein Uhlenbeck process
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet
vanilla swing option class
Interest-rate term structure.