Real GaussianLHPLossModel::expectedShortfall(const Date& d, 
            Probability perctl) const 
        {
            // loss as a fraction of the live portfolio
            Real ptflLossPerc = percentilePortfolioLossFraction(d, perctl);
            Real remainingAttachAmount = basket_->remainingAttachmentAmount();
            Real remainingDetachAmount = basket_->remainingDetachmentAmount();

            const Real remainingNot = basket_->remainingNotional(d);
            const Real attach = 
                std::min(remainingAttachAmount / remainingNot, 1.);
            const Real detach = 
                std::min(remainingDetachAmount / remainingNot, 1.);

            if(ptflLossPerc >= detach-QL_EPSILON) 
                return remainingNot * (detach-attach);//equivalent

            Real maxLossLevel = std::max(attach, ptflLossPerc);
            Probability prob = averageProb(d);
            Real averageRR = averageRecovery(d);

            Real valA = expectedTrancheLossImpl(remainingNot, prob, 
                averageRR, maxLossLevel, detach);
            Real valB = // probOverLoss(d, maxLossLevel);//in live tranche units
            // from fraction of basket notional to fraction of tranche notional
                probOverLoss(d, std::min(std::max((maxLossLevel - attach)
                /(detach - attach), 0.), 1.));
            return ( valA + (maxLossLevel - attach) * remainingNot * valB )
                / (1.-perctl);
        }
Example #2
0
 // same as percentilePortfolio but tranched
 Real percentile(const Date& d, Real perctl) const {
     const Real remainingNot = basket_->remainingNotional(d);
     Real remainingAttachAmount = basket_->remainingAttachmentAmount();
     Real remainingDetachAmount = basket_->remainingDetachmentAmount();
     const Real attach = 
         std::min(remainingAttachAmount / remainingNot, 1.);
     const Real detach = 
         std::min(remainingDetachAmount / remainingNot, 1.);
     return remainingNot * 
         std::min(std::max(percentilePortfolioLossFraction(d, perctl) 
             - attach, 0.), detach - attach);
 }