/src/quantlib/ql/termstructures/volatility/zabr.hpp
Line | Count | Source |
1 | | /* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */ |
2 | | |
3 | | /* |
4 | | Copyright (C) 2014 Peter Caspers |
5 | | Copyright (C) 2026 Aaditya Panikath |
6 | | |
7 | | This file is part of QuantLib, a free-software/open-source library |
8 | | for financial quantitative analysts and developers - http://quantlib.org/ |
9 | | |
10 | | QuantLib is free software: you can redistribute it and/or modify it |
11 | | under the terms of the QuantLib license. You should have received a |
12 | | copy of the license along with this program; if not, please email |
13 | | <quantlib-dev@lists.sf.net>. The license is also available online at |
14 | | <https://www.quantlib.org/license.shtml>. |
15 | | |
16 | | This program is distributed in the hope that it will be useful, but WITHOUT |
17 | | ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS |
18 | | FOR A PARTICULAR PURPOSE. See the license for more details. |
19 | | */ |
20 | | |
21 | | /*! \file zabr.hpp |
22 | | \brief ZABR functions |
23 | | Reference: Andreasen, Huge: ZABR - Expansions for the masses, Preliminary |
24 | | Version, December 2011, http://ssrn.com/abstract=1980726 |
25 | | */ |
26 | | |
27 | | #ifndef quantlib_zabr_hpp |
28 | | #define quantlib_zabr_hpp |
29 | | |
30 | | #include <ql/types.hpp> |
31 | | #include <ql/math/statistics/incrementalstatistics.hpp> |
32 | | #include <ql/math/interpolations/linearinterpolation.hpp> |
33 | | #include <ql/math/interpolations/cubicinterpolation.hpp> |
34 | | #include <ql/math/interpolations/bicubicsplineinterpolation.hpp> |
35 | | #include <vector> |
36 | | |
37 | | namespace QuantLib { |
38 | | |
39 | | class ZabrModel { |
40 | | |
41 | | public: |
42 | | ZabrModel(Real expiryTime, Real forward, Real alpha, Real beta, Real nu, Real rho, Real gamma); |
43 | | |
44 | | Real localVolatility(Real f) const; |
45 | | std::vector<Real> localVolatility(const std::vector<Real> &f) const; |
46 | | |
47 | | Real fdPrice(Real strike) const; |
48 | | std::vector<Real> fdPrice(const std::vector<Real> &strikes) const; |
49 | | |
50 | | Real fullFdPrice(Real strike) const; |
51 | | |
52 | | Real lognormalVolatility(Real strike) const; |
53 | | std::vector<Real> lognormalVolatility(const std::vector<Real> &strikes) const; |
54 | | |
55 | | Real normalVolatility(Real strike) const; |
56 | | std::vector<Real> normalVolatility(const std::vector<Real> &strikes) const; |
57 | | |
58 | 0 | Real forward() const { return forward_; } |
59 | 0 | Real expiryTime() const { return expiryTime_; } |
60 | 0 | Real alpha() const { return alpha_; } |
61 | 0 | Real beta() const { return beta_; } |
62 | 0 | Real nu() const { return nu_; } |
63 | 0 | Real rho() const { return rho_; } |
64 | 0 | Real gamma() const { return gamma_; } |
65 | | |
66 | | private: |
67 | | const Real expiryTime_, forward_; |
68 | | const Real alpha_, beta_, nu_, rho_, |
69 | | gamma_; // nu_ here is a tranformed version of the input nu ! |
70 | | |
71 | | Real x(Real strike) const; |
72 | | std::vector<Real> x(const std::vector<Real> &strikes) const; |
73 | | |
74 | | Real y(Real strike) const; |
75 | | |
76 | | Real F(Real y, Real u) const; |
77 | | |
78 | | Real lognormalVolatilityHelper(Real strike, Real x) const; |
79 | | Real normalVolatilityHelper(Real strike, Real x) const; |
80 | | Real localVolatilityHelper(Real f, Real x) const; |
81 | | }; |
82 | | } |
83 | | |
84 | | #endif |