# QuantLib_Basket man page

Basket —

## Synopsis

`#include <ql/experimental/credit/basket.hpp>`

Inherits **LazyObject**.

### Public Member Functions

Basket(constDate&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>(newFaceValueClaim()))

voidupdate()

voidcomputeBasket() constSize size() constBasketinception number of counterparties.

const std::vector< std::string > &names() constBasketcounterparties names at inception.

const std::vector<Real> ¬ionals() constBasketcounterparties notionals at inception.Real notional()Baskettotal notional at inception.Real exposure(const std::string &name, constDate&=Date()) const

Returns the total expected exposures for that name.

const boost::shared_ptr< Pool > &pool() const

Underlying pool.Disposable< std::vector<DefaultProbKey> >defaultKeys() const

The keys each counterparty enters the basket with (sensitive to)

constDate&refDate() constBasketinception date.Real attachmentRatio() constReal 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 counterpartiesDisposable< std::vector<Probability> >probabilities(constDate&d) constReal settledLoss() constReal settledLoss(constDate&) constReal cumulatedLoss() constReal cumulatedLoss(constDate&) constReal remainingNotional() constReal remainingNotional(constDate&) const

const std::vector<Real> &remainingNotionals() constDisposable< std::vector<Real> >remainingNotionals(constDate&) const

const std::vector< std::string > &remainingNames() constDisposable< std::vector< std::string > >remainingNames(constDate&) const

const std::vector<DefaultProbKey> &remainingDefaultKeys() constDisposable< std::vector<DefaultProbKey> >remainingDefaultKeys(constDate&) constSize remainingSize() const

Number of counterparties alive on the requested date.Size remainingSize(constDate&) constDisposable< std::vector<Probability> >remainingProbabilities(constDate&d) constReal remainingAttachmentAmount() constReal remainingAttachmentAmount(constDate&endDate) constReal remainingDetachmentAmount() constReal remainingDetachmentAmount(constDate&endDate) constReal remainingTrancheNotional() const

Remaining basket tranched notional on calculation date.Real remainingTrancheNotional(constDate&endDate) const

const std::vector<Size> &liveList() const

Indexes of remaining names. Notice these are names and not positions.Disposable< std::vector<Size> >liveList(constDate&) const

voidsetLossModel(const boost::shared_ptr<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(constDate&d) constProbability probOverLoss(constDate&d,ReallossFraction) constReal percentile(constDate&d,Probabilityprob) constReal expectedShortfall(constDate&d,Probabilityprob) constDisposable< std::vector<Real> >splitVaRLevel(constDate&date,Realloss) constDisposable< std::map<Real,Probability> >lossDistribution(constDate&) constReal densityTrancheLoss(constDate&d,ReallossFraction) constReal defaultCorrelation(constDate&d,SizeiName,SizejName) const

std::vector<Probability>probsBeingNthEvent(Sizen, constDate&d) constProbability probAtLeastNEvents(Sizen, constDate&d) constReal recoveryRate(constDate&d,SizeiName) const

### Additional Inherited Members

## Detailed Description

Credit **Basket**.

A basket is a collection of credit names, represented by a unique identifier (a text string), associated notional amounts, a pool and tranche information. The pool is a map of 'names' to issuers. The **Basket** structure is motivated by **CDO** squared instruments containing various underlying inner CDOs which can be represented by respective baskets including their tranche structure. The role of the Pool is providing a unique list of relevant issuers while names may appear multiple times across different baskets (overlap).

## Constructor & Destructor Documentation

## Member Function Documentation

### void update () [virtual]

This method must be implemented in derived classes. An instance of Observer does not call this method directly: instead, it will be called by the observables the instance registered with when they need to notify any changes.

Implements **Observer**.

### 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.

### Disposable<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

### Disposable<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

**Parameters:**

*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

### Disposable<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.

**Parameters:**

*n* The internal index to the name, it should be live 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?????<<<<<<<<<<<<<<<<<<<<<<<

## Author

Generated automatically by Doxygen for QuantLib from the source code.

## Referenced By

attachmentAmount(3), attachmentRatio(3), Basket(3), basketNotional(3), claim(3), computeBasket(3), cumulatedLoss(3), defaultCorrelation(3), defaultKeys(3), densityTrancheLoss(3), detachmentAmount(3), detachmentRatio(3), expectedShortfall(3), expectedTrancheLoss(3), exposure(3), liveList(3), lossDistribution(3), names(3), notional(3), notionals(3), percentile(3), pool(3), probabilities(3), probAtLeastNEvents(3), probOverLoss(3), probsBeingNthEvent(3), recoveryRate(3), refDate(3), remainingAttachmentAmount(3), remainingDefaultKeys(3), remainingDetachmentAmount(3), remainingNames(3), remainingNotional(3), remainingNotionals(3), remainingProbabilities(3), remainingSize(3), remainingTrancheNotional(3), setLossModel(3), settledLoss(3), splitVaRLevel(3) and trancheNotional(3) are aliases of QuantLib_Basket(3).