QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.38
Loading...
Searching...
No Matches
creditriskplus.hpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2013 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 creditriskplus.hpp
21 \brief Extended CreditRisk+ Model
22*/
23
24#ifndef quantlib_creditriskplus_hpp
25#define quantlib_creditriskplus_hpp
26
27#include <ql/qldefines.hpp>
28#include <ql/types.hpp>
29#include <ql/math/matrix.hpp>
30#include <vector>
31
32namespace QuantLib {
33
34 /*! Extended CreditRisk+ model as described in [1] Integrating Correlations, Risk,
35 July 1999 and the references therein.
36
37 \warning the input correlation matrix is not checked for positive
38 definiteness
39
40 \deprecated Out of scope; copy this class in your codebase if needed.
41 Deprecated in version 1.36.
42 */
43 class [[deprecated("Out of scope; copy this class in your codebase if needed")]] CreditRiskPlus {
44
45 public:
46 CreditRiskPlus(std::vector<Real> exposure,
47 std::vector<Real> defaultProbability,
48 std::vector<Size> sector,
49 std::vector<Real> relativeDefaultVariance,
50 Matrix correlation,
51 Real unit);
52
53 const std::vector<Real> &loss() { return loss_; }
54 const std::vector<Real> &marginalLoss() { return marginalLoss_; }
55
56 Real exposure() const { return exposureSum_; }
57 Real expectedLoss() const { return el_; }
58 Real unexpectedLoss() const { return ul_; }
60 return (unexpectedLoss() * unexpectedLoss() - el2_) /
61 (expectedLoss() * expectedLoss());
62 }
63
64 const std::vector<Real> &sectorExposures() const {
65 return sectorExposure_;
66 }
67 const std::vector<Real> &sectorExpectedLoss() const {
68 return sectorEl_;
69 }
70 const std::vector<Real> &sectorUnexpectedLoss() const {
71 return sectorUl_;
72 }
73
74 Real lossQuantile(Real p);
75
76 private:
77
78 const std::vector<Real> exposure_;
79 const std::vector<Real> pd_;
80 const std::vector<Size> sector_;
81 const std::vector<Real> relativeDefaultVariance_;
83 const Real unit_;
84
85 Size n_, m_; // number of sectors, exposures
86
87 std::vector<Real> sectorExposure_, sectorEl_, sectorUl_, marginalLoss_,
89
90 Real exposureSum_, el_, el2_, ul_;
91 unsigned long upperIndex_;
92
93 void compute();
94 };
95}
96
97#endif
const std::vector< Real > & marginalLoss()
std::vector< Real > loss_
const std::vector< Real > exposure_
Real relativeDefaultVariance() const
const std::vector< Real > relativeDefaultVariance_
const std::vector< Real > & loss()
const std::vector< Real > pd_
const std::vector< Real > & sectorExpectedLoss() const
const std::vector< Size > sector_
const std::vector< Real > & sectorExposures() const
const std::vector< Real > & sectorUnexpectedLoss() const
std::vector< Real > marginalLoss_
Matrix used in linear algebra.
Definition: matrix.hpp:41
QL_REAL Real
real number
Definition: types.hpp:50
std::size_t Size
size of a container
Definition: types.hpp:58
matrix used in linear algebra.
Definition: any.hpp:37
Global definitions and compiler switches.
Custom types.