36 {
37
38 BOOST_TEST_MESSAGE("Testing exact Bachelier implied volatility...");
39
40 Real tolerance = 1E-4;
41 Real forward = 0.05;
42
43 for (Real strikeSpread = -0.10; strikeSpread < 0.10 + 1E-5; strikeSpread += 0.001) {
44 Real strike = forward + strikeSpread;
45 for (Real vol = 0.0; vol < 0.02 + 1E-5; vol += 0.001) {
46 for (Real tte = 0.001; tte < 51.0; tte += 0.1) {
47 Real stdDev = std::sqrt(tte) * vol;
48 Real call = bachelierBlackFormula(Option::Call, strike, forward, stdDev);
49 Real put = bachelierBlackFormula(Option::Put, strike, forward, stdDev);
50 if (std::abs(call) < 1E-12 || std::abs(put) < 1E-12)
51 continue;
54 BOOST_CHECK_CLOSE(vol, impliedVolCall, tolerance);
55 BOOST_CHECK_CLOSE(vol, impliedVolPut, tolerance);
56 }
57 }
58 }
59}
Real exactBachelierImpliedVolatility(Option::Type optionType, Real strike, Real forward, Real tte, Real bachelierPrice, Real discount)