Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 11 additions & 18 deletions ql/pricingengines/asian/fdblackscholesasianengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -57,9 +57,8 @@ namespace QuantLib {
const ext::shared_ptr<StrikedTypePayoff> payoff =
ext::dynamic_pointer_cast<StrikedTypePayoff>(arguments_.payoff);
const Time maturity = process_->time(arguments_.exercise->lastDate());
const ext::shared_ptr<Fdm1dMesher> equityMesher(
new FdmBlackScholesMesher(xGrid_, process_, maturity,
payoff->strike()));
const auto equityMesher = ext::make_shared<FdmBlackScholesMesher>(xGrid_, process_, maturity,
payoff->strike());

const Real spot = process_->x0();
QL_REQUIRE(spot > 0.0, "negative or null underlying given");
Expand All @@ -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<Fdm1dMesher> averageMesher(
new FdmBlackScholesMesher(aGrid_, process_, maturity,
payoff->strike(), xMin, xMax));
const auto averageMesher = ext::make_shared<FdmBlackScholesMesher>(aGrid_, process_, maturity,
payoff->strike(), xMin, xMax);

const ext::shared_ptr<FdmMesher> mesher (
new FdmMesherComposite(equityMesher, averageMesher));
const auto mesher = ext::make_shared<FdmMesherComposite>(equityMesher, averageMesher);

// 2. Calculator
ext::shared_ptr<FdmInnerValueCalculator> calculator(
new FdmLogInnerValue(payoff, mesher, 1));
auto calculator = ext::make_shared<FdmLogInnerValue>(payoff, mesher, 1);

// 3. Step conditions
std::list<ext::shared_ptr<StepCondition<Array> > > stepConditions;
Expand All @@ -99,24 +95,21 @@ namespace QuantLib {
averageTimes.push_back(t);
}
stoppingTimes.emplace_back(averageTimes);
stepConditions.push_back(ext::shared_ptr<StepCondition<Array> >(
new FdmArithmeticAverageCondition(
stepConditions.push_back(ext::make_shared<FdmArithmeticAverageCondition>(
averageTimes, arguments_.runningAccumulator,
arguments_.pastFixings, mesher, 0)));
arguments_.pastFixings, mesher, 0));

ext::shared_ptr<FdmStepConditionComposite> conditions(
new FdmStepConditionComposite(stoppingTimes, stepConditions));
auto conditions = ext::make_shared<FdmStepConditionComposite>(stoppingTimes, stepConditions);

// 4. Boundary conditions
const FdmBoundaryConditionSet boundaries;

// 5. Solver
FdmSolverDesc solverDesc = { mesher, boundaries, conditions,
calculator, maturity, tGrid_, 0 };
ext::shared_ptr<FdmSimple2dBSSolver> solver(
new FdmSimple2dBSSolver(
auto solver = ext::make_shared<FdmSimple2dBSSolver>(
Handle<GeneralizedBlackScholesProcess>(process_),
payoff->strike(), solverDesc, schemeDesc_));
payoff->strike(), solverDesc, schemeDesc_);

results_.value = solver->valueAt(spot, avg);
results_.delta = solver->deltaAt(spot, avg, spot*0.01);
Expand Down
20 changes: 7 additions & 13 deletions ql/pricingengines/asian/mc_discr_arith_av_price.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,7 @@ namespace QuantLib {
ext::dynamic_pointer_cast<GeneralizedBlackScholesProcess>(
this->process_);
QL_REQUIRE(process, "Black-Scholes process required");
return ext::shared_ptr<PricingEngine>(new
AnalyticDiscreteGeometricAveragePriceAsianEngine(process));
return ext::make_shared<AnalyticDiscreteGeometricAveragePriceAsianEngine>(process);
}
};

Expand Down Expand Up @@ -141,14 +140,12 @@ namespace QuantLib {
this->process_);
QL_REQUIRE(process, "Black-Scholes process required");

return ext::shared_ptr<typename
MCDiscreteArithmeticAPEngine<RNG,S>::path_pricer_type>(
new ArithmeticAPOPathPricer(
return ext::make_shared<ArithmeticAPOPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(exercise->lastDate()),
this->arguments_.runningAccumulator,
this->arguments_.pastFixings));
this->arguments_.pastFixings);
}

template <class RNG, class S>
Expand All @@ -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<typename
MCDiscreteArithmeticAPEngine<RNG,S>::path_pricer_type>(
new GeometricAPOPathPricer(
return ext::make_shared<GeometricAPOPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(this->timeGrid().back())));
process->riskFreeRate()->discount(this->timeGrid().back()));
}

template <class RNG = PseudoRandom, class S = Statistics>
Expand Down Expand Up @@ -274,13 +269,12 @@ namespace QuantLib {
inline
MakeMCDiscreteArithmeticAPEngine<RNG,S>::operator ext::shared_ptr<PricingEngine>()
const {
return ext::shared_ptr<PricingEngine>(new
MCDiscreteArithmeticAPEngine<RNG,S>(process_,
return ext::make_shared<MCDiscreteArithmeticAPEngine<RNG,S>>(process_,
brownianBridge_,
antithetic_, controlVariate_,
samples_, tolerance_,
maxSamples_,
seed_));
seed_);
}


Expand Down
20 changes: 7 additions & 13 deletions ql/pricingengines/asian/mc_discr_arith_av_price_heston.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,7 @@ namespace QuantLib {
ext::shared_ptr<P> process = ext::dynamic_pointer_cast<P>(this->process_);
QL_REQUIRE(process, "Heston-like process required");

return ext::shared_ptr<PricingEngine>(new
AnalyticDiscreteGeometricAveragePriceAsianHestonEngine(process));
return ext::make_shared<AnalyticDiscreteGeometricAveragePriceAsianHestonEngine>(process);
}
};

Expand Down Expand Up @@ -180,15 +179,13 @@ namespace QuantLib {
ext::dynamic_pointer_cast<P>(this->process_);
QL_REQUIRE(process, "Heston like process required");

return ext::shared_ptr<typename
MCDiscreteArithmeticAPHestonEngine<RNG,S,P>::path_pricer_type>(
new ArithmeticAPOHestonPathPricer(
return ext::make_shared<ArithmeticAPOHestonPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(exercise->lastDate()),
fixingIndexes,
this->arguments_.runningAccumulator,
this->arguments_.pastFixings));
this->arguments_.pastFixings);
}

template <class RNG, class S, class P>
Expand Down Expand Up @@ -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<typename
MCDiscreteArithmeticAPHestonEngine<RNG,S,P>::path_pricer_type>(
new GeometricAPOHestonPathPricer(
return ext::make_shared<GeometricAPOHestonPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(exercise->lastDate()),
fixingIndexes));
fixingIndexes);
}

template <class RNG, class S, class P>
Expand Down Expand Up @@ -309,16 +304,15 @@ namespace QuantLib {

template <class RNG, class S, class P>
inline MakeMCDiscreteArithmeticAPHestonEngine<RNG,S,P>::operator ext::shared_ptr<PricingEngine>() const {
return ext::shared_ptr<PricingEngine>(new
MCDiscreteArithmeticAPHestonEngine<RNG,S,P>(process_,
return ext::make_shared<MCDiscreteArithmeticAPHestonEngine<RNG,S,P>>(process_,
antithetic_,
samples_,
tolerance_,
maxSamples_,
seed_,
steps_,
stepsPerYear_,
controlVariate_));
controlVariate_);
}
}

Expand Down
11 changes: 4 additions & 7 deletions ql/pricingengines/asian/mc_discr_arith_av_strike.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -143,14 +143,12 @@ namespace QuantLib {
}
}

return ext::shared_ptr<typename
MCDiscreteArithmeticASEngine<RNG,S>::path_pricer_type>(
new ArithmeticASOPathPricer(
return ext::make_shared<ArithmeticASOPathPricer>(
payoff->optionType(),
process->riskFreeRate()->discount(exercise->lastDate()),
this->arguments_.runningAccumulator,
this->arguments_.pastFixings,
fixingCount));
fixingCount);
}


Expand Down Expand Up @@ -238,13 +236,12 @@ namespace QuantLib {
inline
MakeMCDiscreteArithmeticASEngine<RNG,S>::
operator ext::shared_ptr<PricingEngine>() const {
return ext::shared_ptr<PricingEngine>(
new MCDiscreteArithmeticASEngine<RNG,S>(process_,
return ext::make_shared<MCDiscreteArithmeticASEngine<RNG,S>>(process_,
brownianBridge_,
antithetic_,
samples_, tolerance_,
maxSamples_,
seed_));
seed_);
}

}
Expand Down
11 changes: 4 additions & 7 deletions ql/pricingengines/asian/mc_discr_geom_av_price.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -128,14 +128,12 @@ namespace QuantLib {
this->process_);
QL_REQUIRE(process, "Black-Scholes process required");

return ext::shared_ptr<typename
MCDiscreteGeometricAPEngine<RNG,S>::path_pricer_type>(
new GeometricAPOPathPricer(
return ext::make_shared<GeometricAPOPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(exercise->lastDate()),
this->arguments_.runningAccumulator,
this->arguments_.pastFixings));
this->arguments_.pastFixings);
}


Expand Down Expand Up @@ -222,13 +220,12 @@ namespace QuantLib {
inline
MakeMCDiscreteGeometricAPEngine<RNG,S>::operator ext::shared_ptr<PricingEngine>()
const {
return ext::shared_ptr<PricingEngine>(new
MCDiscreteGeometricAPEngine<RNG,S>(process_,
return ext::make_shared<MCDiscreteGeometricAPEngine<RNG,S>>(process_,
brownianBridge_,
antithetic_,
samples_, tolerance_,
maxSamples_,
seed_));
seed_);
}

}
Expand Down
11 changes: 4 additions & 7 deletions ql/pricingengines/asian/mc_discr_geom_av_price_heston.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -162,15 +162,13 @@ namespace QuantLib {
ext::dynamic_pointer_cast<P>(this->process_);
QL_REQUIRE(process, "Heston like process required");

return ext::shared_ptr<typename
MCDiscreteGeometricAPHestonEngine<RNG,S,P>::path_pricer_type>(
new GeometricAPOHestonPathPricer(
return ext::make_shared<GeometricAPOHestonPathPricer>(
payoff->optionType(),
payoff->strike(),
process->riskFreeRate()->discount(exercise->lastDate()),
fixingIndexes,
this->arguments_.runningAccumulator,
this->arguments_.pastFixings));
this->arguments_.pastFixings);
}

template <class RNG, class S, class P>
Expand Down Expand Up @@ -242,15 +240,14 @@ namespace QuantLib {

template <class RNG, class S, class P>
inline MakeMCDiscreteGeometricAPHestonEngine<RNG,S,P>::operator ext::shared_ptr<PricingEngine>() const {
return ext::shared_ptr<PricingEngine>(new
MCDiscreteGeometricAPHestonEngine<RNG,S,P>(process_,
return ext::make_shared<MCDiscreteGeometricAPHestonEngine<RNG,S,P>>(process_,
antithetic_,
samples_,
tolerance_,
maxSamples_,
seed_,
steps_,
stepsPerYear_));
stepsPerYear_);
}
}

Expand Down
5 changes: 2 additions & 3 deletions ql/pricingengines/asian/mcdiscreteasianenginebase.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<path_generator_type>(
new path_generator_type(process_, grid,
gen, brownianBridge_));
return ext::make_shared<path_generator_type>(process_, grid,
gen, brownianBridge_);
}
Real controlVariateValue() const override;
// data members
Expand Down
2 changes: 1 addition & 1 deletion ql/pricingengines/bacheliercalculator.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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<StrikedTypePayoff>(new PlainVanillaPayoff(optionType, strike)));
initialize(ext::make_shared<PlainVanillaPayoff>(optionType, strike));
}

void BachelierCalculator::initialize(const ext::shared_ptr<StrikedTypePayoff>& p) {
Expand Down
8 changes: 3 additions & 5 deletions ql/pricingengines/barrier/analyticbinarybarrierengine.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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> exercise(new EuropeanExercise(
arguments_.exercise->lastDate()));
auto exercise = ext::make_shared<EuropeanExercise>(
arguments_.exercise->lastDate());

ext::shared_ptr<PricingEngine> engine(
new AnalyticEuropeanEngine(process_));
auto engine = ext::make_shared<AnalyticEuropeanEngine>(process_);

VanillaOption opt(payoff, exercise);
opt.setPricingEngine(engine);
Expand Down Expand Up @@ -321,4 +320,3 @@ namespace QuantLib {


}

21 changes: 8 additions & 13 deletions ql/pricingengines/barrier/binomialbarrierengine.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,21 +112,17 @@ namespace QuantLib {

// binomial trees with constant coefficient
Handle<YieldTermStructure> flatRiskFree(
ext::shared_ptr<YieldTermStructure>(
new FlatForward(referenceDate, r, rfdc)));
ext::make_shared<FlatForward>(referenceDate, r, rfdc));
Handle<YieldTermStructure> flatDividends(
ext::shared_ptr<YieldTermStructure>(
new FlatForward(referenceDate, q, divdc)));
ext::make_shared<FlatForward>(referenceDate, q, divdc));
Handle<BlackVolTermStructure> flatVol(
ext::shared_ptr<BlackVolTermStructure>(
new BlackConstantVol(referenceDate, volcal, v, voldc)));
ext::make_shared<BlackConstantVol>(referenceDate, volcal, v, voldc));

Time maturity = rfdc.yearFraction(referenceDate, maturityDate);

ext::shared_ptr<StochasticProcess1D> bs(
new GeneralizedBlackScholesProcess(
auto bs = ext::make_shared<GeneralizedBlackScholesProcess>(
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,
Expand Down Expand Up @@ -157,11 +153,10 @@ namespace QuantLib {

TimeGrid grid(maturity, optimum_steps);

ext::shared_ptr<T> tree(new T(bs, maturity, optimum_steps,
payoff->strike()));
auto tree = ext::make_shared<T>(bs, maturity, optimum_steps,
payoff->strike());

ext::shared_ptr<BlackScholesLattice<T> > lattice(
new BlackScholesLattice<T>(tree, r, maturity, optimum_steps));
auto lattice = ext::make_shared<BlackScholesLattice<T>>(tree, r, maturity, optimum_steps);

D option(arguments_, *process_, grid);
option.initialize(lattice, maturity);
Expand Down
Loading
Loading