20#include <ql/exercise.hpp>
21#include <ql/indexes/iborindex.hpp>
22#include <ql/processes/ornsteinuhlenbeckprocess.hpp>
23#include <ql/pricingengines/swaption/fdhullwhiteswaptionengine.hpp>
24#include <ql/methods/finitedifferences/solvers/fdmsolverdesc.hpp>
25#include <ql/methods/finitedifferences/meshers/fdmmeshercomposite.hpp>
26#include <ql/methods/finitedifferences/operators/fdmlinearoplayout.hpp>
27#include <ql/methods/finitedifferences/meshers/fdmsimpleprocess1dmesher.hpp>
28#include <ql/methods/finitedifferences/solvers/fdmhullwhitesolver.hpp>
29#include <ql/methods/finitedifferences/utilities/fdmaffinemodelswapinnervalue.hpp>
30#include <ql/methods/finitedifferences/stepconditions/fdmstepconditioncomposite.hpp>
35 const ext::shared_ptr<HullWhite>& model,
43 dampingSteps_(dampingSteps),
45 schemeDesc_(schemeDesc) {
56 const Date referenceDate = ts->referenceDate();
60 auto process = ext::make_shared<OrnsteinUhlenbeckProcess>(
model_->a(),
model_->sigma());
61 auto shortRateMesher = ext::make_shared<FdmSimpleProcess1dMesher>(
xGrid_, process, maturity, 1,
invEps_);
62 auto mesher = ext::make_shared<FdmMesherComposite>(shortRateMesher);
65 const std::vector<Date>& exerciseDates =
arguments_.exercise->dates();
66 std::map<Time, Date> t2d;
68 for (
auto exerciseDate : exerciseDates) {
70 QL_REQUIRE(t >= 0,
"exercise dates must not contain past date");
72 t2d[t] = exerciseDate;
77 =
arguments_.swap->iborIndex()->forwardingTermStructure();
79 QL_REQUIRE(fwdTs->dayCounter() == disTs->dayCounter(),
80 "day counter of forward and discount curve must match");
81 QL_REQUIRE(fwdTs->referenceDate() == disTs->referenceDate(),
82 "reference date of forward and discount curve must match");
84 auto fwdModel = ext::make_shared<HullWhite>(fwdTs,
model_->a(),
model_->sigma());
85 auto calculator = ext::make_shared<FdmAffineModelSwapInnerValue<HullWhite>>(
93 mesher, calculator, referenceDate, dc);
100 calculator, maturity,
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
FdHullWhiteSwaptionEngine(const ext::shared_ptr< HullWhite > &model, Size tGrid=100, Size xGrid=100, Size dampingSteps=0, Real invEps=1e-5, const FdmSchemeDesc &schemeDesc=FdmSchemeDesc::Douglas())
const FdmSchemeDesc schemeDesc_
Real valueAt(Real r) const
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)
Base class for some pricing engine on a particular model.
Handle< HullWhite > model_
Shared handle to an observable.
bool empty() const
checks if the contained shared pointer points to anything
const ext::shared_ptr< T > & currentLink() const
dereferencing
Single-factor Hull-White (extended Vasicek) model class.
Real Time
continuous quantity with 1-year units
std::size_t Size
size of a container
std::vector< ext::shared_ptr< Dividend > > DividendSchedule
OperatorTraits< FdmLinearOp >::bc_set FdmBoundaryConditionSet