Skip to content

Commit d5f30a7

Browse files
committed
Deprecate remaining old-style FD dividend options.
Replacing them with the new FD Black-Scholes option causes a few tests to fail. We should check if the new-style option can be made to pass them.
1 parent 98857e7 commit d5f30a7

File tree

3 files changed

+37
-63
lines changed

3 files changed

+37
-63
lines changed

ql/pricingengines/vanilla/fddividendamericanengine.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -32,18 +32,8 @@
3232
namespace QuantLib {
3333

3434
//! Finite-differences pricing engine for dividend American options
35-
/*! \deprecated Use FDDividendAmericanEngineMerton73 instead if you
36-
want to use the Merton 73 escowed dividend model;
37-
use FdBlackScholesVanillaEngine otherwise.
35+
/*! \deprecated Use FdBlackScholesVanillaEngine instead.
3836
Deprecated in version 1.17.
39-
40-
\ingroup vanillaengines
41-
42-
\test
43-
- the correctness of the returned greeks is tested by
44-
reproducing numerical derivatives.
45-
- the invariance of the results upon addition of null
46-
dividends is tested.
4737
*/
4838
template <template <class> class Scheme = CrankNicolson>
4939
class QL_DEPRECATED FDDividendAmericanEngine
@@ -61,9 +51,11 @@ namespace QuantLib {
6151

6252

6353
//! Finite-differences pricing engine for dividend American options
64-
/*! This engine uses the Merton 73 escowed dividend model. */
54+
/*! \deprecated Use FdBlackScholesVanillaEngine instead.
55+
Deprecated in version 1.17.
56+
*/
6557
template <template <class> class Scheme = CrankNicolson>
66-
class FDDividendAmericanEngineMerton73
58+
class QL_DEPRECATED FDDividendAmericanEngineMerton73
6759
: public FDEngineAdapter<FDAmericanCondition<
6860
FDDividendEngineMerton73<Scheme> >,
6961
DividendVanillaOption::engine> {

ql/pricingengines/vanilla/fddividendeuropeanengine.hpp

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -30,18 +30,8 @@
3030
namespace QuantLib {
3131

3232
//! Finite-differences pricing engine for dividend European options
33-
/*! \deprecated Use FDDividendEuropeanEngineMerton73 instead if you
34-
want to use the Merton 73 escowed dividend model;
35-
use FdBlackScholesVanillaEngine otherwise.
33+
/*! \deprecated Use FdBlackScholesVanillaEngine instead.
3634
Deprecated in version 1.17.
37-
38-
\ingroup vanillaengines
39-
40-
\test
41-
- the correctness of the returned greeks is tested by
42-
reproducing numerical derivatives.
43-
- the invariance of the results upon addition of null
44-
dividends is tested.
4535
*/
4636
template <template <class> class Scheme = CrankNicolson>
4737
class QL_DEPRECATED FDDividendEuropeanEngine
@@ -59,9 +49,11 @@ namespace QuantLib {
5949

6050

6151
//! Finite-differences pricing engine for dividend European options
62-
/*! This engine uses the Merton 73 escowed dividend model. */
52+
/*! \deprecated Use FdBlackScholesVanillaEngine instead.
53+
Deprecated in version 1.17.
54+
*/
6355
template <template <class> class Scheme = CrankNicolson>
64-
class FDDividendEuropeanEngineMerton73
56+
class QL_DEPRECATED FDDividendEuropeanEngineMerton73
6557
: public FDEngineAdapter<FDDividendEngineMerton73<Scheme>,
6658
DividendVanillaOption::engine> {
6759
typedef FDEngineAdapter<FDDividendEngineMerton73<Scheme>,

test-suite/dividendoption.cpp

Lines changed: 27 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -622,10 +622,11 @@ void DividendOptionTest::testFdEuropeanValues() {
622622
new BlackScholesMertonProcess(Handle<Quote>(spot),
623623
qTS, rTS, volTS));
624624

625-
ext::shared_ptr<PricingEngine> engine(
626-
new FDDividendEuropeanEngineMerton73<CrankNicolson>(stochProcess,
627-
timeSteps,
628-
gridPoints));
625+
ext::shared_ptr<PricingEngine> engine =
626+
MakeFdBlackScholesVanillaEngine(stochProcess)
627+
.withTGrid(timeSteps)
628+
.withXGrid(gridPoints)
629+
.withCashDividendModel(FdBlackScholesVanillaEngine::Escrowed);
629630

630631
ext::shared_ptr<PricingEngine> ref_engine(
631632
new AnalyticDividendEuropeanEngine(stochProcess));
@@ -674,9 +675,9 @@ void DividendOptionTest::testFdEuropeanValues() {
674675

675676
namespace {
676677

677-
template <class Engine>
678678
void testFdGreeks(const Date& today,
679-
const ext::shared_ptr<Exercise>& exercise) {
679+
const ext::shared_ptr<Exercise>& exercise,
680+
FdBlackScholesVanillaEngine::CashDividendModel model) {
680681

681682
std::map<std::string,Real> calculated, expected, tolerance;
682683
tolerance["delta"] = 5.0e-3;
@@ -719,8 +720,10 @@ namespace {
719720
new BlackScholesMertonProcess(Handle<Quote>(spot),
720721
qTS, rTS, volTS));
721722

722-
ext::shared_ptr<PricingEngine> engine(
723-
new Engine(stochProcess));
723+
ext::shared_ptr<PricingEngine> engine =
724+
MakeFdBlackScholesVanillaEngine(stochProcess)
725+
.withCashDividendModel(model);
726+
724727
DividendVanillaOption option(payoff, exercise,
725728
dividendDates, dividends);
726729
option.setPricingEngine(engine);
@@ -809,8 +812,8 @@ void DividendOptionTest::testFdEuropeanGreeks() {
809812
for (Size i=0; i<LENGTH(lengths); i++) {
810813
Date exDate = today + lengths[i]*Years;
811814
ext::shared_ptr<Exercise> exercise(new EuropeanExercise(exDate));
812-
testFdGreeks<FDDividendEuropeanEngineMerton73<CrankNicolson> >(today,exercise);
813-
testFdGreeks<FdBlackScholesVanillaEngine>(today,exercise);
815+
testFdGreeks(today,exercise,FdBlackScholesVanillaEngine::Spot);
816+
testFdGreeks(today,exercise,FdBlackScholesVanillaEngine::Escrowed);
814817
}
815818
}
816819

@@ -826,19 +829,18 @@ void DividendOptionTest::testFdAmericanGreeks() {
826829

827830
for (Size i=0; i<LENGTH(lengths); i++) {
828831
Date exDate = today + lengths[i]*Years;
829-
ext::shared_ptr<Exercise> exercise(
830-
new AmericanExercise(today,exDate));
831-
testFdGreeks<FDDividendAmericanEngineMerton73<CrankNicolson> >(today,exercise);
832-
testFdGreeks<FdBlackScholesVanillaEngine>(today,exercise);
832+
ext::shared_ptr<Exercise> exercise(new AmericanExercise(today,exDate));
833+
testFdGreeks(today,exercise,FdBlackScholesVanillaEngine::Spot);
834+
testFdGreeks(today,exercise,FdBlackScholesVanillaEngine::Escrowed);
833835
}
834836
}
835837

836838

837839
namespace {
838840

839-
template <class Engine>
840841
void testFdDegenerate(const Date& today,
841-
const ext::shared_ptr<Exercise>& exercise) {
842+
const ext::shared_ptr<Exercise>& exercise,
843+
FdBlackScholesVanillaEngine::CashDividendModel model) {
842844

843845
DayCounter dc = Actual360();
844846
ext::shared_ptr<SimpleQuote> spot(new SimpleQuote(54.625));
@@ -853,8 +855,11 @@ namespace {
853855
Size timeSteps = 300;
854856
Size gridPoints = 300;
855857

856-
ext::shared_ptr<PricingEngine> engine(
857-
new Engine(process,timeSteps,gridPoints));
858+
ext::shared_ptr<PricingEngine> engine =
859+
MakeFdBlackScholesVanillaEngine(process)
860+
.withTGrid(timeSteps)
861+
.withXGrid(gridPoints)
862+
.withCashDividendModel(model);
858863

859864
ext::shared_ptr<StrikedTypePayoff> payoff(
860865
new PlainVanillaPayoff(Option::Call, 55.0));
@@ -905,7 +910,8 @@ void DividendOptionTest::testFdEuropeanDegenerate() {
905910

906911
ext::shared_ptr<Exercise> exercise(new EuropeanExercise(exDate));
907912

908-
testFdDegenerate<FDDividendEuropeanEngineMerton73<CrankNicolson> >(today,exercise);
913+
testFdDegenerate(today,exercise,FdBlackScholesVanillaEngine::Spot);
914+
testFdDegenerate(today,exercise,FdBlackScholesVanillaEngine::Escrowed);
909915
}
910916

911917
void DividendOptionTest::testFdAmericanDegenerate() {
@@ -921,7 +927,8 @@ void DividendOptionTest::testFdAmericanDegenerate() {
921927

922928
ext::shared_ptr<Exercise> exercise(new AmericanExercise(today,exDate));
923929

924-
testFdDegenerate<FDDividendAmericanEngineMerton73<CrankNicolson> >(today,exercise);
930+
testFdDegenerate(today,exercise,FdBlackScholesVanillaEngine::Spot);
931+
testFdDegenerate(today,exercise,FdBlackScholesVanillaEngine::Escrowed);
925932
}
926933

927934

@@ -1001,23 +1008,6 @@ void DividendOptionTest::testEscrowedDividendModel() {
10011008
<< "\n difference: " << std::fabs(pdeNPV - analyticNPV)
10021009
<< "\n tolerance: " << tol);
10031010
}
1004-
1005-
option.setPricingEngine(
1006-
ext::make_shared<FDDividendEuropeanEngineMerton73<> >(
1007-
process, 50, 200));
1008-
1009-
const Real deprecatedPDENPV = option.NPV();
1010-
1011-
if (std::fabs(deprecatedPDENPV - analyticNPV) > tol) {
1012-
BOOST_FAIL("Failed to reproduce European option values "
1013-
"with the escrowed dividend model and the "
1014-
"FDDividendEuropeanEngineMerton73 engine"
1015-
<< "\n calculated: " << pdeNPV
1016-
<< "\n expected: " << analyticNPV
1017-
<< "\n difference: "
1018-
<< std::fabs(deprecatedPDENPV - analyticNPV)
1019-
<< "\n tolerance: " << tol);
1020-
}
10211011
}
10221012

10231013
test_suite* DividendOptionTest::suite() {

0 commit comments

Comments
 (0)