21#ifndef quantlib_homogenous_pool_default_model_hpp
22#define quantlib_homogenous_pool_default_model_hpp
42 template<
class copulaPolicy>
60 "Inhomogeneous model not implemented for multifactor");
85 const ext::shared_ptr<ConstantLossLatentmodel<copulaPolicy> >
copula_;
110 attach_ = std::min(basket_->remainingAttachmentAmount() /
111 basket_->remainingNotional(), 1.);
112 detach_ = std::min(basket_->remainingDetachmentAmount() /
113 basket_->remainingNotional(), 1.);
114 notional_ = basket_->remainingNotional();
115 notionals_ = basket_->remainingNotionals();
116 attachAmount_ = basket_->remainingAttachmentAmount();
117 detachAmount_ = basket_->remainingDetachmentAmount();
119 copula_->resetBasket(basket_.currentLink());
128 std::vector<Real> lgd;
129 std::vector<Real> recoveries = copula_->recoveries();
130 std::transform(recoveries.begin(), recoveries.end(),
131 std::back_inserter(lgd),
132 [](
Real x) ->
Real { return 1.0-x; });
133 std::transform(lgd.begin(), lgd.end(), notionals_.begin(),
134 lgd.begin(), std::multiplies<>());
135 std::vector<Real> prob = basket_->remainingProbabilities(
d);
136 for(
Size iName=0; iName<prob.size(); iName++)
137 prob[iName] = copula_->inverseCumulativeY(prob[iName], iName);
144 std::vector<Real> mkft(1, min_ + delta_ /2.);
145 for (
Size i = 0; i < nSteps_; i++) {
146 std::vector<Real> conditionalProbs;
147 for(
Size iName=0; iName<notionals_.size(); iName++)
148 conditionalProbs.push_back(
149 copula_->conditionalDefaultProbabilityInvP(prob[iName], iName,
151 Distribution bld = bucktLDistBuff(lgd, conditionalProbs);
152 Real densitydm = delta_ * copula_->density(mkft);
155 for (
Size j = 0; j < nBuckets_; j++)
basket of issuers and related notionals
void tranche(Real attachmentPoint, Real detachmentPoint)
Real cumulativeExcessProbability(Real a, Real b)
Real confidenceLevel(Real quantil)
void addDensity(int bucket, Real value)
Real expectedShortfall(Real percValue)
Default loss distribution convolution for finite homogeneous pool.
Distribution lossDistrib(const Date &d) const
Real percentile(const Date &d, Real percentile) const override
Value at Risk given a default loss percentile.
std::vector< Real > notionals_
const ext::shared_ptr< ConstantLossLatentmodel< copulaPolicy > > copula_
void resetModel() override
Concrete models do now any updates/inits they need on basket reset.
Real expectedShortfall(const Date &d, Probability percentile) const override
Expected shortfall given a default loss percentile.
Real expectedTrancheLoss(const Date &d) const override
HomogeneousPoolLossModel(const ext::shared_ptr< ConstantLossLatentmodel< copulaPolicy > > &copula, Size nBuckets, Real max=5., Real min=-5., Size nSteps=50)
Loss Distribution for Homogeneous Pool.
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Real Probability
probability
std::size_t Size
size of a container
Loss distributions and probability of n defaults.
HomogeneousPoolLossModel< TCopulaPolicy > HomogTPoolLossModel
HomogeneousPoolLossModel< GaussianCopulaPolicy > HomogGaussPoolLossModel