Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
cvaspreadsensitivitycalculator.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2020 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file orea/aggregation/dimcalculator.hpp
20 \brief Dynamic Initial Margin calculator base class
21 \ingroup analytics
22*/
23
24#pragma once
25
30
34
35#include <ql/time/date.hpp>
36
37#include <ql/shared_ptr.hpp>
38
39namespace ore {
40namespace analytics {
41using namespace QuantLib;
42using namespace QuantExt;
43using namespace data;
44using namespace std;
45
46//! CVA Spread Sensitivity Calculator
47/*!
48 Compute hazard rate and CDS spread sensitivities for a given exposure profile
49 on an externally provided sensitivity grid.
50*/
52public:
53 CVASpreadSensitivityCalculator(//! For logging purposes to distinguish sensi runs, e.g. for different netting sets
54 const std::string& key,
55 //! Asof date
56 const Date& asof,
57 //! Netting set EPE profile
58 const vector<Real>& epe,
59 //! Date grid
60 const vector<Date>& dates,
61 //! Default term structure for the netting set
62 const Handle<DefaultProbabilityTermStructure>& dts,
63 //! Market recovery rate
64 const Real& recovery,
65 //! CDS Discount curve
66 const Handle<YieldTermStructure>& yts,
67 //! Shift grid
68 const vector<Period>& shiftTenors,
69 //! Shift size
70 Real shiftSize = 0.0001);
71
72 //! Inspectors
73 // @{
74 const string key() { return key_; }
75 Date asof() { return asof_; }
76 const vector<Real>& exposureProfile() { return epe_; }
77 const vector<Date>& exposureDateGrid() { return dates_; }
78 const Handle<DefaultProbabilityTermStructure>& defaultTermStructure() { return dts_; }
79 Real recoveryRate() { return recovery_; }
80 const Handle<YieldTermStructure>& discountCurve() { return yts_; }
81 const vector<Period> shiftTenors() { return shiftTenors_; }
82 // @}
83
84 //! Results
85 // @{
86 const vector<Real> shiftTimes() { return shiftTimes_; }
87 Real shiftSize() { return shiftSize_; }
88 const vector<Real> hazardRateSensitivities() { return hazardRateSensitivities_; }
89 const vector<Real> cdsSpreadSensitivities() { return cdsSpreadSensitivities_; }
90 const Matrix& jacobi() { return jacobi_; }
91 // @}
92
93private:
94 // survival probability with shifted hazard rates in the specified bucket
95 Real survivalProbability(Date d, bool shift, Size index);
96 Real survivalProbability(Time t, bool shift, Size index);
97 // CVA calculation with and without shifted hazard rates
98 Real cva(bool shift = false, Size index = 0);
99 //! Fair CDS Spread calculation with and without shifted hazard rates
100 Real fairCdsSpread(Size term, bool shift = false, Size index = 0);
101
102 string key_;
103 Date asof_;
104 vector<Real> epe_;
105 vector<Date> dates_;
106 Handle<DefaultProbabilityTermStructure> dts_;
108 Handle<YieldTermStructure> yts_;
109 vector<Period> shiftTenors_;
110
111 vector<Real> shiftTimes_;
115 Matrix jacobi_;
116};
117
118} // namespace analytics
119} // namespace ore
this class holds data associated to scenarios
const Handle< DefaultProbabilityTermStructure > & defaultTermStructure()
Real fairCdsSpread(Size term, bool shift=false, Size index=0)
Fair CDS Spread calculation with and without shifted hazard rates.
Collateral Exposure Helper Functions (stored in base currency)
class describing the layout of an npv cube and aggregation scenario data
A cube implementation that stores the cube in memory.
data