|
29 | 29 | #include <ql/pricingengines/inflation/inflationcapfloorengines.hpp> |
30 | 30 | #include <ql/experimental/inflation/yoyoptionletstripper.hpp> |
31 | 31 | #include <ql/experimental/inflation/kinterpolatedyoyoptionletvolatilitysurface.hpp> |
| 32 | +#include <ql/quotes/simplequote.hpp> |
| 33 | +#include <ql/termstructures/volatility/inflation/constantcpivolatility.hpp> |
| 34 | +#include <ql/termstructures/volatility/inflation/yoyinflationoptionletvolatilitystructure.hpp> |
32 | 35 | #include <ql/experimental/inflation/interpolatedyoyoptionletstripper.hpp> |
33 | 36 | #include <ql/cashflows/capflooredinflationcoupon.hpp> |
34 | 37 | #include <ql/indexes/inflation/euhicp.hpp> |
@@ -390,6 +393,38 @@ BOOST_AUTO_TEST_CASE(testYoYPriceSurfaceToATM) { |
390 | 393 | reset(); |
391 | 394 | } |
392 | 395 |
|
| 396 | +BOOST_AUTO_TEST_CASE(testConstantVolatilityQuoteIsObserved) { |
| 397 | + |
| 398 | + BOOST_TEST_MESSAGE("Testing that constant inflation volatility surfaces observe their quote..."); |
| 399 | + |
| 400 | + auto quote = ext::make_shared<SimpleQuote>(0.01); |
| 401 | + Handle<Quote> handle(quote); |
| 402 | + |
| 403 | + auto cpi = ext::make_shared<ConstantCPIVolatility>( |
| 404 | + handle, 0, TARGET(), Following, Actual365Fixed(), |
| 405 | + Period(3, Months), Monthly, false); |
| 406 | + auto yoy = ext::make_shared<ConstantYoYOptionletVolatility>( |
| 407 | + handle, 0, TARGET(), Following, Actual365Fixed(), |
| 408 | + Period(3, Months), Monthly, false); |
| 409 | + |
| 410 | + Flag cpiFlag, yoyFlag; |
| 411 | + cpiFlag.registerWith(cpi); |
| 412 | + yoyFlag.registerWith(yoy); |
| 413 | + cpiFlag.lower(); |
| 414 | + yoyFlag.lower(); |
| 415 | + |
| 416 | + quote->setValue(0.02); |
| 417 | + |
| 418 | + BOOST_CHECK_MESSAGE(cpiFlag.isUp(), |
| 419 | + "ConstantCPIVolatility did not notify when its quote moved"); |
| 420 | + BOOST_CHECK_MESSAGE(yoyFlag.isUp(), |
| 421 | + "ConstantYoYOptionletVolatility did not notify when its quote moved"); |
| 422 | + |
| 423 | + // volatilityImpl reads the quote on every call, so these pass either way. |
| 424 | + BOOST_CHECK_CLOSE(cpi->volatility(1.0, 0.02), 0.02, 1.0e-10); |
| 425 | + BOOST_CHECK_CLOSE(yoy->volatility(1.0, 0.02), 0.02, 1.0e-10); |
| 426 | +} |
| 427 | + |
393 | 428 | BOOST_AUTO_TEST_SUITE_END() |
394 | 429 |
|
395 | 430 | BOOST_AUTO_TEST_SUITE_END() |
0 commit comments