23#ifndef quantext_basket_hpp
24#define quantext_basket_hpp
26#include <ql/experimental/credit/defaultprobabilitykey.hpp>
27#include <ql/experimental/credit/issuer.hpp>
28#include <ql/experimental/credit/loss.hpp>
29#include <ql/experimental/credit/pool.hpp>
30#include <ql/experimental/credit/recoveryratemodel.hpp>
31#include <ql/instruments/claim.hpp>
32#include <ql/patterns/lazyobject.hpp>
33#include <ql/termstructures/defaulttermstructure.hpp>
39class DefaultLossModel;
65 const QuantLib::ext::shared_ptr<Claim>&
claim = QuantLib::ext::shared_ptr<Claim>(
new FaceValueClaim()));
67 Date today = Settings::instance().evaluationDate();
86 const std::vector<std::string>&
names()
const {
return pool_->names(); }
88 const std::vector<Real>&
notionals()
const;
90 Real
exposure(
const std::string& name,
const Date& = Date())
const;
92 const QuantLib::ext::shared_ptr<Pool>&
pool()
const;
219 const std::vector<Size>&
liveList()
const;
220 std::vector<Size>
liveList(
const Date&)
const;
223 void setLossModel(
const QuantLib::ext::shared_ptr<QuantExt::DefaultLossModel>& lossModel);
235 Probability
probOverLoss(
const Date& d, Real lossFraction)
const;
238 Real
percentile(
const Date& d, Probability prob)
const;
244 std::vector<Real>
splitVaRLevel(
const Date& date, Real loss)
const;
280 QuantLib::ext::shared_ptr<Pool>
pool_;
282 const QuantLib::ext::shared_ptr<Claim>
claim_;
314 QuantLib::ext::shared_ptr<QuantExt::DefaultLossModel>
lossModel_;
std::vector< Probability > probabilities(const Date &d) const
Real recoveryRate(const Date &d, Size iName) const
Real evalDateAttachAmount_
void performCalculations() const override
Real defaultCorrelation(const Date &d, Size iName, Size jName) const
Real detachmentAmount_
basket tranched inception detachment amount:
Real remainingAttachmentAmount() const
Real detachmentAmount() const
Detachment amount = detachmentRatio() * basketNotional()
const std::vector< DefaultProbKey > & remainingDefaultKeys() const
Real evalDateSettledLoss_
std::vector< DefaultProbKey > evalDateLiveKeys_
std::vector< Real > evalDateLiveNotionals_
const std::vector< Real > & notionals() const
Basket counterparties notionals at inception.
Real remainingTrancheNotional() const
Remaining basket tranched notional on calculation date.
std::vector< Size > evalDateLiveList_
Real attachmentAmount_
basket tranched inception attachment amount:
QuantLib::ext::shared_ptr< Pool > pool_
const QuantLib::ext::shared_ptr< Claim > claim_
The claim is the same for all names.
Real detachmentRatio() const
Detachment point expressed as a fraction of the total pool notional.
Real attachmentRatio() const
std::vector< DefaultProbKey > defaultKeys() const
The keys each counterparty enters the basket with (sensitive to)
QuantLib::Real correlation() const
Real attachmentAmount() const
Attachment amount = attachmentRatio() * basketNotional()
void computeBasket() const
const Date refDate_
Basket inception date.
Probability probOverLoss(const Date &d, Real lossFraction) const
std::vector< Real > notionals_
Size remainingSize() const
Number of counterparties alive on the requested date.
Real remainingTrancheNotional(const Date &endDate) const
Real exposure(const std::string &name, const Date &=Date()) const
Returns the total expected exposures for that name.
Real densityTrancheLoss(const Date &d, Real lossFraction) const
Real trancheNotional_
basket tranched notional amount:
Probability probAtLeastNEvents(Size n, const Date &d) const
Real evalDateRemainingNot_
const std::vector< Size > & liveList() const
Indexes of remaining names. Notice these are names and not positions.
const std::vector< std::string > & names() const
Basket counterparties names at inception.
const QuantLib::ext::shared_ptr< Pool > & pool() const
Underlying pool.
QuantLib::ext::shared_ptr< Claim > claim() const
default claim, same for all positions and counterparties
const Date & refDate() const
Basket inception date.
Real percentile(const Date &d, Probability prob) const
Size remainingSize(const Date &) const
std::vector< std::string > evalDateLiveNames_
Real expectedTrancheLoss(const Date &d, Real recoveryRate=Null< Real >()) const
QuantLib::ext::shared_ptr< QuantExt::DefaultLossModel > lossModel_
std::vector< Probability > probsBeingNthEvent(Size n, const Date &d) const
Real basketNotional() const
Original basket notional ignoring any losses.
Real trancheNotional() const
Original tranche notional ignoring any realized losses.
Real remainingDetachmentAmount() const
Size size() const
Basket inception number of counterparties.
const std::vector< std::string > & remainingNames() const
Real expectedShortfall(const Date &d, Probability prob) const
std::vector< Real > splitVaRLevel(const Date &date, Real loss) const
Real cumulatedLoss() const
void setLossModel(const QuantLib::ext::shared_ptr< QuantExt::DefaultLossModel > &lossModel)
Assigns the default loss model to this basket. Resets calculations.
const std::vector< Real > & remainingNotionals() const
Real evalDateDetachAmmount_
std::vector< Probability > remainingProbabilities(const Date &d) const
Real remainingNotional() const
std::map< Real, Probability > lossDistribution(const Date &) const