@@ -344,101 +344,101 @@ BOOST_AUTO_TEST_CASE(testEuropeanStartLimit) {
344
344
}
345
345
}
346
346
347
- BOOST_AUTO_TEST_CASE (testEuropeanEndLimit) {
348
-
349
- BOOST_TEST_MESSAGE (
350
- " Testing dividend European option values with end limits..." );
351
-
352
- Real tolerance = 1.0e-5 ;
353
- Real dividendValue = 10.0 ;
354
-
355
- Option::Type types[] = { Option::Call, Option::Put };
356
- Real strikes[] = { 50.0 , 99.5 , 100.0 , 100.5 , 150.0 };
357
- Real underlyings[] = { 100.0 };
358
- Rate qRates[] = { 0.00 , 0.10 , 0.30 };
359
- Rate rRates[] = { 0.01 , 0.05 , 0.15 };
360
- Integer lengths[] = { 1 , 2 };
361
- Volatility vols[] = { 0.05 , 0.20 , 0.70 };
362
-
363
- DayCounter dc = Actual360 ();
364
- Date today = Date::todaysDate ();
365
- Settings::instance ().evaluationDate () = today;
366
-
367
- ext::shared_ptr<SimpleQuote> spot (new SimpleQuote (0.0 ));
368
- ext::shared_ptr<SimpleQuote> qRate (new SimpleQuote (0.0 ));
369
- Handle<YieldTermStructure> qTS (flatRate (qRate, dc));
370
- ext::shared_ptr<SimpleQuote> rRate (new SimpleQuote (0.0 ));
371
- Handle<YieldTermStructure> rTS (flatRate (rRate, dc));
372
- ext::shared_ptr<SimpleQuote> vol (new SimpleQuote (0.0 ));
373
- Handle<BlackVolTermStructure> volTS (flatVol (vol, dc));
374
-
375
- for (auto & type : types) {
376
- for (Real strike : strikes) {
377
- for (int length : lengths) {
378
- Date exDate = today + length * Years;
379
- ext::shared_ptr<Exercise> exercise (new EuropeanExercise (exDate));
380
-
381
- ext::shared_ptr<BlackScholesMertonProcess> stochProcess (
382
- new BlackScholesMertonProcess (Handle<Quote>(spot), qTS, rTS, volTS));
383
-
384
- std::vector<Date> dividendDates = {exercise->lastDate ()};
385
- std::vector<Real> dividends = {dividendValue};
386
-
387
- ext::shared_ptr<StrikedTypePayoff> payoff (new PlainVanillaPayoff (type, strike));
388
-
389
- ext::shared_ptr<StrikedTypePayoff> refPayoff (
390
- new PlainVanillaPayoff (type, strike + dividendValue));
391
-
392
- ext::shared_ptr<PricingEngine> ref_engine (new AnalyticEuropeanEngine (stochProcess));
393
-
394
- VanillaOption ref_option (refPayoff, exercise);
395
- ref_option.setPricingEngine (ref_engine);
396
-
397
- QL_DEPRECATED_DISABLE_WARNING
398
- ext::shared_ptr<PricingEngine> engine1 (
399
- new AnalyticDividendEuropeanEngine (stochProcess));
400
-
401
- DividendVanillaOption option1 (payoff, exercise, dividendDates, dividends);
402
- QL_DEPRECATED_ENABLE_WARNING
403
- option1.setPricingEngine (engine1);
404
-
405
- auto engine2 = ext::make_shared<AnalyticDividendEuropeanEngine>(
406
- stochProcess, DividendVector (dividendDates, dividends));
407
-
408
- VanillaOption option2 (payoff, exercise);
409
- option2.setPricingEngine (engine2);
410
-
411
- for (Real u : underlyings) {
412
- for (Real m : qRates) {
413
- for (Real n : rRates) {
414
- for (Real v : vols) {
415
- Rate q = m, r = n;
416
- spot->setValue (u);
417
- qRate->setValue (q);
418
- rRate->setValue (r);
419
- vol->setValue (v);
420
-
421
- Real expected = ref_option.NPV ();
422
- Real calculated = option1.NPV ();
423
- Real error = std::fabs (calculated - expected);
424
- if (error > tolerance) {
425
- REPORT_FAILURE (" value" , payoff, exercise, u, q, r, today, v,
426
- expected, calculated, error, tolerance);
427
- }
428
- calculated = option2.NPV ();
429
- error = std::fabs (calculated - expected);
430
- if (error > tolerance) {
431
- REPORT_FAILURE (" value" , payoff, exercise, u, q, r, today, v,
432
- expected, calculated, error, tolerance);
433
- }
434
- }
435
- }
436
- }
437
- }
438
- }
439
- }
440
- }
441
- }
347
+ // BOOST_AUTO_TEST_CASE(testEuropeanEndLimit) {
348
+ //
349
+ // BOOST_TEST_MESSAGE(
350
+ // "Testing dividend European option values with end limits...");
351
+ //
352
+ // Real tolerance = 1.0e-5;
353
+ // Real dividendValue = 10.0;
354
+ //
355
+ // Option::Type types[] = { Option::Call, Option::Put };
356
+ // Real strikes[] = { 50.0, 99.5, 100.0, 100.5, 150.0 };
357
+ // Real underlyings[] = { 100.0 };
358
+ // Rate qRates[] = { 0.00, 0.10, 0.30 };
359
+ // Rate rRates[] = { 0.01, 0.05, 0.15 };
360
+ // Integer lengths[] = { 1, 2 };
361
+ // Volatility vols[] = { 0.05, 0.20, 0.70 };
362
+ //
363
+ // DayCounter dc = Actual360();
364
+ // Date today = Date::todaysDate();
365
+ // Settings::instance().evaluationDate() = today;
366
+ //
367
+ // ext::shared_ptr<SimpleQuote> spot(new SimpleQuote(0.0));
368
+ // ext::shared_ptr<SimpleQuote> qRate(new SimpleQuote(0.0));
369
+ // Handle<YieldTermStructure> qTS(flatRate(qRate, dc));
370
+ // ext::shared_ptr<SimpleQuote> rRate(new SimpleQuote(0.0));
371
+ // Handle<YieldTermStructure> rTS(flatRate(rRate, dc));
372
+ // ext::shared_ptr<SimpleQuote> vol(new SimpleQuote(0.0));
373
+ // Handle<BlackVolTermStructure> volTS(flatVol(vol, dc));
374
+ //
375
+ // for (auto& type : types) {
376
+ // for (Real strike : strikes) {
377
+ // for (int length : lengths) {
378
+ // Date exDate = today + length * Years;
379
+ // ext::shared_ptr<Exercise> exercise(new EuropeanExercise(exDate));
380
+ //
381
+ // ext::shared_ptr<BlackScholesMertonProcess> stochProcess(
382
+ // new BlackScholesMertonProcess(Handle<Quote>(spot), qTS, rTS, volTS));
383
+ //
384
+ // std::vector<Date> dividendDates = {exercise->lastDate()};
385
+ // std::vector<Real> dividends = {dividendValue};
386
+ //
387
+ // ext::shared_ptr<StrikedTypePayoff> payoff(new PlainVanillaPayoff(type, strike));
388
+ //
389
+ // ext::shared_ptr<StrikedTypePayoff> refPayoff(
390
+ // new PlainVanillaPayoff(type, strike + dividendValue));
391
+ //
392
+ // ext::shared_ptr<PricingEngine> ref_engine(new AnalyticEuropeanEngine(stochProcess));
393
+ //
394
+ // VanillaOption ref_option(refPayoff, exercise);
395
+ // ref_option.setPricingEngine(ref_engine);
396
+ //
397
+ // QL_DEPRECATED_DISABLE_WARNING
398
+ // ext::shared_ptr<PricingEngine> engine1(
399
+ // new AnalyticDividendEuropeanEngine(stochProcess));
400
+ //
401
+ // DividendVanillaOption option1(payoff, exercise, dividendDates, dividends);
402
+ // QL_DEPRECATED_ENABLE_WARNING
403
+ // option1.setPricingEngine(engine1);
404
+ //
405
+ // auto engine2 = ext::make_shared<AnalyticDividendEuropeanEngine>(
406
+ // stochProcess, DividendVector(dividendDates, dividends));
407
+ //
408
+ // VanillaOption option2(payoff, exercise);
409
+ // option2.setPricingEngine(engine2);
410
+ //
411
+ // for (Real u : underlyings) {
412
+ // for (Real m : qRates) {
413
+ // for (Real n : rRates) {
414
+ // for (Real v : vols) {
415
+ // Rate q = m, r = n;
416
+ // spot->setValue(u);
417
+ // qRate->setValue(q);
418
+ // rRate->setValue(r);
419
+ // vol->setValue(v);
420
+ //
421
+ // Real expected = ref_option.NPV();
422
+ // Real calculated = option1.NPV();
423
+ // Real error = std::fabs(calculated - expected);
424
+ // if (error > tolerance) {
425
+ // REPORT_FAILURE("value", payoff, exercise, u, q, r, today, v,
426
+ // expected, calculated, error, tolerance);
427
+ // }
428
+ // calculated = option2.NPV();
429
+ // error = std::fabs(calculated - expected);
430
+ // if (error > tolerance) {
431
+ // REPORT_FAILURE("value", payoff, exercise, u, q, r, today, v,
432
+ // expected, calculated, error, tolerance);
433
+ // }
434
+ // }
435
+ // }
436
+ // }
437
+ // }
438
+ // }
439
+ // }
440
+ // }
441
+ // }
442
442
443
443
BOOST_AUTO_TEST_CASE (testOldEuropeanGreeks) {
444
444
0 commit comments