37 {
38
39 BOOST_TEST_MESSAGE("Testing QuantExt::BlackVarianceSurfaceStdDevs");
40
41 SavedSettings backup;
42 Settings::instance().evaluationDate() = Date(1, Dec, 2015);
43 Date today = Settings::instance().evaluationDate();
44
45
46
47 Calendar cal = NullCalendar();
48 Handle<Quote> spot = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(100));
49 vector<Time> times = { 1.0, 2.0, 3.0, 4.0 };
50 vector<Real> stdDevs = { -1.0, -0.5, 0, 0.5, 1.0 };
51 Volatility flatVol = 0.12;
52 Handle<Quote> flatVolQ = Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(flatVol));
53 vector<vector<Handle<Quote> > > blackVolMatrix(stdDevs.size(), vector<Handle<Quote> >(times.size(), flatVolQ));
54 DayCounter dc = ActualActual(ActualActual::ISDA);
55 Handle<YieldTermStructure> forTS(
56 QuantLib::ext::make_shared<FlatForward>(today, Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.02)), ActualActual(ActualActual::ISDA)));
57 Handle<YieldTermStructure> domTS(
58 QuantLib::ext::make_shared<FlatForward>(today, Handle<Quote>(QuantLib::ext::make_shared<SimpleQuote>(0.01)), ActualActual(ActualActual::ISDA)));
59
60 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex =
61 QuantLib::ext::make_shared<QuantExt::FxIndex>("dummy", 2, EURCurrency(),
62 GBPCurrency(), cal, spot, forTS, domTS);
64
65
66 for (Time t = 0.05; t < 5.0; t += 0.1) {
67
68 for (Real k = 70; k < 150; k += 0.5) {
69 Volatility vol = surface.blackVol(t, k);
70
71 BOOST_CHECK_CLOSE(vol, flatVol, 1e-12);
72 }
73 }
74}