20#include <boost/test/unit_test.hpp>
21#include <ql/quotes/simplequote.hpp>
22#include <ql/termstructures/yield/flatforward.hpp>
23#include <ql/time/calendars/nullcalendar.hpp>
24#include <ql/time/daycounters/actualactual.hpp>
25#include <ql/currencies/europe.hpp>
29using namespace boost::unit_test_framework;
35BOOST_AUTO_TEST_SUITE(BlackVarianceSurfaceStdDevs)
39 BOOST_TEST_MESSAGE(
"Testing QuantExt::BlackVarianceSurfaceStdDevs");
42 Settings::instance().evaluationDate() = Date(1, Dec, 2015);
43 Date today = Settings::instance().evaluationDate();
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)));
60 QuantLib::ext::shared_ptr<QuantExt::FxIndex> fxIndex =
61 QuantLib::ext::make_shared<QuantExt::FxIndex>(
"dummy", 2, EURCurrency(),
62 GBPCurrency(), cal, spot, forTS, domTS);
66 for (Time t = 0.05; t < 5.0; t += 0.1) {
68 for (Real k = 70; k < 150; k += 0.5) {
69 Volatility vol = surface.blackVol(t, k);
71 BOOST_CHECK_CLOSE(vol, flatVol, 1e-12);
76BOOST_AUTO_TEST_SUITE_END()
78BOOST_AUTO_TEST_SUITE_END()
Black volatility surface modeled as variance surface.
BOOST_AUTO_TEST_CASE(testFlatSurface)
Fixture that can be used at top level.