예제 #1
0
        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);
        }
예제 #2
0
        Real expectedTrancheLoss(const Date& d) const {
            //can calls to Basket::remainingNotional(d) be cached?<<<<<<<<<<<<<
            const Real remainingfullNot = basket_->remainingNotional(d);
            Real averageRR = averageRecovery(d);
            Probability prob = averageProb(d);
            Real remainingAttachAmount = basket_->remainingAttachmentAmount();
            Real remainingDetachAmount = basket_->remainingDetachmentAmount();


            //const Real attach = std::min(remainingAttachAmount 
            //    / remainingfullNot, 1.);
            //const Real detach = std::min(remainingDetachAmount 
            //    / remainingfullNot, 1.);
            const Real attach = remainingAttachAmount / remainingfullNot;
            const Real detach = remainingDetachAmount / remainingfullNot;

            return expectedTrancheLossImpl(remainingfullNot, prob, averageRR, 
                attach, detach);
        }