Skip to content

Commit 0f1bb74

Browse files
pcaspersjenkins
authored andcommitted
QPR-11618 add ctors for fd variant of engine
1 parent 4a4bd92 commit 0f1bb74

3 files changed

Lines changed: 52 additions & 3 deletions

File tree

QuantExt/qle/models/lgmfdsolver.hpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
namespace QuantExt {
3434

3535
//! Numerical FD solver for the LGM model
36-
class LgmFdSolver : LgmBackwardSolver {
36+
class LgmFdSolver : public LgmBackwardSolver {
3737
public:
3838
LgmFdSolver(const boost::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime = 50.0,
3939
const Size stateGridPoints = 64, const Size timeStepsPerYear = 24, const Real mesherEpsilon = 1E-4);

QuantExt/qle/pricingengines/numericlgmmultilegoptionengine.cpp

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,9 @@
2323
#include <qle/cashflows/overnightindexedcoupon.hpp>
2424
#include <qle/cashflows/subperiodscoupon.hpp>
2525
#include <qle/instruments/rebatedexercise.hpp>
26+
#include <qle/models/lgmconvolutionsolver2.hpp>
27+
#include <qle/models/lgmfdsolver.hpp>
28+
#include <qle/models/lgmvectorised.hpp>
2629

2730
#include <ql/cashflows/averagebmacoupon.hpp>
2831
#include <ql/cashflows/capflooredcoupon.hpp>
@@ -371,6 +374,17 @@ NumericLgmMultiLegOptionEngine::NumericLgmMultiLegOptionEngine(const boost::shar
371374
registerWith(discountCurve_);
372375
}
373376

377+
NumericLgmMultiLegOptionEngine::NumericLgmMultiLegOptionEngine(const boost::shared_ptr<LinearGaussMarkovModel>& model,
378+
const Real maxTime, const Size stateGridPoints,
379+
const Size timeStepsPerYear, const Real mesherEpsilon,
380+
const Handle<YieldTermStructure>& discountCurve)
381+
: NumericLgmMultiLegOptionEngineBase(
382+
boost::make_shared<LgmFdSolver>(model, maxTime, stateGridPoints, timeStepsPerYear, mesherEpsilon),
383+
discountCurve) {
384+
registerWith(solver_->model());
385+
registerWith(discountCurve_);
386+
}
387+
374388
void NumericLgmMultiLegOptionEngine::calculate() const {
375389
legs_ = arguments_.legs;
376390
payer_ = arguments_.payer;
@@ -396,6 +410,17 @@ NumericLgmSwaptionEngine::NumericLgmSwaptionEngine(const boost::shared_ptr<Linea
396410
registerWith(discountCurve_);
397411
}
398412

413+
NumericLgmSwaptionEngine::NumericLgmSwaptionEngine(const boost::shared_ptr<LinearGaussMarkovModel>& model,
414+
const Real maxTime, const Size stateGridPoints,
415+
const Size timeStepsPerYear, const Real mesherEpsilon,
416+
const Handle<YieldTermStructure>& discountCurve)
417+
: NumericLgmMultiLegOptionEngineBase(
418+
boost::make_shared<LgmFdSolver>(model, maxTime, stateGridPoints, timeStepsPerYear, mesherEpsilon),
419+
discountCurve) {
420+
registerWith(solver_->model());
421+
registerWith(discountCurve_);
422+
}
423+
399424
void NumericLgmSwaptionEngine::calculate() const {
400425
legs_ = arguments_.legs;
401426
payer_ = arguments_.payer;
@@ -420,6 +445,16 @@ NumericLgmNonstandardSwaptionEngine::NumericLgmNonstandardSwaptionEngine(
420445
registerWith(discountCurve_);
421446
}
422447

448+
NumericLgmNonstandardSwaptionEngine::NumericLgmNonstandardSwaptionEngine(
449+
const boost::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime, const Size stateGridPoints,
450+
const Size timeStepsPerYear, const Real mesherEpsilon, const Handle<YieldTermStructure>& discountCurve)
451+
: NumericLgmMultiLegOptionEngineBase(
452+
boost::make_shared<LgmFdSolver>(model, maxTime, stateGridPoints, timeStepsPerYear, mesherEpsilon),
453+
discountCurve) {
454+
registerWith(solver_->model());
455+
registerWith(discountCurve_);
456+
}
457+
423458
void NumericLgmNonstandardSwaptionEngine::calculate() const {
424459
legs_ = arguments_.legs;
425460
payer_ = arguments_.payer;

QuantExt/qle/pricingengines/numericlgmmultilegoptionengine.hpp

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,8 +21,7 @@
2121
#include <ql/instruments/nonstandardswaption.hpp>
2222
#include <ql/instruments/swaption.hpp>
2323
#include <qle/instruments/multilegoption.hpp>
24-
#include <qle/models/lgmconvolutionsolver2.hpp>
25-
#include <qle/models/lgmvectorised.hpp>
24+
#include <qle/models/lgmbackwardsolver.hpp>
2625

2726
#include <ql/pricingengines/genericmodelengine.hpp>
2827

@@ -61,6 +60,11 @@ class NumericLgmMultiLegOptionEngine
6160
const Real sx, const Size nx,
6261
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
6362

63+
NumericLgmMultiLegOptionEngine(const boost::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime = 50.0,
64+
const Size stateGridPoints = 64, const Size timeStepsPerYear = 24,
65+
const Real mesherEpsilon = 1E-4,
66+
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
67+
6468
void calculate() const override;
6569
};
6670

@@ -71,6 +75,11 @@ class NumericLgmSwaptionEngine : public QuantLib::GenericEngine<Swaption::argume
7175
const Real sx, const Size nx,
7276
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
7377

78+
NumericLgmSwaptionEngine(const boost::shared_ptr<LinearGaussMarkovModel>& model, const Real maxTime = 50.0,
79+
const Size stateGridPoints = 64, const Size timeStepsPerYear = 24,
80+
const Real mesherEpsilon = 1E-4,
81+
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
82+
7483
void calculate() const override;
7584
};
7685

@@ -82,6 +91,11 @@ class NumericLgmNonstandardSwaptionEngine
8291
const Size ny, const Real sx, const Size nx,
8392
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
8493

94+
NumericLgmNonstandardSwaptionEngine(const boost::shared_ptr<LinearGaussMarkovModel>& model,
95+
const Real maxTime = 50.0, const Size stateGridPoints = 64,
96+
const Size timeStepsPerYear = 24, const Real mesherEpsilon = 1E-4,
97+
const Handle<YieldTermStructure>& discountCurve = Handle<YieldTermStructure>());
98+
8599
void calculate() const override;
86100
};
87101

0 commit comments

Comments
 (0)