diff --git a/ql/pricingengines/asian/fdblackscholesasianengine.cpp b/ql/pricingengines/asian/fdblackscholesasianengine.cpp index b397be69761..945ac9e95d1 100644 --- a/ql/pricingengines/asian/fdblackscholesasianengine.cpp +++ b/ql/pricingengines/asian/fdblackscholesasianengine.cpp @@ -57,9 +57,8 @@ namespace QuantLib { const ext::shared_ptr payoff = ext::dynamic_pointer_cast(arguments_.payoff); const Time maturity = process_->time(arguments_.exercise->lastDate()); - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher(xGrid_, process_, maturity, - payoff->strike())); + const auto equityMesher = ext::make_shared(xGrid_, process_, maturity, + payoff->strike()); const Real spot = process_->x0(); QL_REQUIRE(spot > 0.0, "negative or null underlying given"); @@ -76,16 +75,13 @@ namespace QuantLib { Real xMin = std::min(std::log(avg) - 0.25*r, std::log(spot) - 1.5*r); Real xMax = std::max(std::log(avg) + 0.25*r, std::log(spot) + 1.5*r); - const ext::shared_ptr averageMesher( - new FdmBlackScholesMesher(aGrid_, process_, maturity, - payoff->strike(), xMin, xMax)); + const auto averageMesher = ext::make_shared(aGrid_, process_, maturity, + payoff->strike(), xMin, xMax); - const ext::shared_ptr mesher ( - new FdmMesherComposite(equityMesher, averageMesher)); + const auto mesher = ext::make_shared(equityMesher, averageMesher); // 2. Calculator - ext::shared_ptr calculator( - new FdmLogInnerValue(payoff, mesher, 1)); + auto calculator = ext::make_shared(payoff, mesher, 1); // 3. Step conditions std::list > > stepConditions; @@ -99,13 +95,11 @@ namespace QuantLib { averageTimes.push_back(t); } stoppingTimes.emplace_back(averageTimes); - stepConditions.push_back(ext::shared_ptr >( - new FdmArithmeticAverageCondition( + stepConditions.push_back(ext::make_shared( averageTimes, arguments_.runningAccumulator, - arguments_.pastFixings, mesher, 0))); + arguments_.pastFixings, mesher, 0)); - ext::shared_ptr conditions( - new FdmStepConditionComposite(stoppingTimes, stepConditions)); + auto conditions = ext::make_shared(stoppingTimes, stepConditions); // 4. Boundary conditions const FdmBoundaryConditionSet boundaries; @@ -113,10 +107,9 @@ namespace QuantLib { // 5. Solver FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator, maturity, tGrid_, 0 }; - ext::shared_ptr solver( - new FdmSimple2dBSSolver( + auto solver = ext::make_shared( Handle(process_), - payoff->strike(), solverDesc, schemeDesc_)); + payoff->strike(), solverDesc, schemeDesc_); results_.value = solver->valueAt(spot, avg); results_.delta = solver->deltaAt(spot, avg, spot*0.01); diff --git a/ql/pricingengines/asian/mc_discr_arith_av_price.hpp b/ql/pricingengines/asian/mc_discr_arith_av_price.hpp index 22fae548e1e..531bb04b088 100644 --- a/ql/pricingengines/asian/mc_discr_arith_av_price.hpp +++ b/ql/pricingengines/asian/mc_discr_arith_av_price.hpp @@ -75,8 +75,7 @@ namespace QuantLib { ext::dynamic_pointer_cast( this->process_); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr(new - AnalyticDiscreteGeometricAveragePriceAsianEngine(process)); + return ext::make_shared(process); } }; @@ -141,14 +140,12 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr::path_pricer_type>( - new ArithmeticAPOPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount(exercise->lastDate()), this->arguments_.runningAccumulator, - this->arguments_.pastFixings)); + this->arguments_.pastFixings); } template @@ -175,12 +172,10 @@ namespace QuantLib { // for seasoned option the geometric strike might be rescaled // to obtain an equivalent arithmetic strike. // Any change applied here MUST be applied to the analytic engine too - return ext::shared_ptr::path_pricer_type>( - new GeometricAPOPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), - process->riskFreeRate()->discount(this->timeGrid().back()))); + process->riskFreeRate()->discount(this->timeGrid().back())); } template @@ -274,13 +269,12 @@ namespace QuantLib { inline MakeMCDiscreteArithmeticAPEngine::operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCDiscreteArithmeticAPEngine(process_, + return ext::make_shared>(process_, brownianBridge_, antithetic_, controlVariate_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } diff --git a/ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp b/ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp index 574add3b0ad..3f4ba858d11 100644 --- a/ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp +++ b/ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp @@ -74,8 +74,7 @@ namespace QuantLib { ext::shared_ptr

process = ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston-like process required"); - return ext::shared_ptr(new - AnalyticDiscreteGeometricAveragePriceAsianHestonEngine(process)); + return ext::make_shared(process); } }; @@ -180,15 +179,13 @@ namespace QuantLib { ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston like process required"); - return ext::shared_ptr::path_pricer_type>( - new ArithmeticAPOHestonPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount(exercise->lastDate()), fixingIndexes, this->arguments_.runningAccumulator, - this->arguments_.pastFixings)); + this->arguments_.pastFixings); } template @@ -224,13 +221,11 @@ namespace QuantLib { // pass seasoning details to the path pricer (NB. NEED to pass them to // the analytic pricer as well in that case). - return ext::shared_ptr::path_pricer_type>( - new GeometricAPOHestonPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount(exercise->lastDate()), - fixingIndexes)); + fixingIndexes); } template @@ -309,8 +304,7 @@ namespace QuantLib { template inline MakeMCDiscreteArithmeticAPHestonEngine::operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCDiscreteArithmeticAPHestonEngine(process_, + return ext::make_shared>(process_, antithetic_, samples_, tolerance_, @@ -318,7 +312,7 @@ namespace QuantLib { seed_, steps_, stepsPerYear_, - controlVariate_)); + controlVariate_); } } diff --git a/ql/pricingengines/asian/mc_discr_arith_av_strike.hpp b/ql/pricingengines/asian/mc_discr_arith_av_strike.hpp index 586d51d2460..f0d6e19291d 100644 --- a/ql/pricingengines/asian/mc_discr_arith_av_strike.hpp +++ b/ql/pricingengines/asian/mc_discr_arith_av_strike.hpp @@ -143,14 +143,12 @@ namespace QuantLib { } } - return ext::shared_ptr::path_pricer_type>( - new ArithmeticASOPathPricer( + return ext::make_shared( payoff->optionType(), process->riskFreeRate()->discount(exercise->lastDate()), this->arguments_.runningAccumulator, this->arguments_.pastFixings, - fixingCount)); + fixingCount); } @@ -238,13 +236,12 @@ namespace QuantLib { inline MakeMCDiscreteArithmeticASEngine:: operator ext::shared_ptr() const { - return ext::shared_ptr( - new MCDiscreteArithmeticASEngine(process_, + return ext::make_shared>(process_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/asian/mc_discr_geom_av_price.hpp b/ql/pricingengines/asian/mc_discr_geom_av_price.hpp index 1a0d9f2a2e4..92ec0fc3117 100644 --- a/ql/pricingengines/asian/mc_discr_geom_av_price.hpp +++ b/ql/pricingengines/asian/mc_discr_geom_av_price.hpp @@ -128,14 +128,12 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr::path_pricer_type>( - new GeometricAPOPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount(exercise->lastDate()), this->arguments_.runningAccumulator, - this->arguments_.pastFixings)); + this->arguments_.pastFixings); } @@ -222,13 +220,12 @@ namespace QuantLib { inline MakeMCDiscreteGeometricAPEngine::operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCDiscreteGeometricAPEngine(process_, + return ext::make_shared>(process_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/asian/mc_discr_geom_av_price_heston.hpp b/ql/pricingengines/asian/mc_discr_geom_av_price_heston.hpp index ab68ef928a6..be60eeb5eae 100644 --- a/ql/pricingengines/asian/mc_discr_geom_av_price_heston.hpp +++ b/ql/pricingengines/asian/mc_discr_geom_av_price_heston.hpp @@ -162,15 +162,13 @@ namespace QuantLib { ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston like process required"); - return ext::shared_ptr::path_pricer_type>( - new GeometricAPOHestonPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount(exercise->lastDate()), fixingIndexes, this->arguments_.runningAccumulator, - this->arguments_.pastFixings)); + this->arguments_.pastFixings); } template @@ -242,15 +240,14 @@ namespace QuantLib { template inline MakeMCDiscreteGeometricAPHestonEngine::operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCDiscreteGeometricAPHestonEngine(process_, + return ext::make_shared>(process_, antithetic_, samples_, tolerance_, maxSamples_, seed_, steps_, - stepsPerYear_)); + stepsPerYear_); } } diff --git a/ql/pricingengines/asian/mcdiscreteasianenginebase.hpp b/ql/pricingengines/asian/mcdiscreteasianenginebase.hpp index 152bb8e98d0..008573414b9 100644 --- a/ql/pricingengines/asian/mcdiscreteasianenginebase.hpp +++ b/ql/pricingengines/asian/mcdiscreteasianenginebase.hpp @@ -113,9 +113,8 @@ namespace QuantLib { TimeGrid grid = this->timeGrid(); typename RNG::rsg_type gen = RNG::make_sequence_generator(dimensions*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(process_, grid, - gen, brownianBridge_)); + return ext::make_shared(process_, grid, + gen, brownianBridge_); } Real controlVariateValue() const override; // data members diff --git a/ql/pricingengines/bacheliercalculator.cpp b/ql/pricingengines/bacheliercalculator.cpp index 8fef72351e6..773f0353e0a 100644 --- a/ql/pricingengines/bacheliercalculator.cpp +++ b/ql/pricingengines/bacheliercalculator.cpp @@ -54,7 +54,7 @@ namespace QuantLib { Option::Type optionType, Real strike, Real forward, Real stdDev, Real discount) : strike_(strike), forward_(forward), stdDev_(stdDev), discount_(discount), variance_(stdDev*stdDev) { - initialize(ext::shared_ptr(new PlainVanillaPayoff(optionType, strike))); + initialize(ext::make_shared(optionType, strike)); } void BachelierCalculator::initialize(const ext::shared_ptr& p) { diff --git a/ql/pricingengines/barrier/analyticbinarybarrierengine.cpp b/ql/pricingengines/barrier/analyticbinarybarrierengine.cpp index 2d97127a686..eed9321116f 100644 --- a/ql/pricingengines/barrier/analyticbinarybarrierengine.cpp +++ b/ql/pricingengines/barrier/analyticbinarybarrierengine.cpp @@ -102,11 +102,10 @@ namespace QuantLib { if ((barrierType == Barrier::DownIn && spot <= barrier) || (barrierType == Barrier::UpIn && spot >= barrier)) { // knocked in - is a digital european - ext::shared_ptr exercise(new EuropeanExercise( - arguments_.exercise->lastDate())); + auto exercise = ext::make_shared( + arguments_.exercise->lastDate()); - ext::shared_ptr engine( - new AnalyticEuropeanEngine(process_)); + auto engine = ext::make_shared(process_); VanillaOption opt(payoff, exercise); opt.setPricingEngine(engine); @@ -321,4 +320,3 @@ namespace QuantLib { } - diff --git a/ql/pricingengines/barrier/binomialbarrierengine.hpp b/ql/pricingengines/barrier/binomialbarrierengine.hpp index 42180ce948d..1df7e04fcd6 100644 --- a/ql/pricingengines/barrier/binomialbarrierengine.hpp +++ b/ql/pricingengines/barrier/binomialbarrierengine.hpp @@ -112,21 +112,17 @@ namespace QuantLib { // binomial trees with constant coefficient Handle flatRiskFree( - ext::shared_ptr( - new FlatForward(referenceDate, r, rfdc))); + ext::make_shared(referenceDate, r, rfdc)); Handle flatDividends( - ext::shared_ptr( - new FlatForward(referenceDate, q, divdc))); + ext::make_shared(referenceDate, q, divdc)); Handle flatVol( - ext::shared_ptr( - new BlackConstantVol(referenceDate, volcal, v, voldc))); + ext::make_shared(referenceDate, volcal, v, voldc)); Time maturity = rfdc.yearFraction(referenceDate, maturityDate); - ext::shared_ptr bs( - new GeneralizedBlackScholesProcess( + auto bs = ext::make_shared( process_->stateVariable(), - flatDividends, flatRiskFree, flatVol)); + flatDividends, flatRiskFree, flatVol); // correct timesteps to ensure a (local) minimum, using Boyle and Lau // approach. See Journal of Derivatives, 1/1994, @@ -157,11 +153,10 @@ namespace QuantLib { TimeGrid grid(maturity, optimum_steps); - ext::shared_ptr tree(new T(bs, maturity, optimum_steps, - payoff->strike())); + auto tree = ext::make_shared(bs, maturity, optimum_steps, + payoff->strike()); - ext::shared_ptr > lattice( - new BlackScholesLattice(tree, r, maturity, optimum_steps)); + auto lattice = ext::make_shared>(tree, r, maturity, optimum_steps); D option(arguments_, *process_, grid); option.initialize(lattice, maturity); diff --git a/ql/pricingengines/barrier/fdblackscholesbarrierengine.cpp b/ql/pricingengines/barrier/fdblackscholesbarrierengine.cpp index a446f404efa..a0aa946471e 100644 --- a/ql/pricingengines/barrier/fdblackscholesbarrierengine.cpp +++ b/ql/pricingengines/barrier/fdblackscholesbarrierengine.cpp @@ -99,29 +99,25 @@ namespace QuantLib { xMax = std::log(arguments_.barrier); } - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, process_, maturity, payoff->strike(), xMin, xMax, 0.0001, 1.5, std::make_pair(Null(), Null()), - dividends_)); + dividends_); - const ext::shared_ptr mesher ( - ext::make_shared(equityMesher)); + const auto mesher = ext::make_shared(equityMesher); // 2. Calculator - ext::shared_ptr calculator( - ext::make_shared(payoff, mesher, 0)); + auto calculator = ext::make_shared(payoff, mesher, 0); // 3. Step conditions std::list > > stepConditions; std::list > stoppingTimes; // 3.1 Step condition if discrete dividends - ext::shared_ptr dividendCondition( - ext::make_shared(dividends_, mesher, + auto dividendCondition = ext::make_shared(dividends_, mesher, process_->riskFreeRate()->referenceDate(), - process_->riskFreeRate()->dayCounter(), 0)); + process_->riskFreeRate()->dayCounter(), 0); if (!dividends_.empty()) { stepConditions.push_back(dividendCondition); @@ -132,8 +128,7 @@ namespace QuantLib { stoppingTimes.push_back(dividendTimes); } - ext::shared_ptr conditions( - ext::make_shared(stoppingTimes, stepConditions)); + auto conditions = ext::make_shared(stoppingTimes, stepConditions); // 4. Boundary conditions FdmBoundaryConditionSet boundaries; @@ -156,11 +151,10 @@ namespace QuantLib { FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator, maturity, tGrid_, dampingSteps_ }; - ext::shared_ptr solver( - ext::make_shared( + auto solver = ext::make_shared( Handle(process_), payoff->strike(), solverDesc, schemeDesc_, - localVol_, illegalLocalVolOverwrite_)); + localVol_, illegalLocalVolOverwrite_); results_.value = solver->valueAt(spot); results_.delta = solver->deltaAt(spot); diff --git a/ql/pricingengines/barrier/fdblackscholesrebateengine.cpp b/ql/pricingengines/barrier/fdblackscholesrebateengine.cpp index dcf9ed55266..a491cd6fc72 100644 --- a/ql/pricingengines/barrier/fdblackscholesrebateengine.cpp +++ b/ql/pricingengines/barrier/fdblackscholesrebateengine.cpp @@ -83,21 +83,17 @@ namespace QuantLib { xMax = std::log(arguments_.barrier); } - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, process_, maturity, payoff->strike(), xMin, xMax, 0.0001, 1.5, std::make_pair(Null(), Null()), - dividends_)); + dividends_); - const ext::shared_ptr mesher ( - new FdmMesherComposite(equityMesher)); + const auto mesher = ext::make_shared(equityMesher); // 2. Calculator - const ext::shared_ptr rebatePayoff( - new CashOrNothingPayoff(Option::Call, 0.0, arguments_.rebate)); - const ext::shared_ptr calculator( - new FdmLogInnerValue(rebatePayoff, mesher, 0)); + const auto rebatePayoff = ext::make_shared(Option::Call, 0.0, arguments_.rebate); + const auto calculator = ext::make_shared(rebatePayoff, mesher, 0); // 3. Step conditions QL_REQUIRE(arguments_.exercise->type() == Exercise::European, @@ -114,27 +110,24 @@ namespace QuantLib { FdmBoundaryConditionSet boundaries; if ( arguments_.barrierType == Barrier::DownIn || arguments_.barrierType == Barrier::DownOut) { - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Lower))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Lower)); } if ( arguments_.barrierType == Barrier::UpIn || arguments_.barrierType == Barrier::UpOut) { - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Upper))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Upper)); } // 5. Solver FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator, maturity, tGrid_, dampingSteps_ }; - const ext::shared_ptr solver( - new FdmBlackScholesSolver( + const auto solver = ext::make_shared( Handle(process_), payoff->strike(), solverDesc, schemeDesc_, - localVol_, illegalLocalVolOverwrite_)); + localVol_, illegalLocalVolOverwrite_); const Real spot = process_->x0(); results_.value = solver->valueAt(spot); diff --git a/ql/pricingengines/barrier/fdhestonbarrierengine.cpp b/ql/pricingengines/barrier/fdhestonbarrierengine.cpp index edb7be3e5fb..25788ab5ba7 100644 --- a/ql/pricingengines/barrier/fdhestonbarrierengine.cpp +++ b/ql/pricingengines/barrier/fdhestonbarrierengine.cpp @@ -75,8 +75,7 @@ namespace QuantLib { const Size tGridMin = 5; const Size tGridAvgSteps = std::max(tGridMin, tGrid_/50); - const ext::shared_ptr vMesher - = ext::make_shared( + const auto vMesher = ext::make_shared( vGrid_, process, leverageFct_, maturity, tGridAvgSteps, 0.0001, mixingFactor_); // 1.2 The equity mesher @@ -94,8 +93,7 @@ namespace QuantLib { xMax = std::log(arguments_.barrier); } - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( process->s0(), process->dividendYield(), @@ -103,24 +101,21 @@ namespace QuantLib { maturity, payoff->strike(), xMin, xMax, 0.0001, 1.5, std::make_pair(Null(), Null()), - dividends_)); + dividends_); - const ext::shared_ptr mesher ( - ext::make_shared(equityMesher, vMesher)); + const auto mesher = ext::make_shared(equityMesher, vMesher); // 2. Calculator - ext::shared_ptr calculator( - ext::make_shared(payoff, mesher, 0)); + auto calculator = ext::make_shared(payoff, mesher, 0); // 3. Step conditions std::list > > stepConditions; std::list > stoppingTimes; // 3.1 Step condition if discrete dividends - ext::shared_ptr dividendCondition( - ext::make_shared(dividends_, mesher, + auto dividendCondition = ext::make_shared(dividends_, mesher, process->riskFreeRate()->referenceDate(), - process->riskFreeRate()->dayCounter(), 0)); + process->riskFreeRate()->dayCounter(), 0); if (!dividends_.empty()) { stepConditions.push_back(dividendCondition); @@ -134,8 +129,7 @@ namespace QuantLib { QL_REQUIRE(arguments_.exercise->type() == Exercise::European, "only european style option are supported"); - ext::shared_ptr conditions( - ext::make_shared(stoppingTimes, stepConditions)); + auto conditions = ext::make_shared(stoppingTimes, stepConditions); // 4. Boundary conditions FdmBoundaryConditionSet boundaries; @@ -158,9 +152,9 @@ namespace QuantLib { calculator, maturity, tGrid_, dampingSteps_ }; - ext::shared_ptr solver(ext::make_shared( + auto solver = ext::make_shared( Handle(process), solverDesc, schemeDesc_, - Handle(), leverageFct_, mixingFactor_)); + Handle(), leverageFct_, mixingFactor_); const Real spot = process->s0()->value(); results_.value = solver->valueAt(spot, process->v0()); diff --git a/ql/pricingengines/barrier/fdhestondoublebarrierengine.cpp b/ql/pricingengines/barrier/fdhestondoublebarrierengine.cpp index 2db0b880cff..2286154be95 100644 --- a/ql/pricingengines/barrier/fdhestondoublebarrierengine.cpp +++ b/ql/pricingengines/barrier/fdhestondoublebarrierengine.cpp @@ -59,8 +59,7 @@ namespace QuantLib { const Size tGridMin = 5; const Size tGridAvgSteps = std::max(tGridMin, tGrid_/50); - const ext::shared_ptr vMesher - = ext::make_shared( + const auto vMesher = ext::make_shared( vGrid_, process, leverageFct_, maturity, tGridAvgSteps, 0.0001, mixingFactor_); // 1.2 The equity mesher @@ -70,20 +69,17 @@ namespace QuantLib { Real xMin = std::log(arguments_.barrier_lo); Real xMax = std::log(arguments_.barrier_hi); - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( process->s0(), process->dividendYield(), process->riskFreeRate(), vMesher->volaEstimate()), - maturity, payoff->strike(), xMin, xMax)); + maturity, payoff->strike(), xMin, xMax); - const ext::shared_ptr mesher ( - new FdmMesherComposite(equityMesher, vMesher)); + const auto mesher = ext::make_shared(equityMesher, vMesher); // 2. Calculator - const ext::shared_ptr calculator( - new FdmLogInnerValue(payoff, mesher, 0)); + const auto calculator = ext::make_shared(payoff, mesher, 0); // 3. Step conditions std::list > > stepConditions; @@ -92,27 +88,24 @@ namespace QuantLib { QL_REQUIRE(arguments_.exercise->type() == Exercise::European, "only european style option are supported"); - ext::shared_ptr conditions( - new FdmStepConditionComposite(stoppingTimes, stepConditions)); + auto conditions = ext::make_shared(stoppingTimes, stepConditions); // 4. Boundary conditions FdmBoundaryConditionSet boundaries; - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Lower))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Lower)); - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Upper))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Upper)); // 5. Solver FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator, maturity, tGrid_, dampingSteps_ }; - ext::shared_ptr solver(new FdmHestonSolver( + auto solver = ext::make_shared( Handle(process), solverDesc, schemeDesc_, - Handle(), leverageFct_, mixingFactor_)); + Handle(), leverageFct_, mixingFactor_); const Real spot = process->s0()->value(); results_.value = solver->valueAt(spot, process->v0()); diff --git a/ql/pricingengines/barrier/fdhestonrebateengine.cpp b/ql/pricingengines/barrier/fdhestonrebateengine.cpp index b1f29295e69..60323edc50b 100644 --- a/ql/pricingengines/barrier/fdhestonrebateengine.cpp +++ b/ql/pricingengines/barrier/fdhestonrebateengine.cpp @@ -76,8 +76,7 @@ namespace QuantLib { const Size tGridMin = 5; const Size tGridAvgSteps = std::max(tGridMin, tGrid_/50); - const ext::shared_ptr vMesher - = ext::make_shared( + const auto vMesher = ext::make_shared( vGrid_, process, leverageFct_, maturity, tGridAvgSteps, 0.0001, mixingFactor_); // 1.2 The equity mesher @@ -95,8 +94,7 @@ namespace QuantLib { xMax = std::log(arguments_.barrier); } - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( process->s0(), process->dividendYield(), @@ -104,16 +102,13 @@ namespace QuantLib { maturity, payoff->strike(), xMin, xMax, 0.0001, 1.5, std::make_pair(Null(), Null()), - dividends_)); + dividends_); - const ext::shared_ptr mesher ( - new FdmMesherComposite(equityMesher, vMesher)); + const auto mesher = ext::make_shared(equityMesher, vMesher); // 2. Calculator - const ext::shared_ptr rebatePayoff( - new CashOrNothingPayoff(Option::Call, 0.0, arguments_.rebate)); - const ext::shared_ptr calculator( - new FdmLogInnerValue(rebatePayoff, mesher, 0)); + const auto rebatePayoff = ext::make_shared(Option::Call, 0.0, arguments_.rebate); + const auto calculator = ext::make_shared(rebatePayoff, mesher, 0); // 3. Step conditions QL_REQUIRE(arguments_.exercise->type() == Exercise::European, @@ -130,16 +125,14 @@ namespace QuantLib { FdmBoundaryConditionSet boundaries; if ( arguments_.barrierType == Barrier::DownIn || arguments_.barrierType == Barrier::DownOut) { - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Lower))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Lower)); } if ( arguments_.barrierType == Barrier::UpIn || arguments_.barrierType == Barrier::UpOut) { - boundaries.push_back(FdmBoundaryConditionSet::value_type( - new FdmDirichletBoundary(mesher, arguments_.rebate, 0, - FdmDirichletBoundary::Upper))); + boundaries.push_back(ext::make_shared( + mesher, arguments_.rebate, 0, FdmDirichletBoundary::Upper)); } // 5. Solver @@ -147,9 +140,9 @@ namespace QuantLib { calculator, maturity, tGrid_, dampingSteps_ }; - ext::shared_ptr solver(new FdmHestonSolver( + auto solver = ext::make_shared( Handle(process), solverDesc, schemeDesc_, - Handle(), leverageFct_, mixingFactor_)); + Handle(), leverageFct_, mixingFactor_); const Real spot = process->s0()->value(); results_.value = solver->valueAt(spot, process->v0()); diff --git a/ql/pricingengines/barrier/mcbarrierengine.hpp b/ql/pricingengines/barrier/mcbarrierengine.hpp index 4a893a7584e..48b7e0031b7 100644 --- a/ql/pricingengines/barrier/mcbarrierengine.hpp +++ b/ql/pricingengines/barrier/mcbarrierengine.hpp @@ -95,9 +95,8 @@ namespace QuantLib { TimeGrid grid = timeGrid(); typename RNG::rsg_type gen = RNG::make_sequence_generator(grid.size()-1,seed_); - return ext::shared_ptr( - new path_generator_type(process_, - grid, gen, brownianBridge_)); + return ext::make_shared(process_, + grid, gen, brownianBridge_); } ext::shared_ptr pathPricer() const override; // data members @@ -243,21 +242,17 @@ namespace QuantLib { // do this with template parameters? if (isBiased_) { - return ext::shared_ptr< - typename MCBarrierEngine::path_pricer_type>( - new BiasedBarrierPathPricer( + return ext::make_shared( arguments_.barrierType, arguments_.barrier, arguments_.rebate, payoff->optionType(), payoff->strike(), - discounts)); + discounts); } else { PseudoRandom::ursg_type sequenceGen(grid.size()-1, PseudoRandom::urng_type(5)); - return ext::shared_ptr< - typename MCBarrierEngine::path_pricer_type>( - new BarrierPathPricer( + return ext::make_shared( arguments_.barrierType, arguments_.barrier, arguments_.rebate, @@ -265,7 +260,7 @@ namespace QuantLib { payoff->strike(), discounts, process_, - sequenceGen)); + sequenceGen); } } @@ -354,8 +349,7 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCBarrierEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, @@ -363,7 +357,7 @@ namespace QuantLib { samples_, tolerance_, maxSamples_, biased_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/basket/fd2dblackscholesvanillaengine.cpp b/ql/pricingengines/basket/fd2dblackscholesvanillaengine.cpp index 9d447b2557f..e09d8239d36 100644 --- a/ql/pricingengines/basket/fd2dblackscholesvanillaengine.cpp +++ b/ql/pricingengines/basket/fd2dblackscholesvanillaengine.cpp @@ -56,24 +56,20 @@ namespace QuantLib { // 2. Mesher const Time maturity = p1_->time(arguments_.exercise->lastDate()); - const ext::shared_ptr em1( - new FdmBlackScholesMesher( + const auto em1 = ext::make_shared( xGrid_, p1_, maturity, p1_->x0(), Null(), Null(), 0.0001, 1.5, - std::pair(p1_->x0(), 0.1))); + std::pair(p1_->x0(), 0.1)); - const ext::shared_ptr em2( - new FdmBlackScholesMesher( + const auto em2 = ext::make_shared( yGrid_, p2_, maturity, p2_->x0(), Null(), Null(), 0.0001, 1.5, - std::pair(p2_->x0(), 0.1))); + std::pair(p2_->x0(), 0.1)); - const ext::shared_ptr mesher ( - new FdmMesherComposite(em1, em2)); + const auto mesher = ext::make_shared(em1, em2); // 3. Calculator - const ext::shared_ptr calculator( - new FdmLogBasketInnerValue(payoff, mesher)); + const auto calculator = ext::make_shared(payoff, mesher); // 4. Step conditions const ext::shared_ptr conditions = @@ -91,12 +87,11 @@ namespace QuantLib { conditions, calculator, maturity, tGrid_, dampingSteps_ }; - ext::shared_ptr solver( - new Fdm2dBlackScholesSolver( + auto solver = ext::make_shared( Handle(p1_), Handle(p2_), correlation_, solverDesc, schemeDesc_, - localVol_, illegalLocalVolOverwrite_)); + localVol_, illegalLocalVolOverwrite_); const Real x = p1_->x0(); const Real y = p2_->x0(); diff --git a/ql/pricingengines/basket/mcamericanbasketengine.hpp b/ql/pricingengines/basket/mcamericanbasketengine.hpp index 3a7d7632774..53d1ce9492d 100644 --- a/ql/pricingengines/basket/mcamericanbasketengine.hpp +++ b/ql/pricingengines/basket/mcamericanbasketengine.hpp @@ -174,11 +174,10 @@ namespace QuantLib { QL_REQUIRE(!exercise->payoffAtExpiry(), "payoff at expiry not handled"); - ext::shared_ptr earlyExercisePathPricer( - new AmericanBasketPathPricer(processArray->size(), + auto earlyExercisePathPricer = ext::make_shared(processArray->size(), this->arguments_.payoff, polynomialOrder_, - polynomialType_)); + polynomialType_); return ext::make_shared > ( @@ -287,8 +286,7 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCAmericanBasketEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, @@ -299,7 +297,7 @@ namespace QuantLib { seed_, calibrationSamples_, polynomialOrder_, - polynomialType_)); + polynomialType_); } } diff --git a/ql/pricingengines/basket/mceuropeanbasketengine.hpp b/ql/pricingengines/basket/mceuropeanbasketengine.hpp index 97e41a946a7..9ec72a31a3a 100644 --- a/ql/pricingengines/basket/mceuropeanbasketengine.hpp +++ b/ql/pricingengines/basket/mceuropeanbasketengine.hpp @@ -80,9 +80,8 @@ namespace QuantLib { typename RNG::rsg_type gen = RNG::make_sequence_generator(numAssets*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(processes_, - grid, gen, brownianBridge_)); + return ext::make_shared(processes_, + grid, gen, brownianBridge_); } ext::shared_ptr pathPricer() const override; // data members @@ -193,11 +192,9 @@ namespace QuantLib { processes_->process(0)); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr< - typename MCEuropeanBasketEngine::path_pricer_type>( - new EuropeanMultiPathPricer(payoff, + return ext::make_shared(payoff, process->riskFreeRate()->discount( - arguments_.exercise->lastDate()))); + arguments_.exercise->lastDate())); } @@ -278,15 +275,14 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCEuropeanBasketEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/basket/stulzengine.cpp b/ql/pricingengines/basket/stulzengine.cpp index fca697583bd..dec1939733d 100644 --- a/ql/pricingengines/basket/stulzengine.cpp +++ b/ql/pricingengines/basket/stulzengine.cpp @@ -84,8 +84,7 @@ namespace QuantLib { Real variance1, Real variance2, Real rho) { - ext::shared_ptr payoff(new - PlainVanillaPayoff(Option::Call, strike)); + auto payoff = ext::make_shared(Option::Call, strike); Real black1 = blackFormula(payoff->optionType(), payoff->strike(), forward1, std::sqrt(variance1)) * riskFreeDiscount; @@ -205,4 +204,3 @@ namespace QuantLib { } } - diff --git a/ql/pricingengines/blackcalculator.cpp b/ql/pricingengines/blackcalculator.cpp index 7790d4b7c78..c5d502f2ca8 100644 --- a/ql/pricingengines/blackcalculator.cpp +++ b/ql/pricingengines/blackcalculator.cpp @@ -58,8 +58,7 @@ namespace QuantLib { Real discount) : strike_(strike), forward_(forward), stdDev_(stdDev), discount_(discount), variance_(stdDev*stdDev) { - initialize(ext::shared_ptr(new - PlainVanillaPayoff(optionType, strike))); + initialize(ext::make_shared(optionType, strike)); } void BlackCalculator::initialize(const ext::shared_ptr& p) { diff --git a/ql/pricingengines/bond/binomialconvertibleengine.hpp b/ql/pricingengines/bond/binomialconvertibleengine.hpp index 3fa5a03fe76..ff7acbd530e 100644 --- a/ql/pricingengines/bond/binomialconvertibleengine.hpp +++ b/ql/pricingengines/bond/binomialconvertibleengine.hpp @@ -101,25 +101,22 @@ namespace QuantLib { "negative value after subtracting dividends"); // binomial trees with constant coefficient - Handle underlying(ext::shared_ptr(new SimpleQuote(s0))); - Handle flatRiskFree(ext::shared_ptr( - new FlatForward(referenceDate, riskFreeRate, rfdc))); + Handle underlying(ext::make_shared(s0)); + Handle flatRiskFree(ext::make_shared(referenceDate, riskFreeRate, rfdc)); Handle flatDividends( - ext::shared_ptr(new FlatForward(referenceDate, q, divdc))); - Handle flatVol(ext::shared_ptr( - new BlackConstantVol(referenceDate, volcal, v, voldc))); + ext::make_shared(referenceDate, q, divdc)); + Handle flatVol(ext::make_shared(referenceDate, volcal, v, voldc)); Time maturity = rfdc.yearFraction(arguments_.settlementDate, maturityDate); Real strike = arguments_.redemption / arguments_.conversionRatio ; - ext::shared_ptr bs( - new GeneralizedBlackScholesProcess(underlying, flatDividends, flatRiskFree, flatVol)); - ext::shared_ptr tree(new T(bs, maturity, timeSteps_, strike)); + auto bs = ext::make_shared(underlying, flatDividends, flatRiskFree, flatVol); + auto tree = ext::make_shared(bs, maturity, timeSteps_, strike); Real creditSpread = creditSpread_->value(); - ext::shared_ptr lattice(new TsiveriotisFernandesLattice( - tree, riskFreeRate, maturity, timeSteps_, creditSpread, v, q)); + auto lattice = ext::make_shared>( + tree, riskFreeRate, maturity, timeSteps_, creditSpread, v, q); DiscretizedConvertible convertible(arguments_, bs, dividends_, creditSpread_, TimeGrid(maturity, timeSteps_)); diff --git a/ql/pricingengines/capfloor/bacheliercapfloorengine.cpp b/ql/pricingengines/capfloor/bacheliercapfloorengine.cpp index e58eb978519..79e9c1ae451 100644 --- a/ql/pricingengines/capfloor/bacheliercapfloorengine.cpp +++ b/ql/pricingengines/capfloor/bacheliercapfloorengine.cpp @@ -32,8 +32,7 @@ namespace QuantLib { Volatility v, const DayCounter& dc) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr( - new ConstantOptionletVolatility(0, NullCalendar(), Following, v, dc))) { + vol_(ext::make_shared(0, NullCalendar(), Following, v, dc)) { registerWith(discountCurve_); } @@ -41,8 +40,7 @@ namespace QuantLib { const Handle& v, const DayCounter& dc) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr( - new ConstantOptionletVolatility(0, NullCalendar(), Following, v, dc))) { + vol_(ext::make_shared(0, NullCalendar(), Following, v, dc)) { registerWith(discountCurve_); registerWith(vol_); } diff --git a/ql/pricingengines/capfloor/blackcapfloorengine.cpp b/ql/pricingengines/capfloor/blackcapfloorengine.cpp index a4011affbcc..2e971a220b4 100644 --- a/ql/pricingengines/capfloor/blackcapfloorengine.cpp +++ b/ql/pricingengines/capfloor/blackcapfloorengine.cpp @@ -35,8 +35,7 @@ namespace QuantLib { const DayCounter& dc, Real displacement) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr( - new ConstantOptionletVolatility(0, NullCalendar(), Following, v, dc))), + vol_(ext::make_shared(0, NullCalendar(), Following, v, dc)), displacement_(displacement) { registerWith(discountCurve_); } @@ -46,8 +45,7 @@ namespace QuantLib { const DayCounter& dc, Real displacement) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr( - new ConstantOptionletVolatility(0, NullCalendar(), Following, v, dc))), + vol_(ext::make_shared(0, NullCalendar(), Following, v, dc)), displacement_(displacement) { registerWith(discountCurve_); registerWith(vol_); diff --git a/ql/pricingengines/capfloor/mchullwhiteengine.hpp b/ql/pricingengines/capfloor/mchullwhiteengine.hpp index dfa4bff9e03..8a2206c37c0 100644 --- a/ql/pricingengines/capfloor/mchullwhiteengine.hpp +++ b/ql/pricingengines/capfloor/mchullwhiteengine.hpp @@ -101,9 +101,8 @@ namespace QuantLib { Time forwardMeasureTime = dayCounter.yearFraction(referenceDate, arguments_.endDates.back()); - return ext::shared_ptr( - new detail::HullWhiteCapFloorPricer(arguments_, model_, - forwardMeasureTime)); + return ext::make_shared(arguments_, model_, + forwardMeasureTime); } TimeGrid timeGrid() const { @@ -137,16 +136,14 @@ namespace QuantLib { arguments_.endDates.back()); Array parameters = model_->params(); Real a = parameters[0], sigma = parameters[1]; - ext::shared_ptr process( - new HullWhiteForwardProcess(curve, a, sigma)); + auto process = ext::make_shared(curve, a, sigma); process->setForwardMeasureTime(forwardMeasureTime); TimeGrid grid = this->timeGrid(); typename RNG::rsg_type generator = RNG::make_sequence_generator(grid.size()-1,seed_); - return ext::shared_ptr( - new path_generator_type(process, grid, generator, - brownianBridge_)); + return ext::make_shared(process, grid, generator, + brownianBridge_); } }; @@ -237,11 +234,10 @@ namespace QuantLib { template inline MakeMCHullWhiteCapFloorEngine:: operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCHullWhiteCapFloorEngine(model_, + return ext::make_shared>(model_, brownianBridge_, antithetic_, samples_, tolerance_, - maxSamples_, seed_)); + maxSamples_, seed_); } } diff --git a/ql/pricingengines/cliquet/analyticcliquetengine.cpp b/ql/pricingengines/cliquet/analyticcliquetengine.cpp index 9bbb7076bd5..02157cfd135 100644 --- a/ql/pricingengines/cliquet/analyticcliquetengine.cpp +++ b/ql/pricingengines/cliquet/analyticcliquetengine.cpp @@ -55,8 +55,7 @@ namespace QuantLib { Real underlying = process_->stateVariable()->value(); QL_REQUIRE(underlying > 0.0, "negative or null underlying"); Real strike = underlying * moneyness->strike(); - ext::shared_ptr payoff( - new PlainVanillaPayoff(moneyness->optionType(),strike)); + auto payoff = ext::make_shared(moneyness->optionType(),strike); results_.value = 0.0; results_.delta = results_.gamma = 0.0; @@ -111,4 +110,3 @@ namespace QuantLib { } } - diff --git a/ql/pricingengines/cliquet/analyticperformanceengine.cpp b/ql/pricingengines/cliquet/analyticperformanceengine.cpp index dc5a9ba314c..f24869f7bec 100644 --- a/ql/pricingengines/cliquet/analyticperformanceengine.cpp +++ b/ql/pricingengines/cliquet/analyticperformanceengine.cpp @@ -55,8 +55,7 @@ namespace QuantLib { Real underlying = process_->stateVariable()->value(); QL_REQUIRE(underlying > 0.0, "negative or null underlying"); - ext::shared_ptr payoff( - new PlainVanillaPayoff(moneyness->optionType(), 1.0)); + auto payoff = ext::make_shared(moneyness->optionType(), 1.0); results_.value = 0.0; results_.delta = results_.gamma = 0.0; @@ -111,4 +110,3 @@ namespace QuantLib { } } - diff --git a/ql/pricingengines/cliquet/mcperformanceengine.hpp b/ql/pricingengines/cliquet/mcperformanceengine.hpp index 64e0ec82bbc..783639299b2 100644 --- a/ql/pricingengines/cliquet/mcperformanceengine.hpp +++ b/ql/pricingengines/cliquet/mcperformanceengine.hpp @@ -66,9 +66,8 @@ namespace QuantLib { TimeGrid grid = this->timeGrid(); typename RNG::rsg_type gen = RNG::make_sequence_generator(grid.size()-1,seed_); - return ext::shared_ptr( - new path_generator_type(process_, grid, - gen, brownianBridge_)); + return ext::make_shared(process_, grid, + gen, brownianBridge_); } ext::shared_ptr pathPricer() const override; // data members @@ -174,11 +173,9 @@ namespace QuantLib { discounts.push_back(this->process_->riskFreeRate()->discount( arguments_.exercise->lastDate())); - return ext::shared_ptr< - typename MCPerformanceEngine::path_pricer_type>( - new PerformanceOptionPathPricer(payoff->optionType(), + return ext::make_shared(payoff->optionType(), payoff->strike(), - discounts)); + discounts); } @@ -241,14 +238,13 @@ namespace QuantLib { inline MakeMCPerformanceEngine::operator ext::shared_ptr() const { - return ext::shared_ptr(new - MCPerformanceEngine(process_, + return ext::make_shared>(process_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/exotic/analyticamericanmargrabeengine.cpp b/ql/pricingengines/exotic/analyticamericanmargrabeengine.cpp index 5ee4f6c94d0..b6b0063496d 100644 --- a/ql/pricingengines/exotic/analyticamericanmargrabeengine.cpp +++ b/ql/pricingengines/exotic/analyticamericanmargrabeengine.cpp @@ -62,10 +62,9 @@ namespace QuantLib { Real s1 = process1_->stateVariable()->value(); Real s2 = process2_->stateVariable()->value(); - ext::shared_ptr spot(new SimpleQuote(arguments_.Q1*s1)); + auto spot = ext::make_shared(arguments_.Q1*s1); - ext::shared_ptr payoff( - new PlainVanillaPayoff(Option::Call, arguments_.Q2*s2)); + auto payoff = ext::make_shared(Option::Call, arguments_.Q2*s2); DiscountFactor dividendDiscount1 = process1_->dividendYield()->discount(exercise->lastDate()); @@ -75,11 +74,9 @@ namespace QuantLib { process2_->dividendYield()->discount(exercise->lastDate()); Rate q2 = -std::log(dividendDiscount2)/t; - ext::shared_ptr qTS( - new FlatForward(today, q1, rfdc)); + auto qTS = ext::make_shared(today, q1, rfdc); - ext::shared_ptr rTS( - new FlatForward(today, q2, rfdc)); + auto rTS = ext::make_shared(today, q2, rfdc); Real variance1 = process1_->blackVolatility()->blackVariance( exercise->lastDate(), s1); @@ -89,17 +86,14 @@ namespace QuantLib { - 2*rho_*std::sqrt(variance1)*std::sqrt(variance2); Volatility volatility = std::sqrt(variance/t); - ext::shared_ptr volTS( - new BlackConstantVol(today, NullCalendar(), volatility, rfdc)); + auto volTS = ext::make_shared(today, NullCalendar(), volatility, rfdc); - ext::shared_ptr stochProcess(new - BlackScholesMertonProcess(Handle(spot), + auto stochProcess = ext::make_shared(Handle(spot), Handle(qTS), Handle(rTS), - Handle(volTS))); + Handle(volTS)); - ext::shared_ptr engine( - new BjerksundStenslandApproximationEngine(stochProcess)); + auto engine = ext::make_shared(stochProcess); VanillaOption option(payoff, exercise); option.setPricingEngine(engine); diff --git a/ql/pricingengines/exotic/analyticcompoundoptionengine.cpp b/ql/pricingengines/exotic/analyticcompoundoptionengine.cpp index e2567ce7102..0ef95dd0456 100644 --- a/ql/pricingengines/exotic/analyticcompoundoptionengine.cpp +++ b/ql/pricingengines/exotic/analyticcompoundoptionengine.cpp @@ -85,9 +85,8 @@ namespace QuantLib { process_->riskFreeRate()->discount(helpMaturity); - ext::shared_ptr f( - new ImpliedSpotHelper(dividendDiscount, riskFreeDiscount, - vol, payoffDaughter(), strikeMother())); + auto f = ext::make_shared(dividendDiscount, riskFreeDiscount, + vol, payoffDaughter(), strikeMother()); Brent solver; solver.setMaxEvaluations(1000); diff --git a/ql/pricingengines/forward/forwardengine.hpp b/ql/pricingengines/forward/forwardengine.hpp index 935a55424bb..95a85905151 100644 --- a/ql/pricingengines/forward/forwardengine.hpp +++ b/ql/pricingengines/forward/forwardengine.hpp @@ -81,10 +81,9 @@ namespace QuantLib { this->arguments_.payoff); QL_REQUIRE(argumentsPayoff, "wrong payoff given"); - ext::shared_ptr payoff( - new PlainVanillaPayoff(argumentsPayoff->optionType(), + auto payoff = ext::make_shared(argumentsPayoff->optionType(), this->arguments_.moneyness * - process_->x0())); + process_->x0()); // maybe the forward value is "better", in some fashion // the right level is needed in order to interpolate @@ -92,29 +91,25 @@ namespace QuantLib { Handle spot = process_->stateVariable(); QL_REQUIRE(spot->value() > 0.0, "negative or null underlying given"); Handle dividendYield( - ext::shared_ptr( - new ImpliedTermStructure(process_->dividendYield(), - this->arguments_.resetDate))); + ext::make_shared(process_->dividendYield(), + this->arguments_.resetDate)); Handle riskFreeRate( - ext::shared_ptr( - new ImpliedTermStructure(process_->riskFreeRate(), - this->arguments_.resetDate))); + ext::make_shared(process_->riskFreeRate(), + this->arguments_.resetDate)); // The following approach is ok if the vol is at most // time-dependent. It is plain wrong if it is asset-dependent. // In the latter case the right solution would be stochastic // volatility or at least local volatility (which unfortunately // implies an unrealistic time-decreasing smile) Handle blackVolatility( - ext::shared_ptr( - new ImpliedVolTermStructure(process_->blackVolatility(), - this->arguments_.resetDate))); + ext::make_shared(process_->blackVolatility(), + this->arguments_.resetDate)); - ext::shared_ptr fwdProcess( - new GeneralizedBlackScholesProcess(spot, dividendYield, + auto fwdProcess = ext::make_shared(spot, dividendYield, riskFreeRate, - blackVolatility)); + blackVolatility); - originalEngine_ = ext::shared_ptr(new Engine(fwdProcess)); + originalEngine_ = ext::make_shared(fwdProcess); originalEngine_->reset(); originalArguments_ = diff --git a/ql/pricingengines/forward/mcforwardeuropeanbsengine.hpp b/ql/pricingengines/forward/mcforwardeuropeanbsengine.hpp index 0d9d7442c65..d691188b779 100644 --- a/ql/pricingengines/forward/mcforwardeuropeanbsengine.hpp +++ b/ql/pricingengines/forward/mcforwardeuropeanbsengine.hpp @@ -152,14 +152,12 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr::path_pricer_type>( - new ForwardEuropeanBSPathPricer( + return ext::make_shared( payoff->optionType(), this->arguments_.moneyness, resetIndex, process->riskFreeRate()->discount( - timeGrid.back()))); + timeGrid.back())); } @@ -241,15 +239,14 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified - set EITHER steps OR stepsPerYear"); - return ext::shared_ptr(new - MCForwardEuropeanBSEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/forward/mcforwardeuropeanhestonengine.hpp b/ql/pricingengines/forward/mcforwardeuropeanhestonengine.hpp index f2f6cfaac57..a5b44c90677 100644 --- a/ql/pricingengines/forward/mcforwardeuropeanhestonengine.hpp +++ b/ql/pricingengines/forward/mcforwardeuropeanhestonengine.hpp @@ -77,9 +77,8 @@ namespace QuantLib { ext::shared_ptr

process = ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston-like process required"); - ext::shared_ptr hestonModel(new HestonModel(process)); - return ext::shared_ptr(new - AnalyticHestonEngine(hestonModel)); + auto hestonModel = ext::make_shared(process); + return ext::make_shared(hestonModel); } }; @@ -173,14 +172,12 @@ namespace QuantLib { ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston like process required"); - return ext::shared_ptr::path_pricer_type>( - new ForwardEuropeanHestonPathPricer( + return ext::make_shared( payoff->optionType(), this->arguments_.moneyness, resetIndex, process->riskFreeRate()->discount( - timeGrid.back()))); + timeGrid.back())); } template @@ -206,14 +203,12 @@ namespace QuantLib { ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston like process required"); - return ext::shared_ptr::path_pricer_type>( - new ForwardEuropeanHestonPathPricer( + return ext::make_shared( payoff->optionType(), this->arguments_.moneyness, resetIndex, process->riskFreeRate()->discount( - timeGrid.back()))); + timeGrid.back())); } template @@ -293,8 +288,7 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified - set EITHER steps OR stepsPerYear"); - return ext::shared_ptr(new - MCForwardEuropeanHestonEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, antithetic_, @@ -302,7 +296,7 @@ namespace QuantLib { tolerance_, maxSamples_, seed_, - controlVariate_)); + controlVariate_); } } diff --git a/ql/pricingengines/forward/mcforwardvanillaengine.hpp b/ql/pricingengines/forward/mcforwardvanillaengine.hpp index 4b5fc1cd482..ed574f40b23 100644 --- a/ql/pricingengines/forward/mcforwardvanillaengine.hpp +++ b/ql/pricingengines/forward/mcforwardvanillaengine.hpp @@ -74,9 +74,8 @@ namespace QuantLib { TimeGrid grid = this->timeGrid(); typename RNG::rsg_type gen = RNG::make_sequence_generator(dimensions*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(process_, grid, - gen, brownianBridge_)); + return ext::make_shared(process_, grid, + gen, brownianBridge_); } // data members ext::shared_ptr process_; @@ -159,8 +158,7 @@ namespace QuantLib { Real moneyness = this->arguments_.moneyness; Real strike = moneyness * spot; - ext::shared_ptr newPayoff(new - PlainVanillaPayoff(payoff->optionType(), strike)); + auto newPayoff = ext::make_shared(payoff->optionType(), strike); auto* controlArguments = dynamic_cast(controlPE->getArguments()); diff --git a/ql/pricingengines/forward/mcvarianceswapengine.hpp b/ql/pricingengines/forward/mcvarianceswapengine.hpp index b3db506e11a..8f1d7275950 100644 --- a/ql/pricingengines/forward/mcvarianceswapengine.hpp +++ b/ql/pricingengines/forward/mcvarianceswapengine.hpp @@ -112,9 +112,8 @@ namespace QuantLib { typename RNG::rsg_type gen = RNG::make_sequence_generator(dimensions*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(process_, grid, gen, - brownianBridge_)); + return ext::make_shared(process_, grid, gen, + brownianBridge_); } // data members ext::shared_ptr process_; @@ -215,9 +214,7 @@ namespace QuantLib { typename MCVarianceSwapEngine::path_pricer_type> MCVarianceSwapEngine::pathPricer() const { - return ext::shared_ptr< - typename MCVarianceSwapEngine::path_pricer_type>( - new VariancePathPricer(process_)); + return ext::make_shared(process_); } @@ -297,15 +294,14 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr( - new MCVarianceSwapEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } diff --git a/ql/pricingengines/forward/replicatingvarianceswapengine.hpp b/ql/pricingengines/forward/replicatingvarianceswapengine.hpp index d74b41e7430..29ff6b0c6da 100644 --- a/ql/pricingengines/forward/replicatingvarianceswapengine.hpp +++ b/ql/pricingengines/forward/replicatingvarianceswapengine.hpp @@ -132,8 +132,7 @@ namespace QuantLib { slope = std::fabs((computeLogPayoff(*(k+1), f) - computeLogPayoff(*k, f))/ (*(k+1) - *k)); - ext::shared_ptr payoff( - new PlainVanillaPayoff(type, *k)); + auto payoff = ext::make_shared(type, *k); if ( k == strikes.begin() ) optionWeights.emplace_back(payoff,slope); else @@ -155,10 +154,8 @@ namespace QuantLib { Real ReplicatingVarianceSwapEngine::computeReplicatingPortfolio( const weights_type& optionWeights) const { - ext::shared_ptr exercise( - new EuropeanExercise(arguments_.maturityDate)); - ext::shared_ptr optionEngine( - new AnalyticEuropeanEngine(process_)); + auto exercise = ext::make_shared(arguments_.maturityDate); + auto optionEngine = ext::make_shared(process_); Real optionsValue = 0.0; for (auto i = optionWeights.begin(); i < optionWeights.end(); ++i) { diff --git a/ql/pricingengines/lookback/mclookbackengine.cpp b/ql/pricingengines/lookback/mclookbackengine.cpp index 6439313b579..58c6dc0fe26 100644 --- a/ql/pricingengines/lookback/mclookbackengine.cpp +++ b/ql/pricingengines/lookback/mclookbackengine.cpp @@ -83,10 +83,9 @@ namespace QuantLib { ext::dynamic_pointer_cast(args.payoff); QL_REQUIRE(payoff, "non-plain payoff given"); - return ext::shared_ptr >( - new LookbackFixedPathPricer(payoff->optionType(), + return ext::make_shared(payoff->optionType(), payoff->strike(), - discount)); + discount); } ext::shared_ptr > @@ -100,11 +99,10 @@ namespace QuantLib { Time lookbackStart = process.time(args.lookbackPeriodStart); - return ext::shared_ptr >( - new LookbackPartialFixedPathPricer(lookbackStart, + return ext::make_shared(lookbackStart, payoff->optionType(), payoff->strike(), - discount)); + discount); } ext::shared_ptr > @@ -116,9 +114,8 @@ namespace QuantLib { ext::dynamic_pointer_cast(args.payoff); QL_REQUIRE(payoff, "non-floating payoff given"); - return ext::shared_ptr >( - new LookbackFloatingPathPricer(payoff->optionType(), - discount)); + return ext::make_shared(payoff->optionType(), + discount); } ext::shared_ptr > @@ -132,10 +129,9 @@ namespace QuantLib { Time lookbackEnd = process.time(args.lookbackPeriodEnd); - return ext::shared_ptr >( - new LookbackPartialFloatingPathPricer(lookbackEnd, + return ext::make_shared(lookbackEnd, payoff->optionType(), - discount)); + discount); } } diff --git a/ql/pricingengines/lookback/mclookbackengine.hpp b/ql/pricingengines/lookback/mclookbackengine.hpp index 1032273e6af..633cc74d921 100644 --- a/ql/pricingengines/lookback/mclookbackengine.hpp +++ b/ql/pricingengines/lookback/mclookbackengine.hpp @@ -70,9 +70,8 @@ namespace QuantLib { TimeGrid grid = timeGrid(); typename RNG::rsg_type gen = RNG::make_sequence_generator(grid.size()-1,seed_); - return ext::shared_ptr( - new path_generator_type(process_, - grid, gen, brownianBridge_)); + return ext::make_shared(process_, + grid, gen, brownianBridge_); } ext::shared_ptr pathPricer() const override; // data members @@ -278,8 +277,7 @@ namespace QuantLib { QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr( - new MCLookbackEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, @@ -287,7 +285,7 @@ namespace QuantLib { samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/mclongstaffschwartzengine.hpp b/ql/pricingengines/mclongstaffschwartzengine.hpp index 5126044fde2..7a1a464783b 100644 --- a/ql/pricingengines/mclongstaffschwartzengine.hpp +++ b/ql/pricingengines/mclongstaffschwartzengine.hpp @@ -184,15 +184,12 @@ namespace QuantLib { typename RNG_Calibration::rsg_type generator = RNG_Calibration::make_sequence_generator( dimensions * (grid.size() - 1), seedCalibration_); - ext::shared_ptr - pathGeneratorCalibration = - ext::make_shared( + auto pathGeneratorCalibration = ext::make_shared( process_, grid, generator, brownianBridgeCalibration_); mcModelCalibration_ = - ext::shared_ptr >( - new MonteCarloModel( + ext::make_shared>( pathGeneratorCalibration, pathPricer_, stats_type(), - this->antitheticVariateCalibration_)); + this->antitheticVariateCalibration_); mcModelCalibration_->addSamples(nCalibrationSamples_); pathPricer_->calibrate(); @@ -250,9 +247,8 @@ namespace QuantLib { TimeGrid grid = this->timeGrid(); typename RNG::rsg_type generator = RNG::make_sequence_generator(dimensions*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(process_, - grid, generator, brownianBridge_)); + return ext::make_shared(process_, + grid, generator, brownianBridge_); } } diff --git a/ql/pricingengines/mcsimulation.hpp b/ql/pricingengines/mcsimulation.hpp index 159655e1448..68db0bef073 100644 --- a/ql/pricingengines/mcsimulation.hpp +++ b/ql/pricingengines/mcsimulation.hpp @@ -181,17 +181,15 @@ namespace QuantLib { this->controlPathGenerator(); this->mcModel_ = - ext::shared_ptr >( - new MonteCarloModel( + ext::make_shared>( pathGenerator(), this->pathPricer(), stats_type(), this->antitheticVariate_, controlPP, - controlVariateValue, controlPG)); + controlVariateValue, controlPG); } else { this->mcModel_ = - ext::shared_ptr >( - new MonteCarloModel( + ext::make_shared>( pathGenerator(), this->pathPricer(), S(), - this->antitheticVariate_)); + this->antitheticVariate_); } if (requiredTolerance != Null()) { diff --git a/ql/pricingengines/quanto/quantoengine.hpp b/ql/pricingengines/quanto/quantoengine.hpp index cb3146d529e..8962893f5ff 100644 --- a/ql/pricingengines/quanto/quantoengine.hpp +++ b/ql/pricingengines/quanto/quantoengine.hpp @@ -99,22 +99,20 @@ namespace QuantLib { Handle riskFreeRate = process_->riskFreeRate(); // dividendTS needs modification Handle dividendYield( - ext::shared_ptr( - new QuantoTermStructure(process_->dividendYield(), + ext::make_shared(process_->dividendYield(), process_->riskFreeRate(), foreignRiskFreeRate_, process_->blackVolatility(), strike, exchangeRateVolatility_, exchangeRateATMlevel, - correlation_->value()))); + correlation_->value())); Handle blackVol = process_->blackVolatility(); - ext::shared_ptr quantoProcess( - new GeneralizedBlackScholesProcess(spot, dividendYield, - riskFreeRate, blackVol)); + auto quantoProcess = ext::make_shared(spot, dividendYield, + riskFreeRate, blackVol); - ext::shared_ptr originalEngine(new Engine(quantoProcess)); + auto originalEngine = ext::make_shared(quantoProcess); originalEngine->reset(); auto* originalArguments = dynamic_cast(originalEngine->getArguments()); diff --git a/ql/pricingengines/swaption/blackswaptionengine.hpp b/ql/pricingengines/swaption/blackswaptionengine.hpp index d9900324445..0626a190025 100644 --- a/ql/pricingengines/swaption/blackswaptionengine.hpp +++ b/ql/pricingengines/swaption/blackswaptionengine.hpp @@ -186,8 +186,8 @@ namespace QuantLib { Real displacement, CashAnnuityModel model) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr(new ConstantSwaptionVolatility( - 0, NullCalendar(), Following, vol, dc, Spec().type, displacement))), + vol_(ext::make_shared( + 0, NullCalendar(), Following, vol, dc, Spec().type, displacement)), model_(model) { registerWith(discountCurve_); } @@ -200,8 +200,8 @@ namespace QuantLib { Real displacement, CashAnnuityModel model) : discountCurve_(std::move(discountCurve)), - vol_(ext::shared_ptr(new ConstantSwaptionVolatility( - 0, NullCalendar(), Following, vol, dc, Spec().type, displacement))), + vol_(ext::make_shared( + 0, NullCalendar(), Following, vol, dc, Spec().type, displacement)), model_(model) { registerWith(discountCurve_); registerWith(vol_); diff --git a/ql/pricingengines/swaption/fdg2swaptionengine.cpp b/ql/pricingengines/swaption/fdg2swaptionengine.cpp index 4e38b6fc46c..fa873e5342e 100644 --- a/ql/pricingengines/swaption/fdg2swaptionengine.cpp +++ b/ql/pricingengines/swaption/fdg2swaptionengine.cpp @@ -57,20 +57,15 @@ namespace QuantLib { const Time maturity = dc.yearFraction(referenceDate, arguments_.exercise->lastDate()); - const ext::shared_ptr process1( - new OrnsteinUhlenbeckProcess(model_->a(), model_->sigma())); + const auto process1 = ext::make_shared(model_->a(), model_->sigma()); - const ext::shared_ptr process2( - new OrnsteinUhlenbeckProcess(model_->b(), model_->eta())); + const auto process2 = ext::make_shared(model_->b(), model_->eta()); - const ext::shared_ptr xMesher( - new FdmSimpleProcess1dMesher(xGrid_,process1,maturity,1,invEps_)); + const auto xMesher = ext::make_shared(xGrid_,process1,maturity,1,invEps_); - const ext::shared_ptr yMesher( - new FdmSimpleProcess1dMesher(yGrid_,process2,maturity,1,invEps_)); + const auto yMesher = ext::make_shared(yGrid_,process2,maturity,1,invEps_); - const ext::shared_ptr mesher( - new FdmMesherComposite(xMesher, yMesher)); + const auto mesher = ext::make_shared(xMesher, yMesher); // 3. Inner Value Calculator const std::vector& exerciseDates = arguments_.exercise->dates(); @@ -92,14 +87,12 @@ namespace QuantLib { QL_REQUIRE(fwdTs->referenceDate() == disTs->referenceDate(), "reference date of forward and discount curve must match"); - const ext::shared_ptr fwdModel( - new G2(fwdTs, model_->a(), model_->sigma(), - model_->b(), model_->eta(), model_->rho())); + const auto fwdModel = ext::make_shared(fwdTs, model_->a(), model_->sigma(), + model_->b(), model_->eta(), model_->rho()); - const ext::shared_ptr calculator( - new FdmAffineModelSwapInnerValue( + const auto calculator = ext::make_shared>( model_.currentLink(), fwdModel, - arguments_.swap, t2d, mesher, 0)); + arguments_.swap, t2d, mesher, 0); // 4. Step conditions const ext::shared_ptr conditions = diff --git a/ql/pricingengines/vanilla/analyticbsmhullwhiteengine.cpp b/ql/pricingengines/vanilla/analyticbsmhullwhiteengine.cpp index 156051e857e..ada6f4523e0 100644 --- a/ql/pricingengines/vanilla/analyticbsmhullwhiteengine.cpp +++ b/ql/pricingengines/vanilla/analyticbsmhullwhiteengine.cpp @@ -110,18 +110,15 @@ namespace QuantLib { } Handle volTS( - ext::shared_ptr( - new ShiftedBlackVolTermStructure(varianceOffset, - process_->blackVolatility()))); + ext::make_shared(varianceOffset, + process_->blackVolatility())); - ext::shared_ptr adjProcess( - new GeneralizedBlackScholesProcess(process_->stateVariable(), + auto adjProcess = ext::make_shared(process_->stateVariable(), process_->dividendYield(), process_->riskFreeRate(), - volTS)); + volTS); - ext::shared_ptr bsmEngine( - new AnalyticEuropeanEngine(adjProcess)); + auto bsmEngine = ext::make_shared(adjProcess); VanillaOption(payoff, exercise).setupArguments( bsmEngine->getArguments()); diff --git a/ql/pricingengines/vanilla/analytichestonengine.cpp b/ql/pricingengines/vanilla/analytichestonengine.cpp index fa5f5913ac4..dfe35a77bf4 100644 --- a/ql/pricingengines/vanilla/analytichestonengine.cpp +++ b/ql/pricingengines/vanilla/analytichestonengine.cpp @@ -887,88 +887,77 @@ namespace QuantLib { AnalyticHestonEngine::Integration::gaussLobatto( Real relTolerance, Real absTolerance, Size maxEvaluations, bool useConvergenceEstimate) { return Integration(GaussLobatto, - ext::shared_ptr( - new GaussLobattoIntegral(maxEvaluations, + ext::make_shared(maxEvaluations, absTolerance, relTolerance, - useConvergenceEstimate))); + useConvergenceEstimate)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::gaussKronrod(Real absTolerance, Size maxEvaluations) { return Integration(GaussKronrod, - ext::shared_ptr( - new GaussKronrodAdaptive(absTolerance, - maxEvaluations))); + ext::make_shared(absTolerance, + maxEvaluations)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::simpson(Real absTolerance, Size maxEvaluations) { return Integration(Simpson, - ext::shared_ptr( - new SimpsonIntegral(absTolerance, - maxEvaluations))); + ext::make_shared(absTolerance, + maxEvaluations)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::trapezoid(Real absTolerance, Size maxEvaluations) { return Integration(Trapezoid, - ext::shared_ptr( - new TrapezoidIntegral(absTolerance, - maxEvaluations))); + ext::make_shared>(absTolerance, + maxEvaluations)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::gaussLaguerre(Size intOrder) { QL_REQUIRE(intOrder <= 192, "maximum integraton order (192) exceeded"); return Integration(GaussLaguerre, - ext::shared_ptr( - new GaussLaguerreIntegration(intOrder))); + ext::make_shared(intOrder)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::gaussLegendre(Size intOrder) { return Integration(GaussLegendre, - ext::shared_ptr( - new GaussLegendreIntegration(intOrder))); + ext::make_shared(intOrder)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::gaussChebyshev(Size intOrder) { return Integration(GaussChebyshev, - ext::shared_ptr( - new GaussChebyshevIntegration(intOrder))); + ext::make_shared(intOrder)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::gaussChebyshev2nd(Size intOrder) { return Integration(GaussChebyshev2nd, - ext::shared_ptr( - new GaussChebyshev2ndIntegration(intOrder))); + ext::make_shared(intOrder)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::discreteSimpson(Size evaluations) { return Integration( - DiscreteSimpson, ext::shared_ptr( - new DiscreteSimpsonIntegrator(evaluations))); + DiscreteSimpson, ext::make_shared(evaluations)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::discreteTrapezoid(Size evaluations) { return Integration( - DiscreteTrapezoid, ext::shared_ptr( - new DiscreteTrapezoidIntegrator(evaluations))); + DiscreteTrapezoid, ext::make_shared(evaluations)); } AnalyticHestonEngine::Integration AnalyticHestonEngine::Integration::expSinh(Real relTolerance) { return Integration( - ExpSinh, ext::shared_ptr( - new ExpSinhIntegral(relTolerance))); + ExpSinh, ext::make_shared(relTolerance)); } Size AnalyticHestonEngine::Integration::numberOfEvaluations() const { diff --git a/ql/pricingengines/vanilla/binomialengine.hpp b/ql/pricingengines/vanilla/binomialengine.hpp index bd0715fed03..381b36dfba6 100644 --- a/ql/pricingengines/vanilla/binomialengine.hpp +++ b/ql/pricingengines/vanilla/binomialengine.hpp @@ -92,14 +92,11 @@ namespace QuantLib { // binomial trees with constant coefficient Handle flatRiskFree( - ext::shared_ptr( - new FlatForward(referenceDate, r, rfdc))); + ext::make_shared(referenceDate, r, rfdc)); Handle flatDividends( - ext::shared_ptr( - new FlatForward(referenceDate, q, divdc))); + ext::make_shared(referenceDate, q, divdc)); Handle flatVol( - ext::shared_ptr( - new BlackConstantVol(referenceDate, volcal, v, voldc))); + ext::make_shared(referenceDate, volcal, v, voldc)); ext::shared_ptr payoff = ext::dynamic_pointer_cast(arguments_.payoff); @@ -107,18 +104,16 @@ namespace QuantLib { Time maturity = rfdc.yearFraction(referenceDate, maturityDate); - ext::shared_ptr bs( - new GeneralizedBlackScholesProcess( + auto bs = ext::make_shared( process_->stateVariable(), - flatDividends, flatRiskFree, flatVol)); + flatDividends, flatRiskFree, flatVol); TimeGrid grid(maturity, timeSteps_); - ext::shared_ptr tree(new T(bs, maturity, timeSteps_, - payoff->strike())); + auto tree = ext::make_shared(bs, maturity, timeSteps_, + payoff->strike()); - ext::shared_ptr > lattice( - new BlackScholesLattice(tree, r, maturity, timeSteps_)); + auto lattice = ext::make_shared>(tree, r, maturity, timeSteps_); DiscretizedVanillaOption option(arguments_, *process_, grid); diff --git a/ql/pricingengines/vanilla/fdbatesvanillaengine.cpp b/ql/pricingengines/vanilla/fdbatesvanillaengine.cpp index 2026841fb81..2b12b4c70ae 100644 --- a/ql/pricingengines/vanilla/fdbatesvanillaengine.cpp +++ b/ql/pricingengines/vanilla/fdbatesvanillaengine.cpp @@ -69,9 +69,8 @@ namespace QuantLib { const ext::shared_ptr process = ext::dynamic_pointer_cast(model_->process()); - ext::shared_ptr solver( - new FdmBatesSolver(Handle(process), - solverDesc, schemeDesc_)); + auto solver = ext::make_shared(Handle(process), + solverDesc, schemeDesc_); const Real v0 = process->v0(); const Real spot = process->s0()->value(); diff --git a/ql/pricingengines/vanilla/fdcirvanillaengine.cpp b/ql/pricingengines/vanilla/fdcirvanillaengine.cpp index e663cbf0c10..de066f56bc9 100644 --- a/ql/pricingengines/vanilla/fdcirvanillaengine.cpp +++ b/ql/pricingengines/vanilla/fdcirvanillaengine.cpp @@ -70,24 +70,20 @@ namespace QuantLib { const Time maturity = bsProcess_->time(arguments_.exercise->lastDate()); // The short rate mesher - const ext::shared_ptr shortRateMesher( - new FdmSimpleProcess1dMesher(rGrid_, cirProcess_, maturity, tGrid_)); + const auto shortRateMesher = ext::make_shared(rGrid_, cirProcess_, maturity, tGrid_); // The equity mesher - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher( + const auto equityMesher = ext::make_shared( xGrid_, bsProcess_, maturity, payoff->strike(), Null(), Null(), 0.0001, 1.5, std::pair(payoff->strike(), 0.1), dividends_, quantoHelper_, - 0.0)); + 0.0); - const ext::shared_ptr mesher( - new FdmMesherComposite(equityMesher, shortRateMesher)); + const auto mesher = ext::make_shared(equityMesher, shortRateMesher); // Calculator - const ext::shared_ptr calculator( - new FdmLogInnerValue(arguments_.payoff, mesher, 0)); + const auto calculator = ext::make_shared(arguments_.payoff, mesher, 0); // Step conditions const ext::shared_ptr conditions = @@ -112,11 +108,11 @@ namespace QuantLib { const ext::shared_ptr payoff = ext::dynamic_pointer_cast(arguments_.payoff); - ext::shared_ptr solver(new FdmCIRSolver( + auto solver = ext::make_shared( Handle(cirProcess_), Handle(bsProcess_), getSolverDesc(1.5), schemeDesc_, - rho_, payoff->strike())); + rho_, payoff->strike()); const Real r0 = cirProcess_->x0(); const Real spot = bsProcess_->x0(); diff --git a/ql/pricingengines/vanilla/fdhestonhullwhitevanillaengine.cpp b/ql/pricingengines/vanilla/fdhestonhullwhitevanillaengine.cpp index 56b0d909e05..4ee1f2d0007 100644 --- a/ql/pricingengines/vanilla/fdhestonhullwhitevanillaengine.cpp +++ b/ql/pricingengines/vanilla/fdhestonhullwhitevanillaengine.cpp @@ -100,9 +100,8 @@ namespace QuantLib { // 2.1 The variance mesher const Size tGridMin = 5; - const ext::shared_ptr varianceMesher( - new FdmHestonVarianceMesher(vGrid_, hestonProcess, - maturity,std::max(tGridMin,tGrid_/50))); + const auto varianceMesher = ext::make_shared(vGrid_, hestonProcess, + maturity,std::max(tGridMin,tGrid_/50)); // 2.2 The equity mesher const ext::shared_ptr payoff = @@ -111,8 +110,7 @@ namespace QuantLib { ext::shared_ptr equityMesher; if (strikes_.empty()) { - equityMesher = ext::shared_ptr( - new FdmBlackScholesMesher( + equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( hestonProcess->s0(), hestonProcess->dividendYield(), @@ -121,35 +119,30 @@ namespace QuantLib { maturity, payoff->strike(), Null(), Null(), 0.0001, 1.5, std::pair(payoff->strike(), 0.1), - dividends_)); + dividends_); } else { QL_REQUIRE(dividends_.empty(), "multiple strikes engine does not work with discrete dividends"); - equityMesher = ext::shared_ptr( - new FdmBlackScholesMultiStrikeMesher( + equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( hestonProcess->s0(), hestonProcess->dividendYield(), hestonProcess->riskFreeRate(), varianceMesher->volaEstimate()), maturity, strikes_, 0.0001, 1.5, - std::pair(payoff->strike(), 0.075))); + std::pair(payoff->strike(), 0.075)); } //2.3 The short rate mesher - const ext::shared_ptr ouProcess( - new OrnsteinUhlenbeckProcess(hwProcess_->a(),hwProcess_->sigma())); - const ext::shared_ptr shortRateMesher( - new FdmSimpleProcess1dMesher(rGrid_, ouProcess, maturity)); + const auto ouProcess = ext::make_shared(hwProcess_->a(),hwProcess_->sigma()); + const auto shortRateMesher = ext::make_shared(rGrid_, ouProcess, maturity); - const ext::shared_ptr mesher( - new FdmMesherComposite(equityMesher, varianceMesher, - shortRateMesher)); + const auto mesher = ext::make_shared(equityMesher, varianceMesher, + shortRateMesher); // 3. Calculator - const ext::shared_ptr calculator( - new FdmLogInnerValue(arguments_.payoff, mesher, 0)); + const auto calculator = ext::make_shared(arguments_.payoff, mesher, 0); // 4. Step conditions const ext::shared_ptr conditions = @@ -167,11 +160,10 @@ namespace QuantLib { calculator, maturity, tGrid_, dampingSteps_ }; - const ext::shared_ptr solver( - new FdmHestonHullWhiteSolver(Handle(hestonProcess), + const auto solver = ext::make_shared(Handle(hestonProcess), Handle(hwProcess_), corrEquityShortRate_, - solverDesc, schemeDesc_)); + solverDesc, schemeDesc_); const Real spot = hestonProcess->s0()->value(); const Real v0 = hestonProcess->v0(); @@ -196,19 +188,16 @@ namespace QuantLib { } if (controlVariate_) { - ext::shared_ptr analyticEngine( - new AnalyticHestonEngine(*model_, 164)); - ext::shared_ptr exercise( - new EuropeanExercise(arguments_.exercise->lastDate())); + auto analyticEngine = ext::make_shared(*model_, 164); + auto exercise = ext::make_shared(arguments_.exercise->lastDate()); VanillaOption option(payoff, exercise); option.setPricingEngine(analyticEngine); Real analyticNPV = option.NPV(); - ext::shared_ptr fdEngine( - new FdHestonVanillaEngine(*model_, tGrid_, xGrid_, + auto fdEngine = ext::make_shared(*model_, tGrid_, xGrid_, vGrid_, dampingSteps_, - schemeDesc_)); + schemeDesc_); fdEngine->enableMultipleStrikesCaching(strikes_); option.setPricingEngine(fdEngine); @@ -216,9 +205,8 @@ namespace QuantLib { results_.value += analyticNPV - fdNPV; for (Size i=0; i < strikes_.size(); ++i) { VanillaOption controlVariateOption( - ext::shared_ptr( - new PlainVanillaPayoff(payoff->optionType(), - strikes_[i])), exercise); + ext::make_shared(payoff->optionType(), + strikes_[i]), exercise); controlVariateOption.setPricingEngine(analyticEngine); analyticNPV = controlVariateOption.NPV(); diff --git a/ql/pricingengines/vanilla/fdhestonvanillaengine.cpp b/ql/pricingengines/vanilla/fdhestonvanillaengine.cpp index 2c920913afb..780b6856d3e 100644 --- a/ql/pricingengines/vanilla/fdhestonvanillaengine.cpp +++ b/ql/pricingengines/vanilla/fdhestonvanillaengine.cpp @@ -109,8 +109,7 @@ namespace QuantLib { // 1.1 The variance mesher const Size tGridMin = 5; const Size tGridAvgSteps = std::max(tGridMin, tGrid_/50); - const ext::shared_ptr vMesher - = ext::make_shared( + const auto vMesher = ext::make_shared( vGrid_, process, leverageFct_, maturity, tGridAvgSteps, 0.0001, mixingFactor_); const Volatility avgVolaEstimate = vMesher->volaEstimate(); @@ -121,8 +120,7 @@ namespace QuantLib { ext::shared_ptr equityMesher; if (strikes_.empty()) { - equityMesher = ext::shared_ptr( - new FdmBlackScholesMesher( + equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( process->s0(), process->dividendYield(), @@ -131,27 +129,24 @@ namespace QuantLib { Null(), Null(), 0.0001, 2.0, std::pair(payoff->strike(), 0.1), dividends_, - quantoHelper_)); + quantoHelper_); } else { QL_REQUIRE(dividends_.empty(), "multiple strikes engine does not work with discrete dividends"); - equityMesher = ext::shared_ptr( - new FdmBlackScholesMultiStrikeMesher( + equityMesher = ext::make_shared( xGrid_, FdmBlackScholesMesher::processHelper( process->s0(), process->dividendYield(), process->riskFreeRate(), avgVolaEstimate), maturity, strikes_, 0.0001, 1.5, - std::pair(payoff->strike(), 0.075))); + std::pair(payoff->strike(), 0.075)); } - const ext::shared_ptr mesher( - new FdmMesherComposite(equityMesher, vMesher)); + const auto mesher = ext::make_shared(equityMesher, vMesher); // 2. Calculator - const ext::shared_ptr calculator( - new FdmLogInnerValue(arguments_.payoff, mesher, 0)); + const auto calculator = ext::make_shared(arguments_.payoff, mesher, 0); // 3. Step conditions const ext::shared_ptr conditions = @@ -196,11 +191,11 @@ namespace QuantLib { const ext::shared_ptr process = model_->process(); - ext::shared_ptr solver(new FdmHestonSolver( + auto solver = ext::make_shared( Handle(process), getSolverDesc(1.5), schemeDesc_, Handle(quantoHelper_), leverageFct_, - mixingFactor_)); + mixingFactor_); const Real v0 = process->v0(); const Real spot = process->s0()->value(); diff --git a/ql/pricingengines/vanilla/fdsimplebsswingengine.cpp b/ql/pricingengines/vanilla/fdsimplebsswingengine.cpp index c1e16a3a3cb..f95ddc3f2d4 100644 --- a/ql/pricingengines/vanilla/fdsimplebsswingengine.cpp +++ b/ql/pricingengines/vanilla/fdsimplebsswingengine.cpp @@ -52,21 +52,17 @@ namespace QuantLib { QL_REQUIRE(payoff, "Strike type payoff expected"); const Time maturity = process_->time(arguments_.exercise->lastDate()); - const ext::shared_ptr equityMesher( - new FdmBlackScholesMesher(xGrid_, process_, - maturity, payoff->strike())); + const auto equityMesher = ext::make_shared(xGrid_, process_, + maturity, payoff->strike()); - const ext::shared_ptr exerciseMesher( - new Uniform1dMesher( + const auto exerciseMesher = ext::make_shared( 0, static_cast(arguments_.maxExerciseRights), - arguments_.maxExerciseRights+1)); + arguments_.maxExerciseRights+1); - const ext::shared_ptr mesher ( - new FdmMesherComposite(equityMesher, exerciseMesher)); + const auto mesher = ext::make_shared(equityMesher, exerciseMesher); // 2. Calculator - ext::shared_ptr calculator( - new FdmZeroInnerValue()); + auto calculator = ext::make_shared(); // 3. Step conditions std::list > > stepConditions; @@ -81,16 +77,13 @@ namespace QuantLib { } stoppingTimes.push_back(exerciseTimes); - ext::shared_ptr exerciseCalculator( - new FdmLogInnerValue(payoff, mesher, 0)); + auto exerciseCalculator = ext::make_shared(payoff, mesher, 0); - stepConditions.push_back(ext::shared_ptr >( - new FdmSimpleSwingCondition( + stepConditions.push_back(ext::make_shared( exerciseTimes, mesher, exerciseCalculator, - 1, arguments_.minExerciseRights))); + 1, arguments_.minExerciseRights)); - ext::shared_ptr conditions( - new FdmStepConditionComposite(stoppingTimes, stepConditions)); + auto conditions = ext::make_shared(stoppingTimes, stepConditions); // 4. Boundary conditions const FdmBoundaryConditionSet boundaries; @@ -98,10 +91,9 @@ namespace QuantLib { // 5. Solver FdmSolverDesc solverDesc = { mesher, boundaries, conditions, calculator, maturity, tGrid_, 0 }; - ext::shared_ptr solver( - new FdmSimple2dBSSolver( + auto solver = ext::make_shared( Handle(process_), - payoff->strike(), solverDesc, schemeDesc_)); + payoff->strike(), solverDesc, schemeDesc_); const Real spot = process_->x0(); diff --git a/ql/pricingengines/vanilla/jumpdiffusionengine.cpp b/ql/pricingengines/vanilla/jumpdiffusionengine.cpp index 0ceba846dcc..f898c4bdd6a 100644 --- a/ql/pricingengines/vanilla/jumpdiffusionengine.cpp +++ b/ql/pricingengines/vanilla/jumpdiffusionengine.cpp @@ -75,9 +75,8 @@ namespace QuantLib { RelinkableHandle volTS( *process_->blackVolatility()); - ext::shared_ptr bsProcess( - new GeneralizedBlackScholesProcess(stateVariable, dividendTS, - riskFreeTS, volTS)); + auto bsProcess = ext::make_shared(stateVariable, dividendTS, + riskFreeTS, volTS); AnalyticEuropeanEngine baseEngine(bsProcess); @@ -111,10 +110,8 @@ namespace QuantLib { v = std::sqrt((variance + i*jumpSquareVol)/t); r = riskFreeRate - process_->jumpIntensity()->value()*k + i*muPlusHalfSquareVol/t; - riskFreeTS.linkTo(ext::shared_ptr(new - FlatForward(rateRefDate, r, voldc))); - volTS.linkTo(ext::shared_ptr(new - BlackConstantVol(rateRefDate, volcal, v, voldc))); + riskFreeTS.linkTo(ext::make_shared(rateRefDate, r, voldc)); + volTS.linkTo(ext::make_shared(rateRefDate, volcal, v, voldc)); baseArguments->validate(); baseEngine.calculate(); diff --git a/ql/pricingengines/vanilla/mcamericanengine.hpp b/ql/pricingengines/vanilla/mcamericanengine.hpp index fc06574b1f2..5ea7f7ff0be 100644 --- a/ql/pricingengines/vanilla/mcamericanengine.hpp +++ b/ql/pricingengines/vanilla/mcamericanengine.hpp @@ -197,9 +197,8 @@ namespace QuantLib { QL_REQUIRE(!exercise->payoffAtExpiry(), "payoff at expiry not handled"); - ext::shared_ptr earlyExercisePathPricer( - new AmericanPathPricer(this->arguments_.payoff, - polynomialOrder_, polynomialType_)); + auto earlyExercisePathPricer = ext::make_shared(this->arguments_.payoff, + polynomialOrder_, polynomialType_); return ext::make_shared > ( @@ -221,12 +220,10 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "generalized Black-Scholes process required"); - return ext::shared_ptr >( - new EuropeanPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), - process->riskFreeRate()->discount(this->timeGrid().back())) - ); + process->riskFreeRate()->discount(this->timeGrid().back())); } template @@ -237,8 +234,7 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "generalized Black-Scholes process required"); - return ext::shared_ptr( - new AnalyticEuropeanEngine(process)); + return ext::make_shared(process); } template @@ -253,8 +249,7 @@ namespace QuantLib { auto* controlArguments = dynamic_cast(controlPE->getArguments()); *controlArguments = this->arguments_; - controlArguments->exercise = ext::shared_ptr( - new EuropeanExercise(this->arguments_.exercise->lastDate())); + controlArguments->exercise = ext::make_shared(this->arguments_.exercise->lastDate()); controlPE->calculate(); @@ -382,8 +377,7 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCAmericanEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, antithetic_, @@ -395,7 +389,7 @@ namespace QuantLib { polynomialType_, calibrationSamples_, antitheticCalibration_, - seedCalibration_)); + seedCalibration_); } } diff --git a/ql/pricingengines/vanilla/mcdigitalengine.hpp b/ql/pricingengines/vanilla/mcdigitalengine.hpp index 9302e5a0732..5596137739e 100644 --- a/ql/pricingengines/vanilla/mcdigitalengine.hpp +++ b/ql/pricingengines/vanilla/mcdigitalengine.hpp @@ -176,13 +176,11 @@ namespace QuantLib { PseudoRandom::ursg_type sequenceGen(grid.size()-1, PseudoRandom::urng_type(76)); - return ext::shared_ptr< - typename MCDigitalEngine::path_pricer_type>( - new DigitalPathPricer(payoff, + return ext::make_shared(payoff, exercise, process->riskFreeRate(), process, - sequenceGen)); + sequenceGen); } @@ -263,15 +261,14 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCDigitalEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/vanilla/mceuropeanengine.hpp b/ql/pricingengines/vanilla/mceuropeanengine.hpp index fe9e5ae9db0..4aa0c646c51 100644 --- a/ql/pricingengines/vanilla/mceuropeanengine.hpp +++ b/ql/pricingengines/vanilla/mceuropeanengine.hpp @@ -144,12 +144,10 @@ namespace QuantLib { this->process_); QL_REQUIRE(process, "Black-Scholes process required"); - return ext::shared_ptr< - typename MCEuropeanEngine::path_pricer_type>( - new EuropeanPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), - process->riskFreeRate()->discount(this->timeGrid().back()))); + process->riskFreeRate()->discount(this->timeGrid().back())); } @@ -230,15 +228,14 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCEuropeanEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, brownianBridge_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } diff --git a/ql/pricingengines/vanilla/mceuropeangjrgarchengine.hpp b/ql/pricingengines/vanilla/mceuropeangjrgarchengine.hpp index d51c04d4be4..8ad8d2a0b58 100644 --- a/ql/pricingengines/vanilla/mceuropeangjrgarchengine.hpp +++ b/ql/pricingengines/vanilla/mceuropeangjrgarchengine.hpp @@ -119,13 +119,11 @@ namespace QuantLib { ext::dynamic_pointer_cast(this->process_); QL_REQUIRE(process, "GJRGARCH process required"); - return ext::shared_ptr< - typename MCEuropeanGJRGARCHEngine::path_pricer_type>( - new EuropeanGJRGARCHPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount( - this->timeGrid().back()))); + this->timeGrid().back())); } @@ -201,14 +199,13 @@ namespace QuantLib { operator ext::shared_ptr() const { QL_REQUIRE(steps_ != Null() || stepsPerYear_ != Null(), "number of steps not given"); - return ext::shared_ptr( - new MCEuropeanGJRGARCHEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } diff --git a/ql/pricingengines/vanilla/mceuropeanhestonengine.hpp b/ql/pricingengines/vanilla/mceuropeanhestonengine.hpp index ac661640ef2..f32a946f32f 100644 --- a/ql/pricingengines/vanilla/mceuropeanhestonengine.hpp +++ b/ql/pricingengines/vanilla/mceuropeanhestonengine.hpp @@ -122,13 +122,11 @@ namespace QuantLib { ext::dynamic_pointer_cast

(this->process_); QL_REQUIRE(process, "Heston like process required"); - return ext::shared_ptr< - typename MCEuropeanHestonEngine::path_pricer_type>( - new EuropeanHestonPathPricer( + return ext::make_shared( payoff->optionType(), payoff->strike(), process->riskFreeRate()->discount( - this->timeGrid().back()))); + this->timeGrid().back())); } @@ -204,14 +202,13 @@ namespace QuantLib { operator ext::shared_ptr() const { QL_REQUIRE(steps_ != Null() || stepsPerYear_ != Null(), "number of steps not given"); - return ext::shared_ptr( - new MCEuropeanHestonEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, antithetic_, samples_, tolerance_, maxSamples_, - seed_)); + seed_); } diff --git a/ql/pricingengines/vanilla/mchestonhullwhiteengine.hpp b/ql/pricingengines/vanilla/mchestonhullwhiteengine.hpp index 058aa18046a..e8575382bbd 100644 --- a/ql/pricingengines/vanilla/mchestonhullwhiteengine.hpp +++ b/ql/pricingengines/vanilla/mchestonhullwhiteengine.hpp @@ -146,10 +146,9 @@ namespace QuantLib { const Time exerciseTime = process_->time(exercise->lastDate()); - return ext::shared_ptr( - new HestonHullWhitePathPricer(exerciseTime, + return ext::make_shared(exerciseTime, this->arguments_.payoff, - process_)); + process_); } template inline @@ -170,11 +169,10 @@ namespace QuantLib { const Time exerciseTime = process_->time(exercise->lastDate()); - return ext::shared_ptr( - new HestonHullWhitePathPricer( + return ext::make_shared( exerciseTime, this->arguments_.payoff, - process_) ); + process_); } template inline @@ -187,15 +185,12 @@ namespace QuantLib { ext::shared_ptr hullWhiteProcess = process_->hullWhiteProcess(); - ext::shared_ptr hestonModel( - new HestonModel(hestonProcess)); - ext::shared_ptr hwModel( - new HullWhite(hestonProcess->riskFreeRate(), + auto hestonModel = ext::make_shared(hestonProcess); + auto hwModel = ext::make_shared(hestonProcess->riskFreeRate(), hullWhiteProcess->a(), - hullWhiteProcess->sigma())); + hullWhiteProcess->sigma()); - return ext::shared_ptr( - new AnalyticHestonHullWhiteEngine(hestonModel, hwModel, 144)); + return ext::make_shared(hestonModel, hwModel, 144); } template inline @@ -209,14 +204,12 @@ namespace QuantLib { RNG::make_sequence_generator(dimensions*(grid.size()-1), this->seed_); - ext::shared_ptr cvProcess( - new HybridHestonHullWhiteProcess(process_->hestonProcess(), + auto cvProcess = ext::make_shared(process_->hestonProcess(), process_->hullWhiteProcess(), 0.0, - process_->discretization())); + process_->discretization()); - return ext::shared_ptr( - new path_generator_type(cvProcess, grid, generator, false)); + return ext::make_shared(cvProcess, grid, generator, false); } @@ -297,8 +290,7 @@ namespace QuantLib { "number of steps not given"); QL_REQUIRE(steps_ == Null() || stepsPerYear_ == Null(), "number of steps overspecified"); - return ext::shared_ptr(new - MCHestonHullWhiteEngine(process_, + return ext::make_shared>(process_, steps_, stepsPerYear_, antithetic_, @@ -306,7 +298,7 @@ namespace QuantLib { samples_, tolerance_, maxSamples_, - seed_)); + seed_); } } diff --git a/ql/pricingengines/vanilla/mcvanillaengine.hpp b/ql/pricingengines/vanilla/mcvanillaengine.hpp index d500065f671..411a5d36cd7 100644 --- a/ql/pricingengines/vanilla/mcvanillaengine.hpp +++ b/ql/pricingengines/vanilla/mcvanillaengine.hpp @@ -75,9 +75,8 @@ namespace QuantLib { TimeGrid grid = this->timeGrid(); typename RNG::rsg_type generator = RNG::make_sequence_generator(dimensions*(grid.size()-1),seed_); - return ext::shared_ptr( - new path_generator_type(process_, grid, - generator, brownianBridge_)); + return ext::make_shared(process_, grid, + generator, brownianBridge_); } result_type controlVariateValue() const override; // data members diff --git a/ql/pricingengines/vanilla/qdfpamericanengine.cpp b/ql/pricingengines/vanilla/qdfpamericanengine.cpp index ebf1618a534..2d70e2a60ed 100644 --- a/ql/pricingengines/vanilla/qdfpamericanengine.cpp +++ b/ql/pricingengines/vanilla/qdfpamericanengine.cpp @@ -452,15 +452,16 @@ namespace QuantLib { return squared(std::log(fv/xmax)); }; - const ext::shared_ptr eqn - = (fpEquation_ == FP_A + const auto eqn = (fpEquation_ == FP_A || (fpEquation_ == Auto && std::abs(r-q) < 0.001))? - ext::shared_ptr(new DqFpEquation_A( - K, r, q, vol, B, - iterationScheme_->getFixedPointIntegrator())) - : ext::shared_ptr(new DqFpEquation_B( - K, r, q, vol, B, - iterationScheme_->getFixedPointIntegrator())); + ext::static_pointer_cast( + ext::make_shared( + K, r, q, vol, B, + iterationScheme_->getFixedPointIntegrator())) + : ext::static_pointer_cast( + ext::make_shared( + K, r, q, vol, B, + iterationScheme_->getFixedPointIntegrator())); Array y(x.size()); y[0] = 0.0; @@ -518,5 +519,3 @@ namespace QuantLib { } - -