Coverage Report

Created: 2025-08-11 06:28

/src/quantlib/ql/experimental/volatility/svismilesection.hpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2014 Peter Caspers
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 svismilesection.hpp
21
    \brief svi smile section
22
*/
23
24
#ifndef quantlib_svi_smile_section_hpp
25
#define quantlib_svi_smile_section_hpp
26
27
#include <ql/termstructures/volatility/smilesection.hpp>
28
#include <ql/time/daycounters/actual365fixed.hpp>
29
#include <vector>
30
31
namespace QuantLib {
32
33
//! Stochastic Volatility Inspired Smile Section
34
/*! \test the correctness of the result is tested by checking it
35
          against known good values.
36
*/
37
class SviSmileSection : public SmileSection {
38
39
  public:
40
    //! \name Constructors
41
    //@{
42
    /*! @param timeToExpiry Time to expiry
43
        @param forward Forward price corresponding to the expiry date
44
        @param sviParameters Expects SVI parameters as a vector composed of a, b, sigma, rho, m
45
    */
46
    SviSmileSection(Time timeToExpiry, Rate forward, std::vector<Real> sviParameters);
47
    /*! @param d Date of expiry
48
        @param forward Forward price corresponding to the expiry date
49
        @param sviParameters Expects SVI parameters as a vector composed of a, b, sigma, rho, m
50
        @param dc Day count method used to compute the time to expiry
51
    */
52
    SviSmileSection(const Date& d,
53
                    Rate forward,
54
                    std::vector<Real> sviParameters,
55
                    const DayCounter& dc = Actual365Fixed());
56
    //@}
57
0
    Real minStrike() const override { return 0.0; }
58
0
    Real maxStrike() const override { return QL_MAX_REAL; }
59
0
    Real atmLevel() const override { return forward_; }
60
61
  protected:
62
    Volatility volatilityImpl(Rate strike) const override;
63
64
  private:
65
    void init();
66
    Rate forward_;
67
    std::vector<Real> params_;
68
};
69
}
70
71
#endif