1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2017 Klaus Spanderen
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
20/*! \file sabrvoltermstructure.hpp
21 \brief implied vol surface backed by a SABR model
22*/
23
24#ifndef quantlib_sabr_vol_termstructure_hpp
25#define quantlib_sabr_vol_termstructure_hpp
26
27
28#include <ql/termstructures/volatility/sabr.hpp>
29#include <ql/termstructures/volatility/equityfx/blackvoltermstructure.hpp>
30#include <ql/time/calendars/nullcalendar.hpp>
31
32namespace QuantLib {
33 class SABRVolTermStructure : public BlackVolatilityTermStructure {
34 public:
35 SABRVolTermStructure(Real alpha,
36 Real beta,
37 Real gamma,
38 Real rho,
39 Real s0,
40 Real r,
41 const Date& referenceDate,
42 const DayCounter& dc)
43 : BlackVolatilityTermStructure(referenceDate, NullCalendar(), Following, dc), alpha_(alpha),
44 beta_(beta), gamma_(gamma), rho_(rho), s0_(s0), r_(r) {}
45
46 Date maxDate() const override { return Date::maxDate(); }
47 Rate minStrike() const override { return 0.0; }
48 Rate maxStrike() const override { return QL_MAX_REAL; }
49
50 protected:
51 Volatility blackVolImpl(Time t, Real strike) const override {
52 const Real fwd = s0_*std::exp(x: r_*t);
53 return sabrVolatility(strike, forward: fwd, expiryTime: t, alpha: alpha_, beta: beta_, nu: gamma_, rho: rho_);
54 }
55
56 private:
57 Real alpha_, beta_, gamma_, rho_, s0_, r_;
58 };
59}
60
61#endif
62

source code of quantlib/ql/experimental/volatility/sabrvoltermstructure.hpp