#include <qle/models/basket.hpp>
Public Member Functions | |
Basket (const Date &refDate, const std::vector< std::string > &names, const std::vector< Real > ¬ionals, const boost::shared_ptr< Pool > pool, Real attachmentRatio=0.0, Real detachmentRatio=1.0, const boost::shared_ptr< Claim > &claim=boost::shared_ptr< Claim >(new FaceValueClaim())) | |
void | computeBasket () const |
Size | size () const |
Basket inception number of counterparties. | |
const std::vector< std::string > & | names () const |
Basket counterparties names at inception. | |
const std::vector< Real > & | notionals () const |
Basket counterparties notionals at inception. | |
Real | exposure (const std::string &name, const Date &=Date()) const |
Returns the total expected exposures for that name. | |
const boost::shared_ptr< Pool > & | pool () const |
Underlying pool. | |
std::vector< DefaultProbKey > | defaultKeys () const |
The keys each counterparty enters the basket with (sensitive to) | |
const Date & | refDate () const |
Basket inception date. More... | |
Real | attachmentRatio () const |
Real | detachmentRatio () const |
Detachment point expressed as a fraction of the total pool notional. | |
Real | basketNotional () const |
Original basket notional ignoring any losses. | |
Real | trancheNotional () const |
Original tranche notional ignoring any realized losses. | |
Real | attachmentAmount () const |
Attachment amount = attachmentRatio() * basketNotional() | |
Real | detachmentAmount () const |
Detachment amount = detachmentRatio() * basketNotional() | |
boost::shared_ptr< Claim > | claim () const |
default claim, same for all positions and counterparties | |
std::vector< Probability > | probabilities (const Date &d) const |
Real | settledLoss () const |
Real | settledLoss (const Date &) const |
Real | cumulatedLoss () const |
Real | cumulatedLoss (const Date &) const |
Real | remainingNotional () const |
Real | remainingNotional (const Date &) const |
const std::vector< Real > & | remainingNotionals () const |
std::vector< Real > | remainingNotionals (const Date &) const |
const std::vector< std::string > & | remainingNames () const |
std::vector< std::string > | remainingNames (const Date &) const |
const std::vector< DefaultProbKey > & | remainingDefaultKeys () const |
std::vector< DefaultProbKey > | remainingDefaultKeys (const Date &) const |
Size | remainingSize () const |
Number of counterparties alive on the requested date. | |
Size | remainingSize (const Date &) const |
std::vector< Probability > | remainingProbabilities (const Date &d) const |
Real | remainingAttachmentAmount () const |
Real | remainingAttachmentAmount (const Date &endDate) const |
Real | remainingDetachmentAmount () const |
Real | remainingDetachmentAmount (const Date &endDate) const |
Real | remainingTrancheNotional () const |
Remaining basket tranched notional on calculation date. | |
Real | remainingTrancheNotional (const Date &endDate) const |
const std::vector< Size > & | liveList () const |
Indexes of remaining names. Notice these are names and not positions. | |
std::vector< Size > | liveList (const Date &) const |
void | setLossModel (const boost::shared_ptr< QuantExt::DefaultLossModel > &lossModel) |
Assigns the default loss model to this basket. Resets calculations. | |
Basket Loss Statistics | |
Methods providing statistical metrics on the loss or value distribution of the basket. Most calculations rely on the pressence of a model assigned to the basket. | |
Real | expectedTrancheLoss (const Date &d, Real recoveryRate=Null< Real >()) const |
Probability | probOverLoss (const Date &d, Real lossFraction) const |
Real | percentile (const Date &d, Probability prob) const |
Real | expectedShortfall (const Date &d, Probability prob) const |
std::vector< Real > | splitVaRLevel (const Date &date, Real loss) const |
std::map< Real, Probability > | lossDistribution (const Date &) const |
Real | densityTrancheLoss (const Date &d, Real lossFraction) const |
Real | defaultCorrelation (const Date &d, Size iName, Size jName) const |
std::vector< Probability > | probsBeingNthEvent (Size n, const Date &d) const |
Probability | probAtLeastNEvents (Size n, const Date &d) const |
Real | recoveryRate (const Date &d, Size iName) const |
QuantLib::Real | correlation () const |
Credit Basket.
Basket | ( | const Date & | refDate, |
const std::vector< std::string > & | names, | ||
const std::vector< Real > & | notionals, | ||
const boost::shared_ptr< Pool > | pool, | ||
Real | attachmentRatio = 0.0 , |
||
Real | detachmentRatio = 1.0 , |
||
const boost::shared_ptr< Claim > & | claim = boost::shared_ptr< Claim >(new FaceValueClaim()) |
||
) |
Constructs a basket of simple collection of constant notional positions subject to default risk only.
The refDate parameter is the basket inception date, that is, the date at which defaultable events are relevant. (There are no constraints on forward baskets but models assigned should be consistent.)
const Date& refDate | ( | ) | const |
Basket inception date.
Loss Given Default for all issuers/notionals based on expected recovery rates for the respective issuers.
Real attachmentRatio | ( | ) | const |
Attachment point expressed as a fraction of the total inception notional.
std::vector<Probability> probabilities | ( | const Date & | d | ) | const |
Vector of cumulative default probability to date d for all issuers in the basket.
Real settledLoss | ( | ) | const |
Realized basket losses between the reference date and the calculation date, taking the actual recovery rates of loss events into account. Only default events that have settled (have a realized RR) are accounted for. For contingent losses after a default you need to compute the losses through a DefaultLossModel
Optionally one can pass a date in the future and that will collect events stored in the issuers list. This shows the effect of 'programmed' (after today's) events on top of past ones. The intention is to be used in risk analysis (jump to default, etc).
Real cumulatedLoss | ( | ) | const |
Actual basket losses between the reference date and the calculation date, taking the actual recovery rates of loss events into account. If the event has not settled yet a model driven recovery is used.
Returns the realized losses in this portfolio since the portfolio default reference date. This method relies on an implementation of the loss given default since the events have not necessarily settled.
Real remainingNotional | ( | ) | const |
Remaining full basket (untranched) notional after settled losses between the reference date and the given date. The full notional for defaulted names is subracted, recovery ignored.
const std::vector< Real > & remainingNotionals | ( | ) | const |
Vector of surviving notionals after settled losses between the reference date and the given date, recovery ignored.
const std::vector< std::string > & remainingNames | ( | ) | const |
Vector of surviving issuers after defaults between the reference basket date and the given (or evaluation) date.
const std::vector< DefaultProbKey > & remainingDefaultKeys | ( | ) | const |
Default keys of non defaulted counterparties
std::vector<Probability> remainingProbabilities | ( | const Date & | d | ) | const |
Vector of cumulative default probability to date d for all issuers still (at the evaluation date) alive in the basket.
Real remainingAttachmentAmount | ( | ) | const |
Attachment amount of the equivalent (after defaults) remaining basket The remaining attachment amount is RAA = max (0, attachmentAmount - cumulatedLoss())
The remaining attachment ratio is then RAR = RAA / remainingNotional()
Real remainingDetachmentAmount | ( | ) | const |
Detachment amount of the equivalent remaining basket. The remaining detachment amount is RDA = max (0, detachmentAmount - cumulatedLoss())
The remaining detachment ratio is then RDR = RDA / remainingNotional()
Real remainingTrancheNotional | ( | const Date & | endDate | ) | const |
Expected basket tranched notional on the requested date according to the basket model. Model should have been assigned.
Probability probOverLoss | ( | const Date & | d, |
Real | lossFraction | ||
) | const |
The lossFraction is the fraction of losses expressed in inception (no losses) tranche units (e.g. 'attach level'=0%, 'detach level'=100%)
Real expectedShortfall | ( | const Date & | d, |
Probability | prob | ||
) | const |
ESF
std::map<Real, Probability> lossDistribution | ( | const Date & | ) | const |
Full loss distribution
std::vector<Probability> probsBeingNthEvent | ( | Size | n, |
const Date & | d | ||
) | const |
Probability vector that each of the remaining live names (at eval date) is the n-th default by date d.
The n parameter is the internal index to the name; it should be alive at the evaluation date.
------—TO DO: Implement with a string passed-------------------— ------—TO DO: Perform check the name is alive------------------—
Probability probAtLeastNEvents | ( | Size | n, |
const Date & | d | ||
) | const |
Returns the probaility of having a given or larger number of defaults in the basket portfolio at a given time.
Real recoveryRate | ( | const Date & | d, |
Size | iName | ||
) | const |
Expected recovery rate of the underlying position as a fraction of its exposure value at date d given it has defaulted on that date. NOTICE THE ARG IS THE CTPTY....SHOULDNT IT BE THE POSITION/INSTRUMENT?????<<<<<<<<<<<<<<<<<<<<<<<
QuantLib::Real correlation | ( | ) | const |
Return single correlation number from the underlying loss model if it is a one factor model. If the underlying loss model is null, this returns a Null<Real>()
.