/* Copyright (C) 2003 Niels Elken Sønderby This file is part of QuantLib, a free-software/open-source library for financial quantitative analysts and developers - http://quantlib.org/ QuantLib is free software: you can redistribute it and/or modify it under the terms of the QuantLib license. You should have received a copy of the license along with this program; if not, please email ferdinando@ametrano.net The license is also available online at http://quantlib.org/html/license.html This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the license for more details. */ /* NesQuant is an extension to QuantLib http://www.nielses.dk/quantlib/nesquant */ #ifndef nesquant_lsmsvjdengine_h #define nesquant_lsmsvjdengine_h #include #include #include #include #include #include #include #include #include #include #include #include using namespace QuantLib; using namespace QuantLib::PricingEngines; using namespace QuantLib::MonteCarlo; using namespace QuantLib::RandomNumbers; using namespace QuantLib::Math; namespace NesQuant { class LSMSVJDEngine : public GenericEngine { public: LSMSVJDEngine::LSMSVJDEngine(Size samples = 100, Size timeSteps = 50, Size exerciseTimes = 50, Size degree = 2, bool antitheticVariate = false, bool controlVariate = false, long seed = 0) : timeSteps_(timeSteps), exerciseTimes_(exerciseTimes), degree_(degree), samples_(samples), seed_(seed), antitheticVariate_(antitheticVariate), controlVariate_(controlVariate) { QL_REQUIRE(timeSteps % exerciseTimes == 0, "timeSteps must be divisible with exerciseTimes"); }; void calculate() const; const Matrix exercisePoints() const { return exercisePoints_; } const Statistics& sampleAccumulator() const { return sampleAccumulator_; } private: bool antitheticVariate_, controlVariate_; Size timeSteps_, exerciseTimes_; Size degree_; // highest degree for polynomial Size samples_; long seed_; mutable Matrix exercisePoints_; mutable Statistics sampleAccumulator_; }; } #endif