#include <orea/aggregation/creditmigrationhelper.hpp>
Public Types | |
enum class | CreditMode { Migration , Default } |
enum class | LoanExposureMode { Notional , Value } |
enum class | Evaluation { Analytic , ForwardSimulationA , ForwardSimulationB , TerminalSimulation } |
Public Member Functions | |
CreditMigrationHelper (const QuantLib::ext::shared_ptr< CreditSimulationParameters > parameters, const QuantLib::ext::shared_ptr< NPVCube > cube, const QuantLib::ext::shared_ptr< NPVCube > nettedCube, const QuantLib::ext::shared_ptr< AggregationScenarioData > aggData, const Size cubeIndexCashflows, const Size cubeIndexStateNpvs, const Real distributionLowerBound, const Real distributionUpperBound, const Size buckets, const Matrix &globalFactorCorrelation, const std::string &baseCurrency) | |
void | build (const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > &trades) |
builds the helper for a specific subset of trades stored in the cube More... | |
const std::vector< Real > & | upperBucketBound () const |
Array | pnlDistribution (const Size date) |
Private Member Functions | |
std::map< string, Matrix > | rescaledTransitionMatrices (const Size date) |
void | init () |
void | initEntityStateSimulation () |
Allocate 3d storage for the simulated idiosyncratic factors by entity, date and sample. More... | |
std::vector< Matrix > | initEntityStateSimulation (const Size date, const Size path) |
void | simulateEntityStates (const std::vector< Matrix > &cond, const Size path, const MersenneTwisterUniformRng &mt) |
Size | simulatedEntityState (const Size i, const Size path) const |
Look up the simulated entity credit state for the given entity, date and path. More... | |
Real | generateMigrationPnl (const Size date, const Size path, const Size n) const |
void | generateConditionalMigrationPnl (const Size date, const Size path, const std::map< string, Matrix > &transMat, std::vector< Array > &condProbs, std::vector< Array > &pnl) const |
Private Attributes | |
QuantLib::ext::shared_ptr< CreditSimulationParameters > | parameters_ |
QuantLib::ext::shared_ptr< NPVCube > | cube_ |
QuantLib::ext::shared_ptr< NPVCube > | nettedCube_ |
QuantLib::ext::shared_ptr< AggregationScenarioData > | aggData_ |
Size | cubeIndexCashflows_ |
Size | cubeIndexStateNpvs_ |
Matrix | globalFactorCorrelation_ |
std::string | baseCurrency_ |
CreditMode | creditMode_ |
LoanExposureMode | loanExposureMode_ |
Evaluation | evaluation_ |
std::vector< Real > | cubeTimes_ |
QuantExt::Bucketing | bucketing_ |
std::vector< std::set< std::string > > | issuerTradeIds_ |
std::vector< std::set< std::string > > | cptyNettingSetIds_ |
std::map< std::string, std::string > | tradeCreditCurves_ |
std::map< std::string, Real > | tradeNotionals_ |
std::map< std::string, std::string > | tradeCurrencies_ |
std::map< std::string, Size > | tradeCdsCptyIdx_ |
Size | n_ |
std::vector< std::map< string, Matrix > > | rescaledTransitionMatrices_ |
std::vector< Real > | globalVar_ |
std::vector< std::vector< Size > > | simulatedEntityState_ |
std::vector< std::vector< Matrix > > | entityStateSimulationMatrices_ |
std::vector< std::vector< std::vector< Real > > > | globalStates_ |
Helper for credit migration risk calculation Dynamics of entity i's state X_i: \( dX_i = dY_i + dZ_i \) with
Definition at line 51 of file creditmigrationhelper.hpp.
|
strong |
Enumerator | |
---|---|
Migration | |
Default |
Definition at line 53 of file creditmigrationhelper.hpp.
|
strong |
Enumerator | |
---|---|
Notional | |
Value |
Definition at line 54 of file creditmigrationhelper.hpp.
|
strong |
Enumerator | |
---|---|
Analytic | |
ForwardSimulationA | |
ForwardSimulationB | |
TerminalSimulation |
Definition at line 55 of file creditmigrationhelper.hpp.
CreditMigrationHelper | ( | const QuantLib::ext::shared_ptr< CreditSimulationParameters > | parameters, |
const QuantLib::ext::shared_ptr< NPVCube > | cube, | ||
const QuantLib::ext::shared_ptr< NPVCube > | nettedCube, | ||
const QuantLib::ext::shared_ptr< AggregationScenarioData > | aggData, | ||
const Size | cubeIndexCashflows, | ||
const Size | cubeIndexStateNpvs, | ||
const Real | distributionLowerBound, | ||
const Real | distributionUpperBound, | ||
const Size | buckets, | ||
const Matrix & | globalFactorCorrelation, | ||
const std::string & | baseCurrency | ||
) |
Definition at line 41 of file creditmigrationhelper.cpp.
void build | ( | const std::map< std::string, QuantLib::ext::shared_ptr< Trade > > & | trades | ) |
builds the helper for a specific subset of trades stored in the cube
Definition at line 584 of file creditmigrationhelper.cpp.
const std::vector< Real > & upperBucketBound | ( | ) | const |
Definition at line 67 of file creditmigrationhelper.hpp.
Array pnlDistribution | ( | const Size | date | ) |
Definition at line 447 of file creditmigrationhelper.cpp.
|
private |
Get the transition matrix from today to date by entity, sanitise the annual transition matrix input, rescale to the desired horizon/date using the generator, cache the result so that we do the sanitising/rescaling only once
Definition at line 87 of file creditmigrationhelper.cpp.
|
private |
Initialise
Definition at line 147 of file creditmigrationhelper.cpp.
|
private |
Allocate 3d storage for the simulated idiosyncratic factors by entity, date and sample.
Definition at line 200 of file creditmigrationhelper.cpp.
|
private |
Initialise the entity state simulationn for a given date for Evaluation = TerminalSimulation: Return transition matrix for each entity for the given date, conditional on the global terminal state on the given path
Definition at line 211 of file creditmigrationhelper.cpp.
|
private |
Generate one entity state sample path for all entities given the global state path and given the conditional transition matrices for all entities at the terminal date.
Definition at line 256 of file creditmigrationhelper.cpp.
|
private |
Look up the simulated entity credit state for the given entity, date and path.
Definition at line 275 of file creditmigrationhelper.cpp.
|
private |
Return a single PnL impact due to credit migration or default of Bond/CDS issuers and default of netting set counterparties on the given global path
Definition at line 281 of file creditmigrationhelper.cpp.
|
private |
Return a vector of PnL impacts and associated conditional probabilities for the specified global path, due to credit migration or default of Bond/CDS issuers and default of netting set counterparties
Definition at line 346 of file creditmigrationhelper.cpp.
|
private |
Definition at line 109 of file creditmigrationhelper.hpp.
|
private |
Definition at line 110 of file creditmigrationhelper.hpp.
|
private |
Definition at line 110 of file creditmigrationhelper.hpp.
|
private |
Definition at line 111 of file creditmigrationhelper.hpp.
|
private |
Definition at line 112 of file creditmigrationhelper.hpp.
|
private |
Definition at line 112 of file creditmigrationhelper.hpp.
|
private |
Definition at line 113 of file creditmigrationhelper.hpp.
|
private |
Definition at line 114 of file creditmigrationhelper.hpp.
|
private |
Definition at line 116 of file creditmigrationhelper.hpp.
|
private |
Definition at line 117 of file creditmigrationhelper.hpp.
|
private |
Definition at line 118 of file creditmigrationhelper.hpp.
|
private |
Definition at line 119 of file creditmigrationhelper.hpp.
|
private |
Definition at line 121 of file creditmigrationhelper.hpp.
|
private |
Definition at line 123 of file creditmigrationhelper.hpp.
|
private |
Definition at line 124 of file creditmigrationhelper.hpp.
|
private |
Definition at line 126 of file creditmigrationhelper.hpp.
|
private |
Definition at line 127 of file creditmigrationhelper.hpp.
|
private |
Definition at line 128 of file creditmigrationhelper.hpp.
|
private |
Definition at line 129 of file creditmigrationhelper.hpp.
|
private |
Definition at line 132 of file creditmigrationhelper.hpp.
|
private |
Definition at line 133 of file creditmigrationhelper.hpp.
|
private |
Definition at line 135 of file creditmigrationhelper.hpp.
|
private |
Definition at line 137 of file creditmigrationhelper.hpp.
|
private |
Definition at line 139 of file creditmigrationhelper.hpp.
|
private |
Definition at line 141 of file creditmigrationhelper.hpp.