109 {
110
111 BOOST_TEST_MESSAGE("Testing forward forward variance dynamics of "
112 "DynamicSwaptionVolatilityMatrix");
113 TestData d;
114
115 QuantLib::ext::shared_ptr<SwaptionVolatilityStructure> dyn =
116 QuantLib::ext::make_shared<DynamicSwaptionVolatilityMatrix>(d.atmSurface, 0, TARGET(),
ForwardForwardVariance);
117
118 dyn->enableExtrapolation();
119
120 Real tol = 1.0E-8;
121
122 Real strike = 0.05;
123
124
125
126 BOOST_CHECK_CLOSE(dyn->volatility(1 * Months, 1 * Years, strike),
127 d.atmSurface->volatility(1 * Months, 1 * Years, strike), tol);
128 BOOST_CHECK_CLOSE(dyn->volatility(1 * Months, 2 * Years, strike),
129 d.atmSurface->volatility(1 * Months, 2 * Years, strike), tol);
130 BOOST_CHECK_CLOSE(dyn->volatility(1 * Years, 1 * Years, strike),
131 d.atmSurface->volatility(1 * Years, 1 * Years, strike), tol);
132 BOOST_CHECK_CLOSE(dyn->volatility(1 * Years, 2 * Years, strike),
133 d.atmSurface->volatility(1 * Years, 2 * Years, strike), tol);
134
135
136
137 Settings::instance().evaluationDate() = TARGET().advance(d.origRefDate, 5 * Months);
138 Real tf = d.atmSurface->timeFromReference(Settings::instance().evaluationDate());
139
140 BOOST_CHECK_CLOSE(dyn->blackVariance(0.1, 1.0, strike),
141 d.atmSurface->blackVariance(tf + 0.1, 1.0, strike) - d.atmSurface->blackVariance(tf, 1.0, strike),
142 tol);
143 BOOST_CHECK_CLOSE(dyn->blackVariance(0.1, 2.0, strike),
144 d.atmSurface->blackVariance(tf + 0.1, 2.0, strike) - d.atmSurface->blackVariance(tf, 2.0, strike),
145 tol);
146 BOOST_CHECK_CLOSE(dyn->blackVariance(1.0, 1.0, strike),
147 d.atmSurface->blackVariance(tf + 1.0, 1.0, strike) - d.atmSurface->blackVariance(tf, 1.0, strike),
148 tol);
149 BOOST_CHECK_CLOSE(dyn->blackVariance(1.0, 2.0, strike),
150 d.atmSurface->blackVariance(tf + 1.0, 2.0, strike) - d.atmSurface->blackVariance(tf, 2.0, strike),
151 tol);
152
153}