Coverage Report

Created: 2025-09-04 07:11

/src/quantlib/ql/experimental/processes/vegastressedblackscholesprocess.cpp
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) 2010 Michael Heckl
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
 <https://www.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
#include <ql/experimental/processes/vegastressedblackscholesprocess.hpp>
21
22
namespace QuantLib {
23
24
    VegaStressedBlackScholesProcess::VegaStressedBlackScholesProcess(
25
             const Handle<Quote>& x0,
26
             const Handle<YieldTermStructure>& dividendTS,
27
             const Handle<YieldTermStructure>& riskFreeTS,
28
             const Handle<BlackVolTermStructure>& blackVolTS,
29
             Time lowerTimeBorderForStressTest,
30
             Time upperTimeBorderForStressTest,
31
             Real lowerAssetBorderForStressTest,
32
             Real upperAssetBorderForStressTest,
33
             Real stressLevel,
34
             const ext::shared_ptr<discretization>& disc)
35
0
    : GeneralizedBlackScholesProcess(x0, dividendTS, riskFreeTS,
36
0
                                     blackVolTS, disc),
37
0
      lowerTimeBorderForStressTest_(lowerTimeBorderForStressTest),
38
0
      upperTimeBorderForStressTest_(upperTimeBorderForStressTest), 
39
0
      lowerAssetBorderForStressTest_(lowerAssetBorderForStressTest), 
40
0
      upperAssetBorderForStressTest_(upperAssetBorderForStressTest),
41
0
      stressLevel_(stressLevel) {}
42
43
    // returns the lower time border for the stress test
44
0
    Real VegaStressedBlackScholesProcess::getLowerTimeBorderForStressTest() const {
45
0
        return lowerTimeBorderForStressTest_;
46
0
    }
47
48
    // returns the upper time border for the stress test
49
0
    Real VegaStressedBlackScholesProcess::getUpperTimeBorderForStressTest() const {
50
0
        return upperTimeBorderForStressTest_;
51
0
    }
52
53
    // returns the lower asset border for the stress test
54
0
    Real VegaStressedBlackScholesProcess::getLowerAssetBorderForStressTest() const {
55
0
        return lowerAssetBorderForStressTest_;
56
0
    }
57
58
    // returns the upper asset border for the stress test
59
0
    Real VegaStressedBlackScholesProcess::getUpperAssetBorderForStressTest() const {
60
0
        return upperAssetBorderForStressTest_;
61
0
    }
62
63
    // returns the stress Level
64
0
    Real VegaStressedBlackScholesProcess::getStressLevel() const {
65
0
        return stressLevel_;
66
0
    }
67
68
69
    // set the lower time border for the stress test
70
0
    void VegaStressedBlackScholesProcess::setLowerTimeBorderForStressTest(Time LTB) {
71
0
        lowerTimeBorderForStressTest_ = LTB;
72
0
        update();
73
0
    }
74
75
    // set the upper time border for the stress test
76
0
    void VegaStressedBlackScholesProcess::setUpperTimeBorderForStressTest(Time UTB) {
77
0
        upperTimeBorderForStressTest_ = UTB;
78
0
        update();
79
0
    }
80
81
    // set the lower asset border for the stress test
82
0
    void VegaStressedBlackScholesProcess::setLowerAssetBorderForStressTest(Real LAB) {
83
0
        lowerAssetBorderForStressTest_ = LAB;
84
0
        update();
85
0
    }
86
87
    // set the upper asset border for the stress test
88
0
    void VegaStressedBlackScholesProcess::setUpperAssetBorderForStressTest(Real UBA) {
89
0
        upperAssetBorderForStressTest_ = UBA;
90
0
        update();
91
0
    }
92
93
    // set the stress Level
94
0
    void VegaStressedBlackScholesProcess::setStressLevel(Real SL) {
95
0
        stressLevel_ = SL;
96
0
        update();
97
0
    }
98
99
100
101
0
    Real VegaStressedBlackScholesProcess::diffusion(Time t, Real x) const {
102
0
        if (lowerTimeBorderForStressTest_ <= t && t <= upperTimeBorderForStressTest_ 
103
0
            && lowerAssetBorderForStressTest_ <= x && x <= upperAssetBorderForStressTest_) {
104
0
            return GeneralizedBlackScholesProcess::diffusion(t, x)+stressLevel_;
105
0
        } else {
106
0
            return GeneralizedBlackScholesProcess::diffusion(t, x);
107
0
        }
108
0
    }
109
110
}