QuantLib: a free/open-source library for quantitative finance
Fully annotated sources - version 1.32
Loading...
Searching...
No Matches
creditriskplus.hpp
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
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
43
44 public:
45 CreditRiskPlus(std::vector<Real> exposure,
46 std::vector<Real> defaultProbability,
47 std::vector<Size> sector,
48 std::vector<Real> relativeDefaultVariance,
49 Matrix correlation,
50 Real unit);
51
52 const std::vector<Real> &loss() { return loss_; }
53 const std::vector<Real> &marginalLoss() { return marginalLoss_; }
54
55 Real exposure() const { return exposureSum_; }
56 Real expectedLoss() const { return el_; }
57 Real unexpectedLoss() const { return ul_; }
59 return (unexpectedLoss() * unexpectedLoss() - el2_) /
61 }
62
63 const std::vector<Real> &sectorExposures() const {
64 return sectorExposure_;
65 }
66 const std::vector<Real> &sectorExpectedLoss() const {
67 return sectorEl_;
68 }
69 const std::vector<Real> &sectorUnexpectedLoss() const {
70 return sectorUl_;
71 }
72
74
75 private:
76
77 const std::vector<Real> exposure_;
78 const std::vector<Real> pd_;
79 const std::vector<Size> sector_;
80 const std::vector<Real> relativeDefaultVariance_;
82 const Real unit_;
83
84 Size n_, m_; // number of sectors, exposures
85
88
90 unsigned long upperIndex_;
91
92 void compute();
93 };
94}
95
96#endif
const std::vector< Real > & marginalLoss()
std::vector< Real > loss_
const std::vector< Real > exposure_
Real relativeDefaultVariance() const
std::vector< Real > sectorEl_
std::vector< Real > sectorExposure_
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_
std::vector< Real > sectorUl_
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
Definition: any.hpp:35