• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

lballabio / QuantLib / 20680857444

03 Jan 2026 05:57PM UTC coverage: 74.172%. Remained the same
20680857444

push

github

lballabio
Revert #2410

57519 of 77548 relevant lines covered (74.17%)

8745369.93 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

65.79
/ql/processes/gsrprocess.cpp
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2

3
/*
4
 Copyright (C) 2013, 2015 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
 <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/processes/gsrprocess.hpp>
21
#include <cmath>
22
#include <utility>
23

24
namespace QuantLib {
25

26
    GsrProcess::GsrProcess(const Array& times,
10✔
27
                           const Array& vols,
28
                           const Array& reversions,
29
                           const Real T,
30
                           const Date& referenceDate,
31
                           DayCounter dc)
10✔
32
    : ForwardMeasureProcess1D(T), core_(times, vols, reversions, T), referenceDate_(referenceDate),
10✔
33
      dc_(std::move(dc)) {
10✔
34
        flushCache();
35
    }
10✔
36

37
    void GsrProcess::checkT(const Time t) const {
12,884,763✔
38
        QL_REQUIRE(t <= getForwardMeasureTime() && t >= 0.0,
12,884,763✔
39
                   "t (" << t
40
                         << ") must not be greater than forward measure time ("
41
                         << getForwardMeasureTime() << ") and non-negative");
42
    }
12,884,763✔
43

44
    Real GsrProcess::time(const Date &d) const {
×
45
        QL_REQUIRE(
×
46
            referenceDate_ != Date() && dc_ != DayCounter(),
47
            "time can not be computed without reference date and day counter");
48
        return dc_.yearFraction(referenceDate_, d);
×
49
    }
50

51
    Real GsrProcess::x0() const { return 0.0; }
×
52

53
    Real GsrProcess::drift(Time t, Real x) const {
×
54
        return core_.y(t) -
×
55
               core_.G(t, getForwardMeasureTime()) * sigma(t) * sigma(t) -
×
56
               reversion(t) * x;
×
57
    }
58

59
    Real GsrProcess::diffusion(Time t, Real) const {
×
60
        checkT(t);
×
61
        return sigma(t);
×
62
    }
63

64
    Real GsrProcess::expectation(Time w, Real xw, Time dt) const {
4,306,693✔
65
        checkT(w + dt);
4,306,693✔
66
        return core_.expectation_x0dep_part(w, xw, dt) +
4,306,693✔
67
               core_.expectation_rn_part(w, dt) +
4,306,693✔
68
               core_.expectation_tf_part(w, dt);
4,306,693✔
69
    }
70

71

72

73
    Real GsrProcess::stdDeviation(Time t0, Real x0, Time dt) const {
4,294,303✔
74
        return std::sqrt(variance(t0, x0, dt));
4,294,303✔
75
    }
76

77
    Real GsrProcess::variance(Time w, Real, Time dt) const {
4,306,693✔
78
        checkT(w + dt);
4,306,693✔
79
        return core_.variance(w,dt);
4,306,693✔
80
    }
81

82
    Real GsrProcess::sigma(Time t) const { return core_.sigma(t); }
×
83

84
    Real GsrProcess::reversion(Time t) const { return core_.reversion(t); }
×
85

86
    Real GsrProcess::y(Time t) const {
4,271,377✔
87
        checkT(t);
4,271,377✔
88
        return core_.y(t);
4,271,377✔
89
    }
90

91
    Real GsrProcess::G(Time t, Time w, Real) const {
4,271,377✔
92
        QL_REQUIRE(w >= t, "G(t,w) should be called with w ("
4,271,377✔
93
                               << w << ") not lesser than t (" << t << ")");
94
        QL_REQUIRE(t >= 0.0 && w <= getForwardMeasureTime(),
4,271,377✔
95
                   "G(t,w) should be called with (t,w)=("
96
                       << t << "," << w << ") in Range [0,"
97
                       << getForwardMeasureTime() << "].");
98

99
        return core_.G(t,w);
4,271,377✔
100
    }
101

102

103
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc